How to Convert VHD to VMDK: A Step-By-Step Guide

VMware vSphere and Microsoft Hyper-V are two of the most popular virtualization platforms. Each solution uses different virtual disk file formats for virtual machines. This means you need to convert virtual disk files when moving VMs between VMware and Hyper-V. For example, you may need to migrate VMs between hypervisors for testing. In other cases, you may need to change the format if you’ve chosen the wrong one when creating the VM.

Hyper-V uses VHD and VHDX for VMs, while VMware uses VMDK. Read this post to learn how to migrate VMs from Hyper-V to a VMware environment by converting a VHD file into VMDK.

NAKIVO for VMware vSphere Backup

NAKIVO for VMware vSphere Backup

Complete data protection for VMware vSphere VMs and instant recovery options. Secure backup targets onsite, offsite and in the cloud. Anti-ransomware features.

Virtual Disk Formats

VHD refers to the disk image format that was introduced as the virtual disk format of virtual machines for Connectix Virtual PC. Later, Microsoft bought Virtual PC and continued development of this virtualization product. Then, Microsoft presented Hyper-V as a substitution of Microsoft Virtual PC. The main VHD features are:

  • The maximum supported size of VHD files is 2 TB (2^32*512 bytes) where 32 bit is quantity and 512 bytes is the sector size.
  • The VHD format of virtual disks is also supported by VirtualBox and is still used in the Microsoft Azure Cloud.
  • Generation 1 Hyper-V VMs can use only virtual disks of the VHD format.

VHDX is the new version of the virtual disk format provided by Microsoft, which is the successor of the VHD format. The VHDX format has the wide area of usage – virtual disks of Hyper-V virtual machines and Microsoft cluster shared volumes. VHDX is a semi-open file format and you can download this file format specification from Microsoft’s web site and create your own applications that work with VHDX files. The main VHDX features are:

  • Maximum disk capacity is 64 TB comparing to the 2-TB limit for VHD.
  • Supports 4-KB sectors
  • Is better protected against failures caused by power loss, comparing to VHD disks

Generation 2 VMs support using both VHDX and VHD virtual disks. However, Azure VMs can use only virtual disks of the VHD format. VHDX virtual disks can be created in the Disk Management window in Windows 10 and Windows Server 2016. VHDX images can be also mounted (attached) as a disk drive, displayed in Windows Explorer (My Computer) in the latest Windows versions thanks to the built-in VHDX driver.

VMDK is an open format of virtual disk images that is used by VMware hypervisors, VirtualBox, QEMU etc., and is not supported by Hyper-V. VMDK image files can be regarded as containers to store data similarly as on physical hard disks, and have a high compatibility with diverse virtualization software. The maximum size of the VMDK virtual disk has been increased from 2 TB to 62 TB. VMDK virtual disks can be divided into the following types and variations: monolithic, split, sparse, flat, as well as thin and thick provisioned. Delta VMDK disks are created when taking VM snapshots. VMDK files can be mapped (mounted) to the specified mount point on your host machine if VMware Workstation is installed. A high level of reliability is provided. 4-KB native sectors are supported for VMDK virtual disks, used by the newest versions of VMware products with VMF S6.

Check the VHD Content Before You Convert VHD to VMDK

This is an optional step that allows you to ensure that a source VHD or VHDX virtual disk is healthy, and view contained files. This approach prevents you from confusing and wasting time on converting the wrong virtual disk. If you want only to extract files from VHD images, this section is what you need. VHD files can be mounted to a directory on Linux and can be mapped to a specified drive letter in Windows.

How to open VHDX in Linux

In Linux VHD and VHDX, files can be mounted to a specified directory (mount point) in the console by using libguestfs tools. Thus, you can view the contents of VHD and VHDX files in Linux before you start to convert VHD to VMDK. Let’s explore how to view the content of VHD and VHDX virtual disk images in Linux.

Install the needed package:

sudo apt-get install libguestfs-tools

Create the directory to which you want to mount the VHD or VHDX images, for example, /mnt/vhd/:

sudo mkdir /mnt/vhd/

Run the command to mount a VHD disk image to the specified directory. We are in the directory where the required VHD file is located, and run the command as root:

guestmount --add test-disk.vhd --ro /mnt/vhd/ -m /dev/sda1

Where:

-add – opens a virtual disk.

--ro – a virtual disk is mounted in read-only mode.

/mnt/vhd/ is the path to the VHD file you want to mount.

-m /dev/sda1/ is the name of partition existing on the VHD virtual disk. There is one NTFS partition on the VHD virtual disk used in this example.

You can see all available commands by running guestmount --help

Note: If you run the command in another directory, specify the full path to your VHD file, for example:
guestmount --add /media/user1/data/test-disk.vhd --ro /mnt/vhd/ -m /dev/sda1

Check the contents of the mounted VHD image:

ls -al /mnt/vhd/

Check the virtual disk content before you convert VHD to VMDK

To unmount the virtual disk, use the command:

guestunmount /mnt/vhd/

Similarly, you can mount VHDX files to the /mnt/vhd/ directory created previously, and copy content from the mounted virtual disk:

guestmount --add /media/user1/data/WinServer2016.vhdx --ro /mnt/vhd -m /dev/sda2

Where: /dev/sda2 is used because /dev/sda1/ is the service partition created by Windows installer by default.

You can see the contents of the Windows system partition (disk C:) of the VHDX virtual disk in the Linux console (see the screenshot below).

How to convert VHD to VMDK – checking the VHDX content

How to open VHD in Windows

Open the Computer Management window (right click My Computer and select Manage in the context menu).

How to mount VHD in Windows – opening Computer Management

In the Computer Management window, select Disk Management, then click Action > Attach VHD.

How to attach a VHD image in Windows

In the pop-up window, define the path to your VHD or VHDX file. Tick the Read-only checkbox if you don’t want to write data to the virtual disk. This option also protects data stored on the virtual disk against accidental corruption.

Attaching a VHD disk in Windows

The disk is now mounted and displayed in the Disk Management window and in Windows Explorer (the drive X: in this case).

Note: Windows can determine only partitions with supported file systems: NTFS, FAT32, exFAT, ReFS. If your virtual disk contains Linux partitions with ext3, ext4, and other file systems, you will not be able to view the content of VHD or VHDX files mounted to your Windows system without third-party tools.

In order to unmount a VHD or VHDX virtual disk from your Windows system, open Windows Explorer, right click the drive letter assigned to your virtual disk, and in the context menu, click Eject.

Eject the VHD disk in Windows when the disk is not in use

Now, when you have checked the content of the VHD (VHDX) virtual disk and you are ensured that this is the disk you need, you can start to convert VHD to VMDK. There are two highly affordable methods to convert VHD to VMDK – using qemu-img and using VBoxManage. Both considered solutions are free to use, and are explained below.

How to Convert VHD to VMDK with qemu-img

QEMU is an open source machine emulation and virtualization platform. Qemu-img is a utility of the QEMU software kit that can be used to convert virtual disks from one format to another. Qemu-img can be used to convert VHD to VMDK, and using this utility is the first method to convert Hyper-V to VMware virtual disks that we will discuss in this blog. Qemu-img can be run in both Windows and Linux operating systems.

Using qemu-img in Linux

Ubuntu Linux is used in this example for running qemu-img.

First, install qemu-img from the online software repositories:

sudo apt-get install qemu-utils

Go to the directory where virtual disk images are stored (in this example VHD and VHDX virtual disk files are stored in /media/user1/data/):

cd /media/user1/data/

Check the VHDX file

Get the root privileges (with  the sudo su command) and view the VHD image information:

qemu-img info test-disk.vhd

How to convert VHD to VMDK with qemu-img – checking the VHD info

Similarly, you can check the information about the VHDX virtual disk:

qemu-img info /media/user1/data/WinServer2016.vhdx

Check the VHDX info before you convert VHDX to VMDK with qemu-img

Convert VHD to VMDK in Linux

In order to convert VHD to VMDK with qemu-img in Linux, run the command as root:

qemu-img convert /media/user1/data/WinServer2016.vhdx -O vmdk /media/user1/data/WinServer2016qemu.vmdk -p

Where:

-O – define the output file format

-p – show the progress bar

Wait until the conversion process is finished.

Using qemu-img in Windows

Download qemu-img from the official web site (32-bit and 64-bit installers are available to download). In the current example, qemu-img-win-x64-2_3_0 is used. Extract files form the downloaded archive, for example, to C:\Programs\qemu-img\. Then launch the Windows command line (CMD) – Press Windows+R to open the “Run” box. Type “cmd” into the box and press Ctrl+Shift+Enter to run the command as an administrator.

Go to the qemu-img directory:

cd C:\Programs\qemu-img

Commands of qemu-img in Linux and Windows are identical.

Convert VHD to VMDK in Windows

Run CMD as administrator and go to the directory where qemu-img is installed.

View the virtual disk information:

qemu-img.exe info c:\Virtual\Hyper-V\test-disk.vhd

Convert the VHD disk image to the VMDK format:

qemu-img.exe convert -p c:\Virtual\Hyper-V\test-disk.vhd -O vmdk c:\Virtual\Hyper-V\test-disk.vmdk

Where:

-p – show progress

-O – the output file

Wait until the conversion process is finished.

How to convert VHD to VMDK – using qemu-img as VHD to VMDK converter

How to Convert VHD to VMDK with VBoxManage

VBoxManage is the command line interface (CLI) for managing the VirtualBox hypervisor and virtual machines. VBoxManage is the multiplatform tool that is installed when you install VirtualBox (as you recall, VirtualBox is a multiplatform virtualization solution). One of VBoxManage‘s most attractive features is its ability to convert multiple virtual disks formats. You can convert VHD to VMDK with VBoxManage.

If you use Windows as the host operating system, run CMD as Administrator and go to the installation directory of VirtualBox to run VBoxManage. In the current example, VirtualBox is installed in the default directory.

cd C:\Program Files\Oracle\VirtualBox

You can add the installation path of VirtualBox to the Path environment variable to avoid going to the VirtualBox installation directory manually each time when you want to run VBoxManage.

Run the command to convert Hyper-V VHD to VMware VMDK as following:

VBoxManage clonehd --format vmdk C:\virtual\Hyper-V\WinServer2016.vhdx С:\virtual\Hyper-V\WinServer2016vbox.vmdk

The syntax is understandable – you set the destination virtual disk format (vmdk) and define the source vhdx file and destination vmdk file names.

Wait until the conversion process is finished.

How to convert VHD to VMDK – using VBoxManage as a VHD to VMDK converter

If you use Linux on your machine where VirtualBox is installed, use the identical commands (but keep in mind the structure of Linux partitions and directories).

Creating a VMware VM by Using the Converted Virtual Disk

Converting VHD to VMDK allows you to convert Hyper-V to VMware virtual machines. You need to import converted virtual disk to your manually created VMware VMs to make the complete VM conversion. This approach can be used for VMs running on VMware Workstation and VMware ESXi. The remaining details of how to convert Hyper-V to VMware are explained in this section.

VMware Workstation

If you want to create a virtual machine using a virtual disk converted from the VHD (VHDX) format to the VMDK format in VMware Workstation, just create a new VM (or open an existing VM if you want to add a converted virtual disk as an additional virtual disk) and select that you wish to use an existing virtual disk.

For example, let’s create a new VM in VMware Workstation. Hit File > New virtual machine.

See a detailed explanation of how to create a new VMware Workstation VM in the blog post about VMware Home Lab. In this section of the today’s blog post, the emphasis is on steps needed for importing a converted VHD virtual disk to the VMware Workstation VM. Hence, you should pay special attention to the following steps:

Select “I will install an operating system later,” and choose the version of the guest OS (operating system) that was installed on the source Hyper-V VM whose virtual disk you have converted (Windows Server 2016 in this case). If you are using an older version of VMware Workstation, select Windows 10 as the guest OS version.

How to import VHD to VMware after conversion

The VM name is Win2016converted in our example. The files of the new VM are stored in C:\Virtual\Win2016converted.

Select “Use an existing virtual disk” at the Select a Disk step.

How to import VHD to VMware after conversion to the VMDK format

Specify a path to the existing VMDK file or browse the file. In this case, the path to the VMDK file is:

C:\Virtual\Hyper-V\WinServer2016qemu2.vmdk

How to import VHD to VMware Workstation after converting to VMDK

If the dialog window appears and suggests that you to convert an existing virtual disk to a newer format, the choice is up to you. You should convert a virtual disk to a newer format if you don’t plan to use this virtual disk for virtual machines of older VM versions (which have older virtual hardware).

Select BIOS as the firmware type in VM options if your source Hyper-V VM was configured to use BIOS. Otherwise, the VMware VM to which you have attached a virtual disk converted from the Hyper-V format to the VMware format will not boot. After a VM is created, you can check this setting by going to VM > Settings, selecting the Options tab > Advanced.

Selecting BIOS in the options of the destination VMware VM

Now your VM should boot correctly. After your guest OS is booted, install VMware Tools.

How to convert Hyper-V to VMware – the conversion has completed successfully

VMware ESXi

You can also convert VHD to VMDK and import a converted virtual disk to a VMware VM running on an ESXi host. However, the VMware virtual disk format for VMware Workstation and VMware ESXi is a different matter. A virtual disk of the VMware Workstation format has a disk descriptor that is built in the single VMDK file. A virtual disk of the ESXi format consists of two separate files – a data file (.vmdk) and a disk descriptor file (-flat.vmdk). In order to use a virtual disk that you have converted from the Hyper-V format with qemu-img or VBoxManage for a VM running on ESXi, you have to convert that virtual disk from the Workstation format to the ESXi format. Otherwise you will get the error: “Unsupported or invalid disk type 2”.

How to convert VHD to VMDK for ESXi – VMDK must be converted to the ESXi format

Let’s find out how to use a virtual disk converted from the VHD format for a VM running on ESXi.

Converting VMDK to the ESXi format

Upload the converted VMDK file to the datastore connected to an ESXi host. Use an SCP client, the web interface of VMware Host Client or VMware vSphere Client for uploading the converted virtual disk vmdk file to the ESXi datastore.

In our example, the WinServer2016qemu.vmdk file is uploaded to the SSD1 datastore that is attached to the ESXi host which IP address is 10.10.10.74.

How to import VHD to VMware ESXi – uploading the VMDK file after conversion

Make sure that SSH access is enabled on your ESXi host (Manage > Services > TSM-SSH).

SSH access is enabled on an ESXi host

Connect to your ESXi host via SSH by using an SSH client (for example, PuTTY) as root.

Go to the directory where the VMDK virtual disk file converted from the Hyper-V VHD format is stored (in this example, the vmdk file is stored in /vmfs/volumes/SSD1/converted/):

cd /vmfs/volumes/SSD1/converted/

Use vmkfstools to convert a virtual disk of the Workstation format to a virtual disk of the ESXi format. In our example, a thin provisioned virtual disk of the ESXi format is the destination virtual disk type.

vmkfstools -i WinServer2016qemu.vmdk WinServer2016thin.vmdk -d thin

How to convert VHD to VMDK – post conversion of the VMDK file to the ESXi format

As you can see on the screenshot, the post conversion of VMDK from the Workstation format to the ESXi format with vmkfstools has completed successfully and two new files have been created:

WinServer2016thin-flat.vmdk

WinServer2016thin.vmdk

How to convert VHD to VMDK – the virtual disk is converted to VMDK of the ESXi format

Importing a VMDK disk to a VM on ESXi

Open VMware Host Client (it is most optimal to use VMware vSphere Client if vCenter is deployed, but you can use VMware Host Client in almost all cases including a scenario with ESXi Free Edition if you decided to convert Hyper-V to VMware VMs). In the web interface of VMware Host Client, select Virtual Machines and hit Create/Register VM.

Creating a new VM to import VHD to VMware after converting a virtual disk

The new virtual machine wizard is opened.

1. Select creation type. Hit Create a new virtual machine. Click Next on each step to continue.

Creating a new VM on an ESXi host

2. Select a name and guest OS. Select the VM version, guest OS family and guest OS version. In this example, the VM name is Win2016converted. The VM is compatible with ESXi 6.5 or later, Windows is the guest OS family and the guest OS version is Microsoft Windows 2016 (64-bit).

How to convert Hyper-V to VMware – creating a new VM to import a converted virtual disk

3. Select storage. Select the datastore in which to store the VM files. The name of the datastore used in this example is SSD2.

Selecting a datastore to store VM files

4. Customize settings. This step is the most important in our case. Delete the virtual disk that was created by default with the new VM. Then, click Add hard disk > Existing hard disk.

Importing a virtual disk converted from VHD to VMDK to a VM on ESXi

In the datastore browser, select the virtual disk that you converted from VHD to VMDK and then converted VMDK from the VMware Workstation format to the VMware ESXi format (thin provisioned). As you may recall, your converted virtual disk consists of two files (.vmdk and -flat.vmdk) but in the datastore browser, only one vmdk file is displayed. Don’t worry—this is a feature of VMware Host Client. Both files copied to the ESXi datastore are present. You may check them in the ESXi console or by connecting via SSH. In the current example, you can see that the current size of the virtual disk is 9.11 GB, but the maximum provisioned size of this disk is 30 GB.

Selecting a converted virtual disk on a datastore

After adding the converted VMDK virtual disk, you can see the inactive field where the 9-GB size (the current size) of the 30-GB virtual disk is displayed. There’s no need to pay attention to the fact that the virtual disk type is displayed incorrectly on the screenshot below; as such, the virtual disk is imported as a thin disk, as intended.

How to convert VHD to VMDK – a converted virtual disk is attached to a VM on ESXi

5. Ready to complete. On this step, you can check your settings. If everything is correct, hit Finish to create a new VM.

Checking the new VM configuration summary

Now, you can power on the VM (right click the VM name and in the context menu select Power > Power On).

Convert Hyper-V to VMware – starting a VM that uses a converted virtual disk

The VM with the converted virtual disk has started properly, and network is functioning correctly. Now you can install VMware Tools on the guest OS.

How to convert Hyper-V to VMware – a VM that uses a converted disk is operating properly on ESXi

Conclusion

If you would like to convert Hyper-V to VMware on the level of virtual machines, you can convert VHD to VMDK and then attach a converted VMDK virtual disk to a new VMware VM. Qemu-img can be used as a VHD to VMDK converter and VBoxManage can be used as an alternative. Both solutions are free and multi-platform, allowing you to convert Hyper-V VHD to VMware VMDK on different operating systems. Be aware that if you want to use a virtual disk converted with qemu-img or VBoxManage for ESXi VMs, you should convert the VMDK virtual disk from the Workstation format to the ESXi format with vmkfstools in the ESXi command line.

If you want to use semi-automated or fully automated tools to convert the entire Hyper-V VM to the VMware VM, you can use free VMware vCenter Converter Standalone.

Regardless of the hypervisor you use, data protection is important. NAKIVO Backup & Replication provides a Cross-Platform Recovery feature, which allows you to convert VHD disks from VM backups to VMDK disks and restore Hyper-V VMs to VMware hypervisors.

1 Year of Free Data Protection: NAKIVO Backup & Replication

1 Year of Free Data Protection: NAKIVO Backup & Replication

Deploy in 2 minutes and protect virtual, cloud, physical and SaaS data. Backup, replication, instant recovery options.

People also read