How to export a specific virtualbox snapshot as a raw disk image

Solution 1:

I think I've figured it out.

Step 1)

Go to the snapshots directory. You can figure out which of the uuid encoded filenames refers to your snapshot by consulting the Virtual Media Manager (ctrl-D under ubuntu).

cd ~/.VirtualBox/Machines/ubuntu-minimal
VBoxManage clonehd 7020aee6-f3aa-49d1-805a-30a127132c90 /home/vm-exports/ubuntu-minimal.vdi -format raw

Step 2) Ok, so now we have exported the entire disk state. So all we have to do is convert it to a format which KVM understands.

du -h /home/vm-exports/ubuntu-minimal.vdi
8.0G    /home/vm-exports/ubuntu-minimal.vdi

It appears to be the size of the disk.

Step 3)

Get rid of that big 8GB MOFO. Let's convert to qcow format.

cd /home/vm-exports/
qemu-img convert -f raw ubuntu-minimal.vdi -O qcow2 ubuntu-minimal.qcow

Step 4)

Lets test it with KVM

kvm -m 512 -hda ubuntu-minimal.qcow

Yay. It works, happy days!

Solution 2:

normally, you'd want to have a look at virt-v2v, but afaik it doesn't support virtualbox. So instead, why not just image the VM into a similar sized v-disk attached to a kvm based VM? dd over netcat is the most basic choice, but clonezilla seems like a nice solution as well