sparse a virtual machine disk

I’ve made a test to find the best “compressed” solution for thin provisioning on virtual machines.

f18.qcow2 is a default minimal Fedora 18 installation.

$ qemu-img info f18.qcow2
image: f18.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 1.1G
cluster_size: 65536

Below is the result, sorted by size

1170252 f18.qcow2
 746188 f18.qcow2.spars
 253552 f18.qcow2.spars.compressed
 236860 f18.qcow2.spars.compressed.lrz
 236076 f18.qcow2.spars.compressed.xz
 151028 f18.qcow2.xz
 146172 f18.qcow2.spars.xz
 141276 f18.qcow2.spars.lrz
 141048 f18.qcow2.lrz

It seems that Con Kolivas has made an extraordinary work with lrzip

And these are the commands i’ve run (sorted by the result of above output):

f18.qcow2 qemu-kvm f18.qcow2 -cdrom Fedora-18-x86_64-netinst.iso -cpu host -usbdevice tablet -m 2048
f18.qcow2.spars virt-sparsify f18.qcow2 f18.qcow2.spars
f18.qcow2.spars.compressed virt-sparsify - -compress f18.qcow2 f18.qcow2.spars.compressed
f18.qcow2.spars.compressed.lrz lrzip f18.qcow2.spars.compressed
f18.qcow2.spars.compressed.xz xz -k f18.qcow2.spars.compressed
f18.qcow2.xz xz -k f18.qcow2
f18.qcow2.spars.xz xz -k f18.qcow2.spars
f18.qcow2.spars.lrz lrzip f18.qcow2.spars
f18.qcow2.lrz lrzip f18.qcow2

My specs are:

$ grep 'model name' /proc/cpuinfo | head -1
model name : Intel(R) Core(TM) i7-3517U CPU @ 1.90GHz

$ grep -c processor /proc/cpuinfo 

$ grep MemTotal /proc/meminfo 
MemTotal:        8038060 kB