How to convert VirtualBox vdi to KVM qcow2

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.

10 thoughts on “How to convert VirtualBox vdi to KVM qcow2”

  1. 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?

    Reply
    • 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.

      Reply
  2. 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?

    Reply

Leave a Reply to jgershaterCancel reply