Thursday, April 14, 2011

How to Convert VirtualBox VDI image to KVM

The idea is very simple. We convert virtualbox vdi image to raw format and than from raw format to kvm specific. I have chosen qcow2 format based on this.
  1. Convert img.vdi to raw format. Please note, that raw format means if your vdi image is configured for maximum size of 10 Gb than the resulting raw file will be 10 Gb. Make sure you have enough disk space.
    VBoxManage clonehd --format RAW img.vdi img.raw
  2. And now raw image to qcow2 format. Here the resulting file (img.qcow2) will be the same size as the original one (img.vdi).
    qemu-img convert -f raw -O qcow2 img.raw img.qcow2
  3. Delete raw file since you will not need it anymore.
You can attach resulting img.qcow2 file to the kvm virtual machine now.

1 comment :