Converting Virtual Machine Images

If you have used VMWare and decide to change for another VM manager (or vice versa), you do not have install those guest VMs a second time. You can convert images to another format.

In this situation qemu is a handy tool even if you would not use it to run those virtual machines. Qemu has a tool which can convert VM formats to another. Even if you are not going to use qemu to run any virtual machines (it can be quite a pain to get it working), you can install it with


sudo apt-get install qemu

Now you are able to use gemu-img to convert virtual machine images from one format to another.

Conversion from VMware (vmdk) to VirtualBox (vdi)

When converting VMWare files you should be aware that they may appear in two variations. First case is simple, since you have only one .vmdk file which contains whole disk image. Second case is more complicated since the disk image is split into several files (which are usually 2GB of size).

A. One .vmdk file
No extra procedures are necessary. Skip the next step B.

B. Several .vmdk files
You have combine (reorganize) these files into one single file. This can be done with vmware-vdiskmanager, which you can find in the directory where all VMWare binaries. vmware-diskmanager works without a working VMWare. You can take VMWare Server installation package and just copy vmware-diskmanager binary to same directory where your disk images exist. Lets assume that you have there files WinXP.vmdk, WinXP-flat.vmdk, WinXp-0001.vmdk etc. Then run


vmware-diskmanager -r WinXP.vmdk -t 2 WindowsXP.vmdk

Then you will have one big file named WindowsXP.vmdk which contains whole disk.

C. Convert .vmdk to .bin
Now we have only one .vmdk file. First we must convert it into .bin format with qemu. Lets continue with that WindowsXP disk image.


qemu-img convert WindowsXP.vmdk WindowsXP.bin

D. Convert .bin to .vdi
This is done from command line with

<code
VBoxManage convertfromraw WindowsXP.bin WindowsXP.vdi

Afterwards you can delete WindowsXP.bin since you probabli won’t need it anymore. Now you can create new VirtualBox machine and use existing disk image WindowsXP.vdi for it.

VMWare image (one file)
VMWARE image (several files)

Leave a comment

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 105 other subscribers