How to Use Virtualbox VMs on KVM In Linux

Are you considering making a switch from VirtualBox to KVM hypervisor? One of your greatest concerns would be starting all over again by creating new virtual machines in KVM – an arduous task to say the least.

The good news is that instead of creating new KVM guest machines, you can easily migrate the VirtualBox VMs which are in VDI format to qcow2 which is the disk image format for KVM.

In this guide, we are going to outline a step-by-step procedure of how you migrate VirtualBox VMs into KVM VMs in Linux.

Step 1: List Existing VirtualBox Images

First and foremost, ensure that all the virtual machines are powered off. Virtualbox guest machines exist in VDI disk format. Next, proceed and list the existing VirtualBox virtual machines as shown.

$ VBoxManage list hdds
OR
$ vboxmanage list hdds

From the output, you can see that I have 2 Virtual Disk Images – Debian and Fedora VDI images.

List Virtualbox Images in Commandline
List Virtualbox Images in Commandline

Step 2: Convert VDI Image to RAW Disk Format

The next step is to convert the VDI images into a RAW disk format. To achieve this, I’m going to run the commands below.

$ VBoxManage clonehd --format RAW /home/james/VirtualBox\ VMs/debian/debian.vdi debian_10_Server.img
OR
$ vboxmanage clonehd --format RAW /home/james/VirtualBox\ VMs/debian/debian.vdi debian_10_Server.img
Convert VDI Image to RAW Disk Format
Convert VDI Image to RAW Disk Format

When you investigate, you will notice that the RAW image format takes up an enormous amount of disk space. You can use the du command as shown to verify the size of the RAW image.

$ du -h debian_10_Server.img

In my case, the Debian RAW image takes up 21G of hard disk space, which is quite some enormous space. We are later going to convert the RAW disk image to KVM disk format.

Check RAW Image Disk Space
Check RAW Image Disk Space

Step 3: Convert RAW Image Disk Format to KVM Format

Lastly, to migrate to KVM disk image format, convert the RAW image to qcow2 format which is the KVM disk image format.

$ qemu-img convert -f raw debian_10_Server.img -O qcow2 debian_10_Server.qcow2

The qcow2 disk image is just a minute fraction of the RAW disk image. Again, verify this using the du command as shown below.

$ du -h debian_10_Server.qcow2
Check Disk Space of qcow2 Image
Check Disk Space of qcow2 Image

From here, you can import the qcow2 KVM image format either on command-line or using the KVM graphical window and create a new KVM virtual machine.

This wraps up our article for today. Your thoughts and feedback are much welcome.

Source: ostechnix.com

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

3 thoughts on “How to Use Virtualbox VMs on KVM In Linux”

  1. qemu-img can convert VirtualBox VDI format directly to KVM’s qcow2 format.

    No need for an in-between RAW format conversion.

    # qemu-img convert -f vdi -O qcow2 image.vdi image.qcow2
    
    Reply

Leave a Reply to Swapnil Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.