Skip to main content
RunBook Academy

CephXXXVI · RBD ImagesRBD Images

Flattening clones and managing the dependency graph

Advanced⏱ ~17 minrbd

What you'll learn

  • Flatten a clone and predict its cost
  • Decide when flattening is warranted
  • Manage the clone dependency graph at scale
  • Handle deep-flatten and snapshot interactions

Prerequisites

None — start here.

Verified against Ceph Tentacle 20.2.x · Ceph Squid 19.2.x (supported previous) · cephadm matches the verified Ceph release · podman 4.x · csi-rbd and csi-cephfs current · RBD / CephFS / RGW current (matches Ceph release) · Linux kernel 5.15+ (5.10 minimum) · Ubuntu 24.04 LTS (Ceph host baseline) · Debian 12 (Bookworm) (Ceph host baseline) · Rocky Linux / RHEL / AlmaLinux 9.x (Ceph host baseline) · Proxmox VE 9.x (cross-course integration) · Kubernetes 1.31+ (cross-course integration) · 2026-08-18

Not yet marked complete on this device.

Why this matters in production

Flattening converts a cheap reference into an independent copy. It costs capacity and I/O proportional to what the clone had not yet written, and it is the only way out of a dependency graph that has become unmanageable — so it is worth doing deliberately rather than reactively.

Flattening

rbd info rbd-vms/web-01 | grep -E 'parent|overlap'
# parent: rbd-templates/ubuntu-2404@v1
# overlap: 40 GiB

rbd flatten rbd-vms/web-01
# Image flatten: 100% complete...done.

rbd info rbd-vms/web-01 | grep parent   # nothing — independent now

The overlap figure is the cost: that much data is copied from the parent into the clone, consuming that much additional capacity and generating that much I/O.

When to flatten

SituationFlatten?
Clone is long-lived (a production VM)yes
Clone will exist for hours (CI runner)no
Parent template must be retiredyes, required
Clone has already diverged substantiallylittle benefit
Read latency on the clone mattersyes
Capacity is tightno — the reference is the saving

The default policy that works well: flatten clones once they exceed a defined age, on the reasoning that a clone still present after a week is a long-lived volume rather than an ephemeral one.

The cost at scale

# total flattening cost for all children of a template
for c in $(rbd children rbd-templates/ubuntu-2404@v1); do
  rbd info "$c" | awk '/overlap/{print $2, $3}'
done

Flattening 300 clones of a 40 GiB template can mean copying several terabytes and hours of cluster I/O. Stage it, throttle it, and run it outside peak periods.

deep-flatten

rbd info rbd-vms/web-01 | grep features
# features: layering, exclusive-lock, object-map, fast-diff, deep-flatten

Without deep-flatten, flattening a clone that has its own snapshots leaves those snapshots still depending on the parent — so the parent still cannot be removed. With it, the flatten covers the clone’s snapshots too and the dependency is genuinely broken.

This is why deep-flatten is in the default feature set and should stay there: without it, a clone with snapshots is a dependency you cannot clear without deleting the snapshots.

Keeping the graph manageable

rbd children rbd-templates/ubuntu-2404@v1
rbd snap ls rbd-templates/ubuntu-2404

Practices that keep template retirement possible:

  • Record the template and version each volume was cloned from
  • Flatten clones after a defined age, automatically
  • Limit the number of live template versions
  • Check rbd children before any template lifecycle change

Quiz

Knowledge check · 4 questions

  1. Q1. What does the `overlap` figure in `rbd info` on a clone tell you?

  2. Q2. Without deep-flatten, flattening a clone that has its own snapshots fully removes the dependency on the parent.

  3. Q3. Plan a bulk flatten before template retirement.

    A 60 GiB template has 280 clones that must be flattened so it can be retired. Average overlap across the clones is 44 GiB. The cluster is at 74% capacity with 180 TB usable.

  4. Q4. Why is flattening a one-way operation?

Passing score: 75%. Answers are checked in this browser.

Production discipline

Flatten on a defined age policy rather than reactively, since the decision is irreversible and the capacity it consumes is permanent. Sum the overlaps and multiply by the replication factor before any bulk flatten — the raw-capacity figure is what determines whether the operation is safe on the current cluster.

Cross-course references

  • Kubernetes: promoting a snapshot-backed PVC to a full volume is the same one-way conversion
  • Linux: breaking an overlayfs lower layer by copying it up has identical semantics