18

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?

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76
user2512377
  • 501
  • 1
  • 3
  • 9

2 Answers2

18

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.

user2512377
  • 501
  • 1
  • 3
  • 9
11
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.