Mailinglist Archive: opensuse-virtual (68 mails)

< Previous Next >
[opensuse-virtual] is there a clever way to shrink qcow2 images
Hello all,

I'm looking for a clever way to shrink qcow2 images.

what I do now is :

1 in the vm delete the files I don't need (tempfiles, spoolfiles,
junkfiles, etc, etc)
2 fill the empty space with zeros
dd if=/dev/zero of=bigfile bs=1024k ; sync ; rm bigfile ; sync
3 shut down the vm
4 convert the qcow2 to a fresh new qcow2
qemu-img convert -c -O qcow2 orig.qcow2 shrunk.qcow2
mv orig.qcow2 orig.qcow2.bak
mv shrunk.qcow2 orig.qcow2
5 test the vm
6 delete the backup if it works

Now this is fine if you got plenty space and just want to tidy up a
bit before it turns bad.

But what if there is no space, and adding extra partitions is not that easy.
(imagine an offsite, far off location that is a real pain to get into
due to serious security hassle)

Or if you are me and are seriously annoyed by the cumbersome exercise
above and have a gut feeling that there should be a more elegant way
(preferably one without downtime)

The above exercise requires to be done on all the partitions of the
qcow2 image if there is more than one, adding to my irritation of the

Does anybody have any ideas on a more elegant solution ?

To unsubscribe, e-mail: opensuse-virtual+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-virtual+owner@xxxxxxxxxxxx

< Previous Next >
This Thread
Follow Ups