In an environment where different versions of the hypervisor are used, it is often necessary to convert virtual machine files from one format to another. In this article, we will look at how to convert a VMware virtual machine’s VMDK file to Hyper-V (VHDX) format.
Table of Contents
What are VMDK and VHD/VHDX Virtual Disk Files?
The VMDK format (abbreviation for Virtual Machine Disk) is used to store virtual hard disk images in the VMware ESXi/Workstation/Player/Fusion environment. A VMware virtual disk consists of one or more (rare) files with the *.vmdk. extension.
The Microsoft Hyper-V hypervisor uses its own Virtual Hard Drive (VHD) format. Windows Server 2012 Hyper-V introduced a new and improved VHD format called VHDX (Virtual Hard Disk v2). VHDXs support larger file sizes, disc resizing, etc. The VHDX format the most commonly used file format in Hyper-V now.
In general, virtual disk files from different hypervisors are not directly compatible with each other. In order to run a virtual machine created in the VMware environment on a Hyper-V host, you need to convert the virtual disc file from VMDK to VHDX format.
There are no built-in tools for converting files from VMDK to VHDX in either Hyper-V or VMware. Therefore, you must use V2V migration tools (such as System Center Virtual Machine Manager, VMM), or third-party tools to convert the virtual image files.
Before you begin:
- If the source virtual machine is stored in OVF format in VMware datastore, first export the OVF template using the vSphere Client. Then you can download *.OVF file and extract the *.VMDK disk image file from it using 7-Zip;
- It is recommended that you remove VMWare Tools from a virtual machine before proceeding;
- Shut down the VM before conversion;
- Make sure that you have enough free space on your hard disk to save new VHDX file.
Convert VMDK to VHDX with StartWind V2V Converter
You can use the free third-party graphical utility StarWind V2V Converter to convert between different types of virtual disks. Visit the official website to download the tool (to receive the download link, a free registration is required). Run the startwind.exe file to install the tool on your computer.
StartWind Converter allows you to remotely connect to VMware ESXi and perform an online conversion of a virtual machine and immediately import it to a Hyper-V server.
Select the Remote VMware ESXi Server or vCenter option.
You can also convert a local VMDK file (for example, a file of a VMware Workstation/Player virtual machine) to VHDX format. To do this, select Local file > specify the source VMDK file and select destination image format VHD/VHDX (Microsoft Virtual Hard Drive).
Specify the destination file path.
Now you can attach the resulting VHDX disk to the Hyper-V virtual machine.
If you need to convert between VMDK and VHDX formats on a regular basis, it is better to do it with the command line tools.
How to Convert VMDK to VHDX Disk using PowerShell
You can use the MVMC PowerShell module to convert VMware virtual disks (vmdk) to Hyper-V format (vhdx). Download and install the Microsoft Virtual Machine Converter module on your computer.
Import the MVMC module into your elevated PowerShell session:
Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1'
To convert your VMDK file to VHDX format, run the command:
ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "C:\SharedVMDK\shareddisk01.vmdk" -VhdType DynamicHardDisk -VhdFormat vhdx -destination C:\VHD
The shareddisk01.vhdx file will appear in the destination directory. You can use it to create a new Hyper-V virtual machine or add it to an existing VM
In our case, converting a 33GB VMware VMDK to VHDX took about an hour.
Converting VMDK Image Files with Qemu-img
You can use the qemu-img tool to convert virtual disk images between different formats. The utility is available for both Linux ($ sudo apt install qemu-utils) and Windows platforms (https://cloudbase.it/qemu-img-windows/).
You can list virtual disc image formats supported by qemu-img:
$ qemu-img -h | grep "Supported formats"
Supported formats: blkdebug blklogwrites blkverify bochs cloop compress copy-before-write copy-on-read dmg file ftp ftps gluster host_cdrom host_device http https iscsi iser luks nbd null-aio null-co nvme parallels preallocate qcow qcow2 qed quorum raw rbd replication ssh throttle vdi vhdx vmdk vpc vvfat
Use the following command to convert a disk image from VMDK to VHDX on Linux:
$ qemu-img convert -O vhdx /data/sourceimg.vmdk /data/outputimg.vhdx
The command to convert a VMDK file in Windows looks like this:
qemu-img.exe convert source.vmdk -O vhdx -o subformat=dynamic output.vhdx
To get disk image information:
qemu-img.exe info output.vhdx
Attach an Existing VHDX Disk to Hyper-V VM
Finally, you can attach the converted VHDX disk to the Hyper-V virtual machine.
- Open the Hyper-V Manager console;
- Select New > Virtual Machine;
- Specify a name and location for the virtual machine files;
- Select VM generation (Generation 2 is recommended);
- Specify the RAM size for the VM;
- Select Use and existing virtual hard disk item and locate the VHDX file that you received in the previous steps;
- Power on your VM.
4 comments
Nice post but why should one prefer Hyper-V to vSphere?
Licensing costs and Maybe you only have 1 or 2 vms.
My VMWare Workstation image has many snapshot and I want the last one which seems to have 026 as a suffix. I created a Full Clone from this image with just one snapshot. So, in my local VM Workstation directory for my newly created Full clone, there are two different vmdk files with the suffix 026. They are:
RAWinSvr2019-cl1-000001-s026.vmdk
&
RAWinSvr2019-cl1-s026.VMDK
where the one that I launch for the VMWare Workstation to run is named:
RAWinSvr2019-cl1.VMDK
I want to use StarWind to convert local vmdk to a local VHDX file using the image of my last or newest snapshot in VMWare. Which VMDK do I have StarWind use?
Create a full clone VM based the snapshot you want. Then convert the new vmdk file to vxhd.