user2512377
user2512377

Reputation: 551

Transforming qcows2 snapshot plus backing file into standalone image file

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?

Upvotes: 21

Views: 13504

Answers (2)

Tigran Ghahramanyan
Tigran Ghahramanyan

Reputation: 151

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.

Upvotes: 13

user2512377
user2512377

Reputation: 551

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.

Upvotes: 19

Related Questions