Mailinglist Archive: opensuse-virtual (68 mails)

< Previous Next >
Re: [opensuse-virtual] is there a clever way to shrink qcow2 images
  • From: Rob Verduijn <rob.verduijn@xxxxxxxxx>
  • Date: Wed, 21 Aug 2013 15:48:30 +0200
  • Message-id: <>

virt-sparsify is definitely going to make the shrinking of qcow2
images less annoying, but it still produces a new disk image and
requires downtime for the vm.

The other tools in guestfs look very interesting as well, they will
make life a lot easier.

Thanx for the tip

2013/8/20 Jim Fehlig <jfehlig@xxxxxxxx>:
Rob Verduijn wrote:
Hello all,

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

Thanks for all the info you provided in this thread!

I'd like to add that virt-sparsify, virt-resize, and the other virt-*
tools in the guestfs-tools package are also useful for manipulating 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