QEMU Disk Management

When I first got started with QEMU, I simply created .qcow images, assuming the formatting would be based on the file extension. I was either wrong or they changed how qemu views the file. So, in order to migrate my virtual machines from raw image drives to the qcow2 format to avoid a complete rebuild, I had to do the following.

First I made a backup of my currently running virtual machine disk.

cp /VMs/dns-server/dns-server.qcow /VMs/dns-server/dns-server.qcow2.bak

Then I got down to the conversion to the qcow2 format.

qemu-img convert /VMs/dns-server/dns-server.qcow -f raw /VMs/dns-server/dns-server.qcow2 -O qcow2

I made use of the info feature of the qemu-img program to validate the format of my new disk.

qemu-img info /VMs/dns-server/dns-server.qcow2

Then I generated a snapshot of the virtual machine, so I can fall back to that snapshot if and when I goof something up.

qemu-img snapshot -c /VMs/dns-server/30SEP15.snapshot /VMs/dns-server/dns-server.qcow2

Then I was able to simply stop my virtual machine, modify my startup script to look for the new .qcow2 hard disk, and restart the virtual machine!