[09-Dec-2019] [Based on discussion with the QEMU Block Layer folks; thanks Kevin Wolf.] Suppose we have a disk image chain: base.raw <-- overlay1.qcow2 To flatten the above chain, i.e. merge the contents of overlay1.qcow2 into base.raw, 'qemu-img' offers three *offline* ways: (1) Using 'commit': $> qemu-img commit overlay1.qcow2 Notes: - This is in-place copy. Copies contents of overlay1 into its backing file, base.raw. (2) Using 'rebase': $> qemu-img rebase -b base.raw overlay1.qcow2 Notes: - There are "two modes" of 'rebase' (read the manual page for details), "Safe mode" (it's the default) and "Unsafe mode". - The "Unsafe mode" (-u) only changes the backing file pointer, but by default `qemu-img rebase` copies the delta into the overlay. (3) Using 'convert': $> qemu-img convert -f qcow2 -O qcow2 overlay1.qcow2 flattened.qcow2 Notes: - The difference is that 'commit' and 'rebase' are *in-place*, while 'convert' creates a new copy (of base + overlay1). - 'convert' also does sparsification ("the empty sectors are detected and suppressed from the destination image"). - Because 'convert' creates a new copy, it is thus slow, and takes double the disk space. When to use when? ---------------- - If the backing file is shared or the overlay actually overwrites most of the blocks, 'rebase' makes more sense. - Use 'convert' if you can (a) accept the slowness due to the copy containing the contents of both 'base' and 'overlay1'; and (b) have no disk space constraints, because of point (a).