I have a qemu qcow2 disk snapshot dev.img
that is based off a backing file dev.bak
.
How can I merge both into a standalone devplus.img
, while leaving dev.bak
as it is?
In essence, QCOW2(Qemu Copy-On-Write) gives you an ability to create a base-image, and create several 'disposable' copy-on-write overlay disk images on top of the base image(also called backing file).
qcow is a file format for disk image files used by QEMU, a hosted virtual machine monitor. It stands for “QEMU Copy On Write” and uses a disk storage optimization strategy that delays the allocation of storage until it is needed.
I got some help from the qemu mailing list: First copy the original base file to your standalone image file:
cp dev.bak devplus.img
Then "rebase" the image file that was backed off the original file so that it uses the new file:
qemu-img rebase -b devplus.img dev.img
Then you can commit the changes in the dev file back into the new base:
qemu-img commit dev.img
Now you can use devplus.img as a standalone image file and get rid of dev.img if you wish, leaving the original dev.bak intact and not corrupting any other images that were based off it.
qemu-img convert -O qcow2 dev.img devplus.img
This detects that dev.img is based off dev.bak and creates a standalone devplus.img.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With