Tuesday, June 08, 2010

Converting vdi to vmdk

The only Windows installation I have is in a virtual machine that I keep for odd jobs. Usually these jobs are related to firmware updates because manufactures usually do not support Linux out-of-box. Generally the non-open source edition of VirtualBox works very well with USB pass-through. One item in which it decidedly failed is HTC's HTCSync software: it simply refuse to connect to my HTC Hero. Further research shows that VMWare is able to do the same job. So I decided to try VMware-player. I don't want to create a new image just for it, so I would like to convert the VBox image (.vdi) to the VMware format (.vmdk). Since VBox can also use .vmdk, I can keep using VirtualBox for all the stuff it can handles. VMware has some behavior that just annoy the hell out of me.

Simple googling shows how to convert the VirtualBox HDD image to a VMware one:

$ qemu-image convert -O vmdk hddimage.vdi hddimage.vmdk
This, however, did not work for me. VMware cannot boot the converted image. Some blog mentioned that this is because dynamically allocated images are different and incompatible in the two formats. My image is pre-allocated, yet I still have problem. Does not matter. The solution is the same.

What one needs to do is to convert the image to RAW first using the versatile VBoxManager command that can do all kind of stuff with .vdi image:

$ VBoxManage internalcommands converttoraw hddimage.vdi hddimage.raw
Then convert it to .vmdk:
$ qemu-image convert -O vmdk hddimage.raw hddimage.vmdk
The new image can now be used in both VirtualBox and VMware-player.

A final note about VMware-player. When creating a new machine, the GUI does not allow user to use an existing image file. So in order to the converted image, one has to create an virtual machine with a new HDD image first---don't allocate space for it, of course. Then, one can add the image as a second HDD, delete the first one, and make the second one master (if you are using IDE).

No comments: