I tend to use rsync to backup my system ( including VMs) thanks an anoying bug[1] . Turns out, this would sync the entire sparse file, expanding from 11gb on disk to 64gb on target system.
To "fix" this I now use qcow2 for disk image, based of instructions from here[2].
- Move existing images to qcow2 , if not done. This also would allow us to use snapshots via virt-manager [3]
# convert existing raw images to qcow2 image
$ qemu-img convert -O qcow2
$ mv orig.img orig.img.bak
$ mv new.img orig.img
# assuming the first device marked raw is the hdd
$ sed -i 's/raw/qcow2/' /etc/libvirt/qemu/orig.xml
|
- Fill VMs with zeros to allow them to be compressed
$ dd if=/dev/zero of=/mytempfile
$ rm -f /mytempfile
|
- Shut down the VMs, and run from host
$ mv original_image.qcow2 original_image.qcow2_backup
$ qemu-img convert -O qcow2 original_image.qcow2_backup original_image.qcow2
[1] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1259829
[2] http://www.jamescoyle.net/how-to/323-reclaim-disk-space-from-a-sparse-image-file-qcow2-vmdk
[3] http://www.phoronix.com/scan.php?page=news_item&px=MTQ0NjM