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:

  1. vditool COPYDD vbox-image.vdi raw-image.img
  2. qemu-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.

    • wazaz
    • March 18th, 2008

    Thank you very much! This is just what i’m looking for! Thank you for sharing your experience! Have a nice day!

    • mam
    • June 2nd, 2008

    Thank you for this great post. vditools can be simple download from: http://www.virtualbox.org/download/testcase/vditool

    • as
    • June 17th, 2008

    Just what i was looking for, thanks!

  1. Thanks for the information!

    • Andrew
    • August 29th, 2008

    Thanks a lot. This is just what i needed after virtualbox-ose couldn’t support ubuntu-server. hopefully qemu can (fingers crossed X)

    • Shuki
    • December 14th, 2008

    Awesome.

    QEMU/KVM takes 1% cpu when idle.
    VirtualBox OTOH takes 70%.

    • isama
    • December 20th, 2008

    @andrew: ubuntu server will run on virtualbox as long as you enable pae or install a generic kernel

  2. You are now my qemu god. This is precisely what I needed.

    • markus
    • April 29th, 2009

    Where can I find vditool? The link above is broken…

  3. 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.

    • ed
    • May 26th, 2009

    saved my day.

    • larry
    • July 21st, 2009

    thanks!!!!

    • pang
    • May 11th, 2010

    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!