Recently, I decided to convert my QEMU based virtual machine installed on my Manjaro Linux to the VirtualBox format. The reason behind this is that I would like to be able to use the same VM across different host system (specifically Manjaro Linux and Windows 7). It is not a easy thing to do, so I decided to document it for future references.
First thing first, you would need to convert the QEMU image (extension img) to raw format, this can be done by issuing the following command:
qemu-img convert Windows7-compressed.img -O raw Windows7.raw
This will generate a raw image. Note that this newly generated file might be a lot larger than the file it based on, this is because the img file allocates space on as-is basis.
After you get the raw image, it's time to convert it to VDI format (which is used by VirtualBox). You can do this by running:
VBoxManage convertfromraw Windows7.raw --format vdi Windows7.vdi
Then, it is recommended to compact the image:
VBoxManage modifyhd Windows7.vdi --compact
So after the previous step, you will have a working VirtualBox image, but if you boot it from VirtualBox, it might not work.
In my case, what I was trying to convert was a Windows 7 VM, and when I finished the above steps and try to boot the VM, I got a BSOD. My feeling is that there were some default that QEMU used that doesn't work for a newly created machine in VirtualBox. I tweak the following settings in the newly created VirtualBox VM:
- Delete the auto created SATA controller and change it IDE controller.
It turned out, after doing that, everything works as expected.