5

I created a Linux appliance for my friends. It's a small Ubuntu installation with Trac, lighthttp and ufw configured.

I made it using VirtualBox.

Now I want to export the latest snapshot version with everything secured and configured as a raw disk image for use with KVM.

Now I'm wondering if I wasted several hours of work because I cant figure out how to export.

I've trawled the interwebs but the amount of material is enormous and I haven't found a description of anything similar to what I want to do.

Is it possible?

Bryan Hunt
  • 321
  • 4
  • 14

2 Answers2

7

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!

Bryan Hunt
  • 321
  • 4
  • 14
1

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

dyasny
  • 18,482
  • 6
  • 48
  • 63