If you are running virtual machines on both VMware ESXi/Workstation and Microsoft Hyper-V, in some cases you may need to convert a VMware virtual machine to Hyper-V format. You can use different V2V migration tools for this. However, it is much faster to simply convert the VMware virtual machine VMDK file to the VHDX format. In this article, we’ll look at several ways to convert VMDK to VHDX.
Convert VMDK to VHDX with StartWind Converter
A third-party StartWind Converter utility allows you to convert VMs from VMware ESXi to Hyper-V.
Using the free StarWind V2V Converter tool, you can convert between the following virtual hard drive formats:
- .vmdk (VMware);
- .vhd and .vhdx (Hyper-V);
- .img.
Download the StartWind Converter utility (free registration required) and install the tool on your computer by running the startwind.exe file.
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. To do this, select the Remote VMware ESXi Server option.
You can also convert a local VMDK file (for example, a file of a VMware Workstation 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).
Note. Check our tutorial on how to configure autostart of VM on VMware ESXi.
Specify the target file.
Now you can attach the resulting VHDX disk to the Hyper-V virtual machine.
How to Convert VMDK to VHDX Disk using PowerShell?
You can use a special 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.
Open a PowerShell console as an administrator and import the MVMC module into your 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
After executing the command, the shareddisk01.vhdx file will appear in the target directory. You can create a new Hyper-V virtual machine from it or add it to an existing VM.
Note. Learn how to fix Hyper-V error: Virtual Machine could not be started because the Hypervisor is not running.
In our case, converting a 33GB VMware VMDK to VHDX took about an hour.
In some cases, when converting a VMDK disk using ConvertTo-MvmcVirtualHardDisk, an error may appear:
ConvertTo-MvmcVirtualHardDisk : The entry 0000000-0000-0000-0000-00000000 is not a supported disk database entry for the descriptor.
The problem is that there was an entry in the VMDK file descriptor that Microsoft Converter could not recognize. To fix the error, you need to remove unrecognized entries from the disk image descriptor.
To do this, download the dsfok tool (https://web.archive.org/web/20190910101150/http://members.ozemail.com.au/%7Enulifetv/freezip/freeware/dsfok.zip).
Then extract the VMDK file descriptor with the command:
dsfo.exe "C:\SharedVMDK\shareddisk01.vmdk" 512 1024 "C:\SharedVMDK\ shareddisk01_descriptor.txt"
Open the shareddisk01_descriptor.txt file with Notepad++ and look for the lines that contain the entry listed in the ConvertTo-MvmcVirtualHardDisk error. In our example, we need to find lines with the entry 0000000-0000-0000-0000-00000000.
Referer. Check our article about RVTools.
Comment out the lines with this value by adding a # sign at the beginning of the line. In this example, we commented out the lines:
# ddb.uuid.parent = "0000000-0000-0000-0000-00000000" # ddb.uuid.parentmodification = "0000000-0000-0000-0000-00000000"
Apply the new descriptor to the VMDK file:
dsfi.exe "C:\SharedVMDK\shareddisk01.vmdk" 512 1024 "C:\SharedVMDK\ shareddisk01_descriptor.txt"
Try running the ConvertTo-MvmcVirtualHardDisk command again. If the error The entry xxx is not a supported disk database entry for the descriptor appears again, you need to extract the descriptor again and comment out the lines with the problematic entries. Repeat the steps several times until ConvertTo-MvmcVirtualHardDisk completes the VMDK to VHDX conversion without errors.
Use Qemu-img to Convert Between VMDK and VHDX Disk Image
In Linux, you can use the qemu-img tool to convert disk images between QCOW2 (KVM, Xen), RAW, VMDK (VMware), VHD/VHDX (Hyper-V), VDI (VirtualBox) formats.
Use the following command to convert a disk image from VMDK to VHDX:
$ qemu-img convert -O vhdx /data/sourceimg.vmdk /data/outputimg.vhdx
You can download qemu-img port for Windows/Windows Server x64 here.
In order to convert a VMDK disk image in Windows, run the command:
qemu-img.exe convert source.vmdk -O vhdx -o subformat=dynamic output.vhdx
To get disk image information:
qemu-img.exe info output.vhdx
Connect Converted 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 on the Assign memory screen;
- At the Connect Virtual Hard Disk step, select the Use and existing virtual hard disk item and locate the VHDX file that you received in the previous steps;
- After the VM has been created, power it on.
VMware and Microsoft use different VM integration tools to give the best VM and user experience. VMware uses VMware tools and Microsoft > Hyper-V Integration Services. You need to remove VMtools from the VM and install Hyper-V integration services.
Related. Learn how to share a disk between VMs on VMWare ESXi.
Now you need to uninstall VMware Tools and device drivers in the guest operating system:
- On Windows, select Programs > Uninstall a program > select VMware Tool > Remove. You can also use the PowerShell script to force remove the VMware Tools, Program Files, and Windows Services (https://gist.github.com/broestls/f872872a00acee2fca02017160840624_)
- On Linux, use a Perl script to uninstall VMTools:
/usr/bin/vmware-uninstall-tools.pl
Now install Hyper-V Integration Services in the guest OS:
Windows:
- Download Windows Update CAB file with Hyper-V integration components (KB 3063109 – https://support.microsoft.com/en-us/kb/3063109)
- Then install the CAB file using PowerShell:
$HyperVCab="C:\Downloads\windows6.2-hypervintegrationservices-x86.cab" Add-WindowsPackage -Online -PackagePath $HyperVCab
Installing Hyper-V LIS (Linux Integration Services) on Ubuntu:
- First add hv_modules modules to initramfs-tools:
# echo 'hv_vmbus' >> /etc/initramfs-tools/modules # echo 'hv_storvsc' >> /etc/initramfs-tools/modules # echo 'hv_blkvsc' >> /etc/initramfs-tools/modules # echo 'hv_netvsc' >> /etc/initramfs-tools/modules
- Then install the Hyper-V integration components using your package manager:
# apt -y install linux-virtual linux-cloud-tools-virtual linux-tools-virtual # update-initramfs –u
2 comments
Nice post but why should one prefer Hyper-V to vSphere?
Licensing costs and Maybe you only have 1 or 2 vms.