What is a .vhdx file?

What is a VHDX File?

A VHDX file is a disk image saved in the Virtual Hard Disk version 2 (VHDX) format developed by Microsoft. It is used as a virtual hard disk file, allowing for the creation of virtual hard drives that can be attached to virtual machines and used like regular hard drives (https://filext.com/file-extension/VHDX).

The VHDX file format was designed by Microsoft as an upgrade to the older VHD format, which was used for virtual hard disks in Microsoft’s Hyper-V virtualization technology. VHDX improves upon VHD with features like the ability to store virtual hard disks larger than 2 TB and the use of 4K sectors for more efficient alignment with modern hard drives.

In summary, VHDX files allow virtual hard drives to be created and used in virtualized environments, providing efficient virtual storage for virtual machines. The VHDX file format is the successor to VHD, adding capabilities for larger drive sizes and improved performance (https://www.devx.com/terms/hyper-v-virtual-hard-disk/).

VHDX File Format Specifications

The VHDX file format was designed by Microsoft as an upgrade over the older VHD format. It offers several key improvements in terms of features and capabilities:

Maximum size – VHDX files can be as large as 64 TB, a significant increase over VHD’s limit of 2 TB. This allows modern, large virtual hard disks to be stored efficiently in a single file.

Block sizes – Data in VHDX files is organized into block sizes ranging from 4 KB to 256 KB, providing more flexibility than VHD’s fixed block size of 2 MB. Larger block sizes improve performance for sequential disk access.

Supported operating systems – VHDX was introduced with Windows Server 2012 and Windows 8. It is fully supported in Windows 10, Windows Server 2016, and later versions. The format is not compatible with older operating systems like Windows 7 or Server 2008 R2.

Overall, the VHDX specifications deliver critical storage capacity and performance improvements while maintaining compatibility with modern Windows environments. The larger maximum size and flexible block sizes make it an ideal virtual disk format compared to VHD.

Sources:
[MS-VHDX]: Virtual Hard Disk v2 (VHDX) File Format

Advantages of VHDX

The VHDX format offers several key advantages over the older VHD format:1

Larger storage capacity – VHDX supports virtual hard drives up to 64 TB in size, a massive increase compared to VHD’s limit of 2 TB. This enables VHDX to support even the largest applications and workloads.

Better performance – The VHDX format delivers faster read/write speeds, lower latencies, and improved alignment between the virtual hard disk and physical storage. This results in a noticeable performance boost for most applications.

Support for larger block sizes – VHDX supports block sizes up to 256 MB, compared to VHD’s limit of 2 MB. Larger block sizes enable more efficient storage allocation and access, especially for large files.

In summary, VHDX’s improved performance, capacity, and functionality make it far superior to VHD for most workloads. Its advantages have made it the preferred virtual disk format for Hyper-V and other major hypervisors.

Creating a VHDX File

There are a few different ways to create a new VHDX file in Windows:

Using Hyper-V Manager

The easiest way is to use the Hyper-V Manager included in Windows. Open the Hyper-V Manager and under the Actions menu on the right, click “New” and then “Hard Disk”. This will start the New Virtual Hard Disk Wizard. Specify a name, location, and size for the new VHDX file and click through the wizard to create it (Source).

Using Powershell

You can also create a new VHDX file using Powershell commands. The New-VHD cmdlet allows you to specify all the parameters needed to generate the VHDX file. For example:

New-VHD -Path C:\vdisks\mydisk.vhdx -SizeBytes 20GB -Dynamic

This will create a dynamic 20GB VHDX file at the specified path (Source).

Using Third Party Tools

There are also third party tools available that provide a GUI interface for creating new VHDX files. StarWind V2V Converter and Disk2vhd from Sysinternals are two options. These tools make it easy to specify all the settings and save the VHDX file without using Powershell or Hyper-V Manager.

Mounting and Using VHDX Files

Mounting a VHDX file allows you to access it like a physical disk drive in Windows. To mount a VHDX file:

1. Open Disk Management (diskmgmt.msc).

2. Click Action > Attach VHD. Browse to the location of your VHDX file.

3. Select the VHDX file and click OK. This will mount the VHDX file and assign it a drive letter.

By default, mounted VHDX drives are read/write accessible. You can view contents, modify files, copy data, etc. just like a regular drive. The VHDX behaves like a physical disk connected to the system.

To set a mounted VHDX as read-only, right-click the disk and select Properties. Under the General tab, check “Read-only” and click OK. This will prevent any changes to the VHDX contents.

When finished working with the mounted VHDX, right-click on its disk entry in Disk Management and select Detach VHD to unmount it. The VHDX will remain available in its file location but will no longer show as a mounted drive.

Migrating from VHD to VHDX

The VHDX file format is the newer and more advanced version of VHD. Microsoft recommends upgrading from VHD to VHDX for improved performance and features. There are a couple ways to migrate existing VMs from VHD to VHDX:

Converting VHD to VHDX:

  • Use the Convert-VHD Powershell cmdlet to convert VHD files to VHDX. This preserves all data and converts in place.
  • Alternatively, the Hyper-V Manager also provides an “Edit Disk” option to convert VHD to VHDX.

Upgrading existing VMs:

  • Create a new VHDX disk.
  • Copy the contents from the VHD to the new VHDX disk.
  • Update the VM settings to point to the new VHDX disk.
  • Delete the old VHD disk.

Overall, VHD to VHDX migration is quick and seamless. Microsoft provides handy tools like Hyper-V Manager and Powershell cmdlets to automate much of the process. Just be sure to validate proper functioning of the VM after migrating disks over to VHDX.

Sources:

https://learn.microsoft.com/en-us/troubleshoot/system-center/vmm/convert-between-vhd-vhdx-formats

https://www.bdrsuite.com/blog/how-to-convert-vhd-to-vhdx-using-hyper-v-manager-and-powershell/

Comparing VHDX and VHD

VHDX and VHD are both virtual hard drive file formats used in virtualization, but there are some key differences between the two formats.

Storage Capacity Differences

One of the biggest differences between VHDX and VHD is the maximum storage capacity. VHD files are limited to 2TB maximum, while VHDX files can support up to 64TB of storage (according to SysInfo). The increased capacity makes VHDX better suited for large virtual machines with massive storage requirements.

Performance Comparison

In terms of performance, VHDX offers some advantages over VHD. VHDX uses a 4KB block allocation compared to VHD’s 2MB blocks. This smaller block size helps optimize performance for rapidly changing data and allows for faster operation when expanding dynamic disks (according to Citrix).

Feature Differences

VHDX includes features not available in VHD, like support for virtual machine snapshots, protection against data corruption during power failures, and the ability to dynamically resize files while the virtual machine is running (according to SalvageData). VHDX provides a more robust and resilient virtual disk format.

Limitations of VHDX

While VHDX offers some advantages over the older VHD format, it also comes with some limitations that are worth considering before adopting it:

One key limitation is that VHDX files are not bootable on all operating systems. Unlike VHD files, which can be used to boot virtual machines on a wider range of platforms, VHDX has more limited boot support. For example, VHDX cannot be directly booted on Windows versions prior to Windows Server 2012 and Windows 8. This lack of backwards compatibility can make migration more difficult in some environments.

There are also some compatibility issues to be aware of. Although Microsoft has worked to ensure broad VHDX support across its products like Hyper-V and Azure, third party virtualization platforms do not always fully support the format. For example, older versions of VMware and VirtualBox have limited capabilities with VHDX files. This can complicate workflows if you need to port virtual disks between platforms.

Overall, while the VHDX format provides some compelling advantages, it does come with tradeoffs in terms of boot support and cross-platform compatibility compared to VHD. Understanding these limitations is key when evaluating if and when to migrate legacy VMs or choose VHDX for new virtual disks.

Best Practices for VHDX

When working with VHDX files, there are some key best practices to follow for optimal performance and reliability:

Alignment – It is recommended to align VHDX files to 1 MB boundaries. This ensures the partitions within the VHDX are properly aligned and avoids performance degradation. Improper alignment can significantly slow down I/O operations.

Physical vs. Virtual Disks – For optimal performance, it is best to deploy VHDX files on physical disks rather than virtual disks or RAID arrays. The abstraction layer of virtual disks adds overhead. Physical disks have the fastest speeds.

Backups – Regularly backing up VHDX files is critical to avoid data loss. Incremental backups are preferred over full backups due to their efficiency. Backups should be stored on different media than the original VHDX for redundancy. Offsite backups provide protection against disasters.

Some sources for these best practices include:
https://learn.microsoft.com/en-us/windows-server/administration/performance-tuning/role/hyper-v-server/storage-io-performance
https://www.bdrsuite.com/blog/hyper-v-storage-best-practices/

Alternatives to VHDX

While VHDX is a popular and capable virtual disk format, there are some alternatives that may be better suited depending on the use case:

Other virtual disk formats like VMDK and VDI have some advantages over VHDX in certain virtualization environments. For example, VMDK is the native disk format for VMware hypervisors like ESXi and Workstation. Using VMDK avoids any conversion or compatibility issues when working with VMware products. VDI is VirtualBox’s native format and offers features like disk encryption built-in.

Linux containers like Docker provide an alternative virtualization approach by containerizing applications rather than full virtual machines. Containers allow packing all dependencies and settings together for easy portability between environments. This can provide some benefits over traditional VMs in certain use cases like microservices and portability.

Physical disks may sometimes be preferable for performance-sensitive applications like databases rather than virtual disks. Direct access to physical hardware removes the abstraction layer and overhead of virtual disks. However, this reduces flexibility and portability. Physical disks are best suited when peak performance is critical and consolidating multiple VMs is not a priority.