In this guide, we’ll show you how to convert a VirtualBox VM with the “.vdi” extension to a KVM VM with the “.qcow2” extension. This is a guide for folks who want to transition from VMware to KVM virtualization without having to start from scratch.
Step 1: Open CMD and locate your VirtualBox directory.
Firstly, open your command prompt and locate your VirtualBox directory using the cd command.
Step 2: Clone and convert your VDI file into a raw image file.
To clone and convert the file, run the following command in your command prompt.
VboxManage clonehd “absolutepath/filename_of_existing_vdi_file.vdi” “absolutepath/filename.img” -format raw
Here is an example of my command.
VBoxManage clonehd “D:\Oracle\VirtualBox VMs\Ubuntu\Ubuntu.vdi” “D:\Oracle\VirtualBox VMs\Ubuntu\Ubuntu.img” -format raw
You will be seeing a similar output as followed in your command prompt.
0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100% Clone medium created in format ‘raw’. UUID: afdb24d-1a3c-4276-9251-bf2616f9b75e
You will be able to see an image file in the directory you had cloned into. The raw image file will be much larger in comparison with your “.vdi” file.
Step 3: Converting image file into the ".qcow2" file which is the file type for KVM.
This final step requires you to use the qemu-ing command, kindly refer to this link if you do not have the command installed, else skip this step if you already have it installed and proceed with the guide.
Run the following command for the “.img” to “.qcow2” conversion.
qemu-img convert -f raw -O qcow2 “absolutepath/filename_of_existing_img_file.img” “absolutepath/filename.qcow2”