How To

Importing Virtual Machine from VirtualBox to KVM

Convert VirtualBox VDI disks to KVM QCOW2 disks

There are two methods to achieve the conversion of virtualbox disks formats to KVM disk formats:

Original content from computingforgeeks.com - post 76047
  • Convert VDI to raw disk image (.img) and then convert the raw disk image to QCOW2.
  • Directly convert VDI to QCOW2 using the qemu-img command.

Let us look at the first method of converting VirtualBox VDI first to a raw disk and later to KVM format.

Convert VirtualBox VDI to Raw Disk Image

In my local machine, I have installed Oracle 9 in VirtualBox and I have its virtual disk images stored in ~/VirtualBox VMs/Oracle8. I am changing into this directory and convert the Oracle 8.vdi image to raw image as below:

$ sudo vboxmanage clonemedium --format RAW Oracle-8.vdi Oracle8.img
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'RAW'. UUID: 49451559-be0f-49d2-b804-41c62e266760

You should notice a ram image created.

$ ls
Oracle8.img

Note that /home/lorna/KVM/ is just a directory which I created to hold the converted images. Now we are going to convert .img to KVM format, qcow2, by executing the below command in the directory where the raw image is saved:

sudo qemu-img convert -f raw Oracle8.img -O qcow2 Oracle8.qcow2

You should notice two images in the directory.

$ ls
Oracle8.img  Oracle8.qcow2

Convert VDI images directly to QCOW2

You can directly and simply convert a vdi image to qcow2 by running the below command:

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

Run a VM on KVM by importing an Image

To use the created Image to create a VM on KVM, open virt manager and click on the VM icon to create a new virtual machine. Choose Import Existing Disk Image and click Forward.

Importing Virtual Machine from VirtualBox to KVM 01

Next, browse to the location of the image then click Forward.

Importing Virtual Machine from VirtualBox to KVM 02

Specify CPU and RAM for your VM and click Forward.

Importing Virtual Machine from VirtualBox to KVM 03

Next, verify settings and click Finish.

Importing Virtual Machine from VirtualBox to KVM 04

Your VM will begin creating.

We have successfully learned how to convert VirtualBox disk images to KVM format. You may also need to check on how to install Virtualbox and KVM hypervisors. Click the links below:

Related Articles

CentOS How To Install VirtualBox 7.0 on CentOS 8 / RHEL 8 Networking Configure and Use Dnsmasq DHCP Server in Proxmox VMs Virtualization How To Install Vagrant on Rocky 8 / RHEL 8 Cloud Install Flatcar Container Linux on VMware ESXI / vCenter

Leave a Comment

Press ESC to close