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.

Regards,
Jim

> 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
> exercise.
>
> Does anybody have any ideas on a more elegant solution ?
>
> cheers
> Rob
>   
-- 
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]

Reply via email to