VirtualBox to QEMU
Recently, I had cause to convert a VirtualBox virtual machine to one compatible with QEMU and KVM. A quick search found me multiple methods for converting an image QEMU -> VirtualBox but nothing helping me to go from VirtualBox -> QEMU. After asking on the PLUG mailing list, I got some help and managed to convert it without any issues. In order to do it, you’ll need the vditool tool contained in the virtualbox-ose package available from the Debian repositories. Here’s how I got it working:
vditool COPYDD vbox-image.vdi raw-image.imgqemu-img convert -f raw raw-image.img -O qcow2 qemu-image.qcow
The first step copies the contents of the image (*.vdi is the VirtualBox filesystem image extension) to a raw disk image. Be advised: this file will be the full size of the virtual hard drive. That means that, unlike *.vdi and *.qcow formats, if the virtual disk has a maximum capacity of 8Gb, the raw image will be 8Gb in size regardless of how full the disk is.
Once you have the raw image, run the second step which uses the QEMU disk image manipulation tool, qemu-img, to convert the raw image into the QCOW2 format. The new QEMU image will be much smaller than the raw image was and it can be made smaller by passing qemu-img the -c option to enable transparent compression. However, seeing as how this just uses zlib on each cluster, this might introduce more overhead to I/O than is desired and will most likely degrade your overall VM performance.
UPDATE: 2010-05-14
It looks like vditool is no longer available. It also seems like you could use the VBoxManage tool included with VirtualBox to do the conversion but that option has also been removed. The good news is that qemu-img now has support for *.vdi files and can be used directly.















Thank you very much! This is just what i’m looking for! Thank you for sharing your experience! Have a nice day!
Thank you for this great post. vditools can be simple download from: http://www.virtualbox.org/download/testcase/vditool
Just what i was looking for, thanks!
Thanks for the information!
Thanks a lot. This is just what i needed after virtualbox-ose couldn’t support ubuntu-server. hopefully qemu can (fingers crossed X)
Awesome.
QEMU/KVM takes 1% cpu when idle.
VirtualBox OTOH takes 70%.
@andrew: ubuntu server will run on virtualbox as long as you enable pae or install a generic kernel
You are now my qemu god. This is precisely what I needed.
Where can I find vditool? The link above is broken…
A quick update: vditool is no longer part of VirtualBox, but you can use
VBoxManage clonehd $ABSOLUTE_PATH_OF_VDI –format raw $OUTPUT
to get the same result with VirtualBox 2.
saved my day.
thanks!!!!
I always forget VirtualBox and kvm are incompatible. I was stuck with one working machine in VirtualBox and another in kvm. Now I can move on. Thanks!