[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 exercise. Does anybody have any ideas on a more elegant solution ? cheers Rob -- To unsubscribe, e-mail: opensuse-virtual+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-virtual+owner@opensuse.org
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: opensuse-virtual+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-virtual+owner@opensuse.org
Hi, 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 Rob 2013/8/20 Jim Fehlig <jfehlig@suse.com>:
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: opensuse-virtual+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-virtual+owner@opensuse.org
This is more to my likings : zerofree see : http://intgat.tigress.co.uk/rmy/uml/index.html To bad its only for ext2 and ext3 Rob 2013/8/21 Rob Verduijn <rob.verduijn@gmail.com>:
Hi,
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 Rob
2013/8/20 Jim Fehlig <jfehlig@suse.com>:
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: opensuse-virtual+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-virtual+owner@opensuse.org
participants (2)
-
Jim Fehlig
-
Rob Verduijn