It is very easy to convert a VirtualBox .vdi disk images to KVM qcow2 file. You have to use the RAW file format as an intermediate.
1 – Make sure the VirtualBox machine is shutdown.
2 – Convert the vdi to a raw disk images. Note: vdi are compressed and raw images are not and so you will need to leave enough disk space for entire uncompressed disk.
VBoxManage clonehd --format RAW vm.vdi vm.img
3 – Then on your KVM host:
qemu-img convert -f raw vm.img -O qcow2 vm.qcow2
Hope this is helpful.
qemu-img support VDI, so it can be convert directly:
“`bash
qemu-img convert -f vdi -O qcow2 vm.vdi vm.qcow2
“`
That is good to know. Thanks.
Saved me lot of trouble.
Your comment saved me some wandering around. OP should update it’s post.
qemu-img understands only ‘plain’ VDI images without snapshots. So in my case I had to create ‘plain VDI’ image first:
$ cd ~/VirtualBox VMs/Linuxes/sles11x64/Snapshots
$ ls -lt (pick the latest)
$ VBoxManage clonehd –format VDI “{d30c5f02-1d3c-45a0-a631-254b865b0dfd}.vdi” bsles11x64_current.vdi
people like you make the internet a better place. thank you twang2218
Curious, when I convert the vdi to qcow2 image, I started with a 28g .vdi image and ended with a 3.5g .qcow2 image. When I start the qcow2 image my partition sizes are the same as on the vdi image. Is there a way to convert the images and keep the same image size?
Qcow2 format is an automatic compressed image file. then it’s dynamic, not fixed file size. Only fixed partition size with file compression data.
see man qemu.
Don’t I need to remove the MAC address from the network config files?
What about installing cloud-init so the qcow2 can be used on public clouds?