Use VirtualBox VMs on KVM

|
Last Updated:
|
|

Do you have some VirtualBox virtual machines that you would like to re-use on your KVM? Follow through this guide to learn how to use VirtualBox VMs on KVM.

Using VirtualBox VMs on KVM

The first thing to note is that both VirtualBox and KVM uses different disk formats. In order to re-use each format on different virtualization platform, you simply need to convert the disks to the format supported by each virtualization solution in question.

Well in that regard, in this guide, we are going to learn how to convert VirtualBox VDI disks to KVM QCOW2 disks.

We also assume that you are not running VirtualBox and KVM on the same host at the same time.

There are two ways in which we can convert the VirtualBox disk image into KVM qcow2.

Convert VirtualBox VDI to Raw Disk Image

Create a directory to store KVM images. (Not necessary).

mkdir ~/kvm-images

Next, convert a specific VirtualBox VM disk to raw image.

vboxmanage clonemedium --format RAW /path/to/vm-disk-name.vdi ~/kvm-images/vm-disk-name.img
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'RAW'. UUID: 261d0760-16bd-4cfd-a852-96861293f663

Replace the location of the VirtualBox VM and the name of the VM disk (/path/to/vm-disk-name.vdi) accordingly.

You should now be having a RAW virtual machine disk image, located in the ~/kvm-images for our case.

ls ~/kvm-images
vm-disk-name.img

Convert RAW Disk Image to KVM QCOW2

Now, copy the raw disk image to the host running KVM and convert it to the format supported by KVM, in this case, qcow2.

The conversion can be done by executing the command below;

qemu-img convert -f raw vm-disk-name.img -O qcow2 vm-disk-name.qcow2

Convert VDI Directly to QCOW2

You can simply do the direct conversions of VDI to QCOW2 by executing the command below;

qemu-img convert -f vdi -O qcow2 vm-disk-name.vdi vm-disk-name.qcow2

Convert OVA to QCOW2

What if you have an OVA image exported from VirtualBox? In this case, then you also need to convert the OVA to QCOW2 image.

How to convert OVA to QCOW2?

  • Extract disk image from OVA;
tar xf <name>.ova

You will either have VDI or VMDK depending on how the vm was created. See example files below

ls -1
ubuntu22.vmdk
ubuntu22.mf
ubuntu22.ova
ubuntu22.ovf
  • In the above case, you need to convert VMDK image to QCOW2 format:
qemu-img convert -f vmdk -O qcow2 ubuntu22.vmdk ubuntu22.qcow2

Create New KVM Virtual Machine

You can now transfer the QCOW2 disk image to KVM host.

After that, you can create a new virtual machine by importing from the existing disk image.

Related Tutorials

How to Rename KVM Virtual Machine with virsh command

Install VirtualBox Guest Additions on CentOS 8

AutoStart VirtualBox VMs on System Boot on Linux

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment