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.
Use 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.
- One method is to convert VDI to raw disk image (.img) and then convert the raw disk image to QCOW2.
- Another method is to directly convert VDI to QCOW2 using the qemu-img command.
Convert VirtualBox VDI to Raw Disk Image
Create a directory to store KVM images. (Not necessary).
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 (
You should now be having a RAW virtual machine disk image, located in the
~/kvm-images for our case.
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,
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
qemu-img convert -p 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
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.
That is all on how to use VirtualBox VMs on KVM.