Updated: December 8, 2010
And vice versa. This is definitely something you may want to do if you happen to be a virtualization fan and you're running both VirtualBox and one of VMware products. The reasons for conversion could be many, including the need to preserve a license or a machine state, run it in different software for compatibility testing and who knows what other reasons virtualization geeks may have.
Anyhow, today, I'm going to show you two definite and one maybe ways of how you can convert your virtual hard disks in .vdi format, used by VirtualBox to .vmdk, used by VMware, and the other way around. Furthermore, you will also learn how to convert to other formats, should you fancy them, including VHD, RAW, and others. We will use tools like the VBoxManage command line utility and QEMU, and take a look at VMware Converter, which we've seen in action before. All combined, this tutorial will significantly enhance the flexibility and portability of our setup.
Conversion method 1: VBoxManage
We have used VBoxManage to clone VirtualBox disks. The method here is identical, except that we will be converting to a different disk format. Let's see how this is done.
VBoxManage clonehd source.vdi target.vmdk --format VMDK
Where source is your VirtualBox disk, target is your VMware disk and --format VMDK is the desired output format. Similarly, you can go the other way around, using VMDK as your source and VDI as your target. Make sure to specify the right disk format. VBoxManage clonehd function supports other formats as well.
Again, using an external disk for storing virtual machines can reduce the performance penalty due to massive I/O. You can read more about optimizing virtual machine usage in my virtualization tips guide.
Let it run.
Once the procedure is successfully completed, create a new virtual machine in a VMware product and use the new disk as your storage.
You have quite a bit of leeway. I have converted a VirtualBox machine that was installed on a different machine, running a quad-core Intel processor, and deployed the VMware disk on a machine equipped with a dual-core Intel processor one generation behind. VirtualBox Guest Addons were installed in the guest operating system. Moreover, I let the VMware machine use PAE extension, whereas I disabled this feature in VirtualBox. Furthermore, I changed the disk controller from IDE to SCSI in the VMware machine settings and it still worked fairly well, with only a minor inconvenience of installing new hardware drivers on the machine startup. So you have a large margin for error and can be flexible about your conversions.
As to which machines and software I used ...
The so-called source host was my newest HP Pavilion dv6-2130ej laptop with the i5 processor, running Ubuntu 10.04. The target host was my somewhat older but still new and powerful LG RD510 laptop, with the Core 2 Duo P7450 processor, also running Ubuntu 10.04 and equipped with both VirtualBox and the spectacular VMware Workstation.
P.S., on a side note, the Workstation installed flawlessly on Lucid Lynx, even more smoothly than it did on openSUSE 11.2. Compared to the fairly complex and difficult VMware Server setup on Ubuntu, this is an extremely impressive result.
The Workstation (and possibly other products) may ask you to convert the virtual machine to the latest version of the VMware series. You can accept this, but you should not if you intend to use it with older products.
Let us see what gives.
Notice the same serial number. Likewise, pay attention to the PAE featured used in the converted copy of the virtual machine.
Please note that if your virtual machines are running Windows, you will need to make sure you have enough licenses to run the several instances of the operating system in parallel. You are probably good for the few seconds of testing, but each virtual machine requires its own license. You may also need to reactive your installation.
Oh, yes, the other direction is fairly simple.
VBoxManage clonehd source.vmdk target.vdi --format VDI
And that's it.
Conversion method 2: QEMU
QEMU is an old friend, too. We've seen in my very first article on virtualization, when I was still young and naive. Strike that, I was never young. We have also used QEMU to convert VMDK disks to RAW format, so we could use them with Amazon EC2 machines. The concept is exactly the same here. And it works both ways.
VDI to VMDK
It's extremely simple.
qemu-img convert something.vdi -O vmdk something.vmdk
VMDK to VDI
You have two ways to do this. Use a one-step qemu-img-vdi tool or go about using classic qemu-img, which will require an intermediate conversion to raw format.
Pretty much like all other conversions we've seen before:
qemu-img-vdi convert something.vmdk -O vdi something.vdi
Now, using qemu-img, you have two steps, first convert to RAW format, then use VBoxManage to convert to VDI. Older versions of VirtualBox used the tool called vditool, so you may find online resources that reference this utility.
Step 1: Convert VMDK to RAW (you don't need any file extension, btw)
qemu-img convert something.vmdk something.raw
Step 2: Convert RAW to VDI
VBoxManage convertdd something.raw something.vdi
Note: If you're using sparse disks, as we've seen in other tutorials, the raw file will them inflated to their intended max. size. A 20GB disk, even though if only 2.4GB are used, will become a 20GB byte-by-byte file on your hard disk.
That would be all. Next, please!
Conversion method 3 (maybe): VMware Converter
To the best of my knowledge, and I've already stated in the past, it does not seem that VMware Converter supports VirtualBox. Therefore, using VMware Converter may or may not work.
Now, you can try a different method. Export your VirtualBox machine as an appliance, which will save it in the .ovf format, including a ready VMDK disk. Then, convert the appliance using VMware Converter. There's no guarantee, though. I have read a few forum threads here and there where various users claimed to have done it successfully, so it indeed may be possible.
I have not managed this yet, so keep this in mind!
Another options is to use other tools to convert to VMDK, then use VMware Converter for additional conversions, including ESXi disks. Therefore, even if you cannot use the Converter directly, you can later benefit by using it.
Although you can be pretty flexible with your conversions, you should take into account that VMware and VirtualBox support things a little differently. So it is possible that some conversion may fail if you have special stuff enabled, like multi-processors, video acceleration and other cool things.
Therefore, if your conversions are not successful, consider doing the following:
- If your disks are split into multiple files, merge them into one.
- Disable any video acceleration or special features.
- Delete snapshots.
- Uninstall VMware Tools and/or Guest Additions.
- Try to match the virtual machine settings between the source and destination.
This is more important for Windows than Linux. Once again, I must remind you that you could have licensing issues if you're using proprietary software. Make sure that you do not invalidate your products by the virtual machine migration.
For a whole library full of tutorials, guides, howtos, tips and tricks on virtualization, feel free to click on any of the links below, preferably all.
There you go, another fine, complete tutorial baked. Today, you have learned another useful lesson, which gives you yet more freedom and flexibility when working with virtualization products. You can now convert your virtual machines back and forth between products and migrate them between machines as you see fit. You have no less than two proven methods and maybe a third to let you do the conversions. Best yet, you are not limited to just VDI and VMDK formats. I hope you liked it, enjoy!
P.S. Teaser image at the top of the page taken from Wikipedia, in public domain.