Converting KVM images to logical volumes

When creating virtual disks for KVM you can use several methods. Most people use flat files in one of several formats - raw and qcow2 being the most popular. qcow2 files can compressed and also have "holes" (where unused space doesn't use up real space).

We recently converted some old systems from flat files to using logical volumes as it's the recommended approach these days.

If you are using raw flat files (use "qemu-img info filename.img" to find out) then you can just use "dd if=filename.img of=/dev/rootvg/logicalvolume".

However if you are using any other format of file as your source (e.g. qcow2) then you need to use qemu-img (which in qemu-kvm is called "kvm-img"). Normally you would use this: "kvm-img convert -O format filename.img output.img". You might expect to be able to say "-O raw" but this will fail for block devices - you need to use "-O host_device". Sadly that wasn't documented so we've submitted a patch to fix that.

We have also updated the KVM packages to v0.11 (32-bit Debian Lenny packages only at the moment).