Linux – How to boot a KVM virtual machine raw image to VirtualBox

linuxlinux-kvmmountqemuvirtualbox

I have received a .img file of a server which is a Virtual Machine running in a KVM environment. The Virtual Machine was installed with Ubuntu.

I would now like to take this .img file and "emulate" the server within VirtualBox. So I have converted the .img file to a .vdi file using qemu-img from raw to vdi, however the VirtualBox instance starts up and simply states:

FATAL: No bootable medium found! System halted.

I do not know if I would have to install KVM in VirtualBox and then configure it to run the VM in my .img file, or if I would be able to convert the image from KVM to VDI and then just run the server in VirtualBox directly.

What I have tried already is using qemu to convert the .img raw file to a .vdi, but that produced the above errors.

I have also read the answer on this Server Fault question, but this question is slightly different, as it is talking about moving a Windows VM from KVM to VirtualBox.

I have also tried converting from qcow2 to vdi using the qemu-img linux package, however I continually get the following error messages:

#> qemu-img convert -f qcow2 original.img -O vdi converted.vdi
qemu-img: Could not open './duketest.img': Invalid argument
qemu-img: Could not open './duketest.img'

I have also tried converting using the VBoxManage command as shown on this page:

http://funcptr.net/2012/04/01/converting-kvm-virtual-machines-to-virtualbox/

This also provides the error message I mentioned at first:

FATAL: No bootable medium found! System halted.

Thanks in advance!

Best Answer

There's a few small issues with your conversion stanza.

qemu-img convert -f qcow2 original.img -O vdi converted.vdi tells you to explicitly convert a qcow2 file to a VDI, and you have an raw image file. You essentially told your computer to translate a french text, using a spanish translator, into english.

You are better off with qemu-img convert -O vdi original.img original.vdi - letting qemu decide what's the format of the input implicitly. If you must, I believe the right input format for a img is raw, not qcow.

I've tested using the command I used in conversion from from qcow2 to VDI and and from a raw file to a VDI it works. (Interestingly qcow2 to raw to VDI dosen't.)

Just to confirm what I did

  1. Create a VM with libvirt-manager with a qcow or img disk image
  2. Install Ubuntu Minimal
  3. Check if the system boots
  4. Use qemu-image with mu-img convert -O vdi original.ext original.vdi for both files
  5. Move the file over to a windows/virtualbox system
  6. Check to see if it boots.
Related Question