How to Convert a VHD File into VHDX

How do you convert a VHD file into a VHDX file?

VHDX is the new and default format of virtual hard disk (VDH) that is provided by Windows 8 Client Hyper-V and Windows Server 2012 Hyper-V. There are many reasons to favor VHDX files over VHD files, including:

  • scalability to 64 TB instead of 2040 GB
  • better performance by offering 4 K sector matching
  • protection against data corruption during power outages


New virtual machines are probably being created using this new format. But don’t worry, you can convert VHD to VHDX for existing virtual hard disks in use by virtual machines.
Please note that VHDX files cannot be used on versions of Hyper-V prior to Windows 8. Most people won’t want to go back to older versions once they’ve upgraded, but you can convert VHDX files back into VHD. Also note that the conversion is done offline. Maybe it would make sense to use Live Storage Migration to move the virtual machine to some very fast storage. This will minimize the time required to read the VHD and create the VHDX.
The two basic methods you can use to convert a VHD to VHDX file are Hyper-V Manager and PowerShell.

WARNING
Do not attempt to convert a VHD to a VHDX if any of the following are true:
  • You have created a snapshot of the virtual machine
  • You are replicating the VHD using Hyper-V Replica
  • The VHD is the parent to one or more differential virtual hard disks

Using Hyper-V Manager to Convert VHD to VHDX

You can find the Edit Disk link in Hyper-V Manager under Actions. This launches the Edit Virtual Hard Disk Wizard. Browse and select the VHD file in question. The Choose Action screen offers you possible actions that you can do to edit this disk. The Convert action will create a new VHDX file using the selected VHD file as a source.
VHD to VHDX
Next you will select the format of virtual hard disk you want, so go ahead and choose the VHDX option. This wizard will allow you to create the VHDX file as either a dynamically expanding or fixed-size VHDX file. The last step is to select where the new VHDX will be created and what it will be called.

Using PowerShell to Convert VHD to VHDX

You can dispense with the time-consuming wizard by using PowerShell. This will be extremely useful if you need to use a script to automate lots of VHD conversions across many virtual machines. The following snippet will convert a VHD to a VHDX:
Convert-VHD –Path d:VM01Disk0.vhd –DestinationPath d:VM01Disk0.vhdx

We’re Not Finished Yet!

The above instructions do not finish the job.  The next essential set of steps are:

  1. Open the settings of the virtual machine.
  2. Replace the VHD with the VHDX.
  3. Start and test the virtual machine.
  4. Delete the VHD file.

There is one more step that you might consider: When you create a new VHDX file (not converted) it has a physical sector size of 4 K. A converted VHDX file has a physical sector size of 512 Bytes. You can change the physical sector size of a converted VHDX by running this piece of PowerShell before you power up the virtual machine:
set-vhd d:VM01Disk0.vhdx -PhysicalSectorSizeBytes 4096
Now you have a virtual machine that is using the best kind of virtual machine storage, the VHDX format virtual hard disk.

FAQs

Can I convert VHD to VHDX while the virtual machine is running?

No, you cannot convert VHD to VHDX while the virtual machine is running. The conversion process requires the VM to be powered off to ensure data integrity and successful conversion of the virtual disk format.

What happens to my checkpoints when I convert VHD to VHDX?

When you attempt to convert VHD to VHDX, you must first remove all checkpoints (formerly known as snapshots) as the conversion process doesn’t support virtual disks with existing checkpoint hierarchies.

Is there a size limitation when converting from VHD to VHDX format?

While converting VHD to VHDX, ensure your source VHD is not larger than 2040GB (VHD limit). After conversion, your VHDX can be expanded up to 64TB, which is one of the main benefits of converting to VHDX format.

Will converting VHD to VHDX affect my virtual machine’s performance?

Converting VHD to VHDX typically improves performance due to enhanced features like improved metadata structure and built-in corruption protection. You may notice better I/O performance, especially with larger disk sizes.

Can I batch convert multiple VHD to VHDX files simultaneously?

Yes, you can create PowerShell scripts to convert multiple VHD to VHDX files in batches. However, ensure you have sufficient storage space as the conversion process creates new files rather than modifying existing ones.