Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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!

share|improve this answer
    
FYI some qemu CLIs need it like this: qemu-img convert -f raw -O qcow2 minimal.vdi minimal.qcow –  Michael Neale Apr 17 '12 at 7:08

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

share|improve this answer
    
No, I want to preserve the exact state. Running a clone from within the VM is not ideal for that. –  Bryan Hunt Mar 21 '11 at 17:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.