I recently had to move a Windows virtual machine from VirtualBox to VMware. The disk image was in VDI format, but VMware expects VMDK. I didn't want to recreate the VM from scratch, so I needed to convert the disk image.

It turns out this is straightforward with qemu-img, a CLI tool that comes with QEMU. Here’s the command:

qemu-img convert -p Windows.vdi -O vmdk Windows.vmdk

Let me walk you through what each part does.

qemu-img is the main tool here. It's typically installed with QEMU, which is available on macOS, Linux, and Windows. You can check out the official QEMU website to know how to install it: https://www.qemu.org/download/

The convert argument tells QEMU to transform the input disk image into a different format. It reads the source disk and writes the converted version to the destination.

The -p flag causes QEMU to display progress during the conversion. This is useful because converting a large disk image can take several minutes, and it's nice to see that something is actually happening.

Windows.vdi is the input file, the VirtualBox disk image you want to convert. Ensure you use the correct filename and path if it is located in a different directory.

The -O vmdk part specifies the output format. QEMU supports many formats, but here we're using VMDK, which is the format VMware uses.

Windows.vmdk is the name of the output file.

One thing to keep in mind: if you're using a recent version of VMware, you might want to add the -o compat6 option to create a VMDK in version 6 format. That would look like this:

qemu-img convert -p Windows.vdi -O vmdk -o compat6 Windows.vmdk

Once QEMU has successfully converted the VM disk, you can attach it to a VMWare VM to boot into it.