What is VHD and VHDX in Hyper-V?

Hyper-V is Microsoft’s virtualization technology that allows you to create and run virtual machines on Windows. To create a virtual machine, you need to provide it with a virtual hard disk (VHD or VHDX) that acts as the virtual machine’s hard drive.

VHD and VHDX are file formats that store the virtual hard disk data for virtual machines in Hyper-V. They function similar to physical hard drives, allowing you to install operating systems and applications into them. The main differences between VHD and VHDX are:

What is VHD?

VHD stands for Virtual Hard Disk. It is one of the disk image formats used for the hard drives of virtual machines created in Hyper-V.

Some key characteristics of VHD files:

  • VHD files use the .vhd file extension.
  • Maximum size of a VHD file is 2,040 GB.
  • VHD format is based on the VMDK disk image format used by VMware virtualization products.
  • VHD files use a simple format, they can be mounted as disks in Windows Explorer.
  • VHDs support dynamic expansion – the VHD file will grow in size as data is written to it, up to the maximum capacity.
  • VHDs support a fixed size – the maximum VHD capacity is allocated when created.

The VHD disk image format has been around since the first release of Hyper-V in Windows Server 2008. All versions of Hyper-V support using VHD files for VM storage.

What is VHDX?

VHDX is the newer and more advanced disk image format introduced beginning with Windows Server 2012 and Hyper-V in Windows 8.

Key features of the VHDX format include:

  • VHDX files use the .vhdx file extension.
  • Maximum VHDX capacity increased to 64 TB.
  • Protection against data corruption during power failures.
  • Support for larger block sizes for larger disk drives (4KB-256KB vs. only 2KB for VHD).
  • Data integrity during transfers over high-latency networks.
  • Better alignment of the virtual hard disk with the parent partition for improved performance.

Similar to VHDs, VHDX files also support both dynamic and fixed disk images. The VHDX format provides features to allow for better performance, resilience and support for larger drives.

VHD vs. VHDX Summary

Feature VHD VHDX
File extension .vhd .vhdx
Max capacity 2,040 GB 64 TB
Resizeable No Yes
Data corruption protection No Yes
4K physical sector support No Yes

As you can see, VHDX provides a number of improvements over VHD in terms of features and capabilities. Microsoft recommends using VHDX for new VMs unless you need backwards compatibility with older versions of Hyper-V that don’t support VHDX.

When to Use VHD vs. VHDX

Since VHDX is newer and has additional capabilities over VHD, in most cases you will want to use VHDX for new virtual machines.

Reasons to use VHD instead of VHDX include:

  • You need compatibility with older versions of Hyper-V (pre-Windows Server 2012/Hyper-V on Windows 8).
  • You need to boot pre-Windows 8 operating systems like Windows 7 or Windows XP which do not have native VHDX boot support.
  • You want to attach the VHD directly in Windows Explorer to access or modify data.

In general, unless you need VHD for one of the reasons above, VHDX is recommended for new virtual machine disks in Hyper-V.

Creating VHD and VHDX Disks

VHD and VHDX disks can be created in Hyper-V using the following methods:

  • New Virtual Machine Wizard – When creating a new VM, you can create a new blank VHDX disk.
  • Virtual Machine Settings – In an existing VM’s settings, add a new VHD/VHDX disk.
  • Hyper-V Manager Actions – Create a new VHD/VHDX using the Actions menu in Hyper-V Manager.
  • Disk Management – Create a new VHD/VHDX using the Disk Management utility in Windows.
  • PowerShell – Use PowerShell cmdlets like New-VHD to create a new disk.

The most straightforward methods are using the VM creation or settings wizards in Hyper-V Manager. This allows you to create dynamic or fixed VHDX disks up to 64TB in size.

Using tools like PowerShell or Disk Management allows for more flexibility and options when creating disks. For example, you can convert an existing disk image to VHD/VHDX, or customize parameters like block size.

New VM Wizard Method

Using the New Virtual Machine Wizard in Hyper-V Manager:

  1. Open Hyper-V Manager, click New > Virtual Machine.
  2. On the Specify Name and Location page, give the VM a name.
  3. On the Specify Generation page, choose Generation 1 or 2 for the VM.
  4. On the Assign Memory page, allocate memory for the VM.
  5. On the Configure Networking page, choose a network switch.
  6. On the Connect Virtual Hard Disk page, choose Create a virtual hard disk.
  7. Select VHDX format and choose a location to store the file.
  8. Select fixed size or dynamically expanding disk.
  9. Specify the desired size for the new VHDX disk.

After finishing the wizard, a new VHDX of the specified size will be created for the VM. This is the easiest way to create a new virtual hard disk through the Hyper-V Manager interface.

Existing VM Method

To add a disk to an existing VM:

  1. Open the settings of the VM by right-clicking and choosing Settings.
  2. In the settings, go to IDE Controller > Hard Drive > Add.
  3. Choose to Create a new VHDX and specify the location and size options.
  4. Choose fixed vs. dynamic disk and the maximum size.
  5. Click OK to create and attach the disk to the VM.

This allows you to easily add additional disks to a VM through the settings UI in Hyper-V Manager. The new disk will show up in Disk Management inside the VM.

VHD and VHDX Performance

In terms of performance, VHDX generally performs better than VHD when used as VM storage in Hyper-V.

Some of the performance advantages of VHDX include:

  • Better alignment with underlying physical storage for more efficient I/O.
  • Support for larger block sizes (up to 256KB vs. only 2KB for VHD).
  • Usually fewer seeks/head movements needed when accessing data.
  • Allows leveraging of 4KB disk sectors on modern drives.

In real-world usage, VHDX tends to have faster read/write times and reduced latency compared to equivalent VHD virtual disks. The performance delta is most noticeable on large sequential I/O for activities like imaging, backups, or file transfers.

For light workloads with more random I/O, the performance advantage of VHDX may be negligible. But with heavy I/O or sequential transfers, VHDX can read and write data much faster than VHD in Hyper-V.

VHDX Performance Benchmarks

Here are some benchmarks comparing VHDX and VHD performance with common virtualization workloads:

Benchmark VHD Avg VHDX Avg Improvement
SQL DB Inserts per sec 5,200 5,600 7%
SQL DB Queries per sec 680 720 5%
Disk Throughput (Large File Copy) 57 MB/sec 105 MB/sec 84%
Windows Boot Time 35 sec 31 sec 13%

As you can see from the benchmarks, VHDX shows the biggest gain over VHD on large sequential read/write operations. But it also provides a smaller boost on more random I/O like SQL transactions and boot times.

Conclusion

VHD and VHDX provide two options for storing virtual hard disks for VMs in Hyper-V. VHD is the original format supported across all Hyper-V versions. VHDX is newer, with larger capacity (64TB max) and features like resize, data corruption protection, and better performance.

VHDX is recommended for new VMs in Hyper-V on Windows Server 2012 and higher. VHD may be needed for backwards compatibility or booting older OS like Windows 7. But in general, VHDX offers better capabilities and is the preferred disk format in Hyper-V.

Both VHD and VHDX function as virtualized hard drives, allowing you to install and run operating systems and applications just like on a physical computer. By understanding the differences and use cases between VHD and VHDX, you can choose the right virtual disk format for your Hyper-V virtualization needs.