In the following article, we’ll go through the steps how to convert Virtualbox VMs to QEMU/KVM hypervisor, or in another words, how to convert VM files from VDI to QCOW2 extenstion. This process is useful especially when you need to migrate from virtualbox to KVM or just want to try out the KVM hypervisor without  the need to create new machines from the start.

What is VDI?

VDI(Virtual desktop infrastructure) is an file extension of the HDD disc image file for an Virtual machines that are commonly used by hypervisor solutions such as Virtualbox.

What is QCOW2?

QCOW2 is also an HDD disc image file for Virtual machines that are used by QEMU based hypervisors.

Convert Virtualbox VMs to QEMU/KVM[VDI to QCOW2]

Before starting with the conversion/migration process, on Virtualbox, all VMs must be powered of.

The process requires the terminal usage but the steps are quite simple and straightforward. Essentially all it requires is one command to be run and that is:

qemu-img convert -f vdi -O qcow2 rocky.vdi rocky8.qcow2

For this command to work you need to navigate to the directory of the source image file(VDI file where it’s located) and in the same directory, the new qcow2 image for the KVM will be saved as well. You can also run it like this to target the source and destination without navigating to directories:

qemu-img convert -f vdi -O qcow2 /home/markon/VirtualBox VMs/debian KDE/debian-kde.vdi /var/libvirt/images/debian-kde.qcow2

The process in the terminal should look like something like this:

Convert Virtualbox VMs to QEMU/KVM

Command breakdown:

  • convert: argument to run the conversion process
  • -f: input image type
  • -O: output image type

Then follows the input image and it’s location with output directory with the new image name and qcow2 extension.

Second option - Convert VDI to IMG( RAW) and then to QCOW2

If by any chance, the first method does not work for you, or you get errors, then you can try to first convert the VDI VM image to the RAW image(IMG extension) and then from RAW to QCOW2. You should be more successful with method. Here’s how to do it:

Locate the Virtualbox VM image location:

vboxmanage list hdd

Then in terminal, with the Virtualbox tool “vboxmanage” convert the VM to the RAW(IMG) file:

vboxmanage convertdd debian-11.vdi debian11.img

Convert Virtualbox VMs to QEMU/KVM

After that, again with the “qemu-img” tool, convert the RAW(IMG) file to the QCOW2

qemu-img convert -f raw -O qcow debian11.img debian11a.qcow2

Convert Virtualbox VMs to QEMU/KVM

Import the qcow2 into the KVM VM

After the conversion is completed, the new dics image needs to be imported(added) on the new VM you created in the Virtual machine manager. So, start to create the new VM in the Virtual machine manager. On the first prompt, select the option “import the disc image” and click forward:

Convert Virtualbox VMs to QEMU/KVM

Next screen is to locate the disc image you converted:

Convert Virtualbox VMs to QEMU/KVM

The last screen is the preview screen of the you’ll create and it comes with the option that you can customize the VM and it’s hardware before running the machine if you need. Click the finish button and the VM creation will start:

Convert Virtualbox VMs to QEMU/KVM

One note to keep in mind:

During the migration/conversion process, if for an example you’ve added multiple devices in your VM while it was running on Virtualbox, like multiple network adapters, you need to match those extra devices in Virtual machine manager(KVM or libvirt), otherwise the devices will be lost and you’ll need to add them again from start.


Ih this article we covered the following steps - how to convert Virtualbox VMs to QEMU/KVM or in another words how to convert virtualbox machines for the KVM hypervisors(KVM/QEMU hypervisors) or to be precise, their VM HDD files, from VDI to QCOW2 and also covered how to convert VM HDD image from VDI to IMG(RAW) and to QCOW2 afterwards.

Lastly, we review how to import the newly convet QCOW2 image to a new VM created in the Virtual machine manager.

Thank you for your time…