How to Use VHDX Disks with Hyper-V on Windows Server 2025

The VHDX format is the modern virtual hard disk standard for Hyper-V, replacing the older VHD format that was limited to 2 TB and lacked resilience features. VHDX disks support up to 64 TB of capacity, use 4 KB sector alignment for optimal performance on modern storage, and include metadata journaling that protects against corruption during unexpected power loss. On Windows Server 2025, VHDX management is fully scriptable through PowerShell, making it easy to create, resize, mount, compact, and share virtual disks as part of automated VM provisioning workflows. This tutorial covers every common VHDX operation you will encounter in a production Hyper-V environment.

Prerequisites

  • Windows Server 2025 with the Hyper-V role installed.
  • PowerShell running as Administrator.
  • Sufficient free disk space on the host storage volume for new VHDX files.
  • For guest disk operations: a running VM with the Hyper-V integration services installed.
  • For shared VHDX: a Windows Server Failover Cluster with a Scale-Out File Server or SMB share for the VHDX location.

Step 1: Understand VHDX Types

There are three VHDX disk types, each with different trade-offs:

  • Dynamic — Starts small and grows on-demand up to the declared maximum size. Efficient for storage but has a slight write overhead as the file expands.
  • Fixed — Pre-allocates all space immediately. Best performance because there is no expansion overhead; preferred for production databases and I/O-intensive workloads.
  • Differencing — Stores only the changes relative to a parent VHDX. Ideal for test labs where many VMs share a common base image.

Step 2: Create a VHDX Disk

Use New-VHD to create all three types. The path can be any location accessible to the Hyper-V host, including a local NTFS volume or an SMB 3.x share.

# Create a 100 GB dynamic VHDX
New-VHD -Path "D:VMsMyVM-data.vhdx" -SizeBytes 100GB -Dynamic

# Create a 200 GB fixed VHDX (pre-allocated, better I/O performance)
New-VHD -Path "D:VMsMyVM-os.vhdx" -SizeBytes 200GB -Fixed

# Create a differencing VHDX based on a parent image
New-VHD -Path "D:VMsTestVM01-diff.vhdx" `
        -Differencing `
        -ParentPath "D:BaseImagesWS2025-base.vhdx"

Step 3: Attach a VHDX to a Virtual Machine

After creating the VHDX, add it to a VM’s SCSI controller. SCSI is preferred over IDE in Generation 2 VMs because it supports hot-add and larger disk counts.

$VMName = "MyVM"
$VHDXPath = "D:VMsMyVM-data.vhdx"

# Add VHDX to the first available SCSI slot
Add-VMHardDiskDrive -VMName $VMName -Path $VHDXPath -ControllerType SCSI

# Verify the disk was attached
Get-VMHardDiskDrive -VMName $VMName

Step 4: Inspect a VHDX with Get-VHD

The Get-VHD cmdlet returns comprehensive metadata about a VHDX file, including its actual size on disk versus its logical size, the disk type, and the parent path for differencing disks.

Get-VHD -Path "D:VMsMyVM-data.vhdx"

# Example output fields:
# VhdFormat        : VHDX
# VhdType          : Dynamic
# FileSize         : 4194304       (current file size on disk)
# Size             : 107374182400  (logical maximum size)
# LogicalSectorSize: 512
# PhysicalSectorSize: 4096

# Check all VHDXs in a directory
Get-ChildItem "D:VMs*.vhdx" | ForEach-Object { Get-VHD -Path $_.FullName }

Step 5: Mount and Dismount a VHDX for Offline Servicing

Mounting a VHDX directly on the host (without a running VM) is extremely useful for offline servicing, injecting drivers, or recovering files. Mount-VHD attaches the VHDX as a disk visible in Disk Management and assigns it a drive letter.

$VHDXPath = "D:VMsMyVM-os.vhdx"

# Mount the VHDX (read/write by default)
Mount-VHD -Path $VHDXPath

# Find the drive letter assigned
$Disk = Get-VHD -Path $VHDXPath
$DriveLetter = (Get-Partition -DiskNumber $Disk.DiskNumber | Get-Volume).DriveLetter
Write-Host "VHDX mounted at drive: ${DriveLetter}:"

# Perform offline operations — e.g., copy files
Copy-Item "C:Driversnetwork.inf" "${DriveLetter}:WindowsSystem32DriverStore"

# Dismount cleanly when done
Dismount-VHD -Path $VHDXPath

Step 6: Expand a VHDX and Resize the Partition

Expanding a VHDX is a two-phase process: first resize the virtual disk file on the host, then extend the partition inside the guest VM.

# Phase 1: Resize the VHDX on the host (VM can be running for dynamic, must be off for fixed)
$VHDXPath = "D:VMsMyVM-data.vhdx"
Resize-VHD -Path $VHDXPath -SizeBytes 200GB

# Phase 2: Inside the guest VM — extend the partition to use new space
# Run the following inside the VM:
$Disk = Get-Disk | Where-Object { $_.PartitionStyle -eq "GPT" -and $_.Size -gt 190GB }
$Partition = Get-Partition -DiskNumber $Disk.Number | Where-Object { $_.Type -eq "Basic" }
Resize-Partition -DiskNumber $Disk.Number -PartitionNumber $Partition.PartitionNumber -Size (
    (Get-PartitionSupportedSize -DiskNumber $Disk.Number -PartitionNumber $Partition.PartitionNumber).SizeMax
)

Step 7: Share a VHDX Between VMs for Guest Clustering

A Shared VHDX allows multiple VMs in a Windows Server Failover Cluster to access the same virtual disk simultaneously — equivalent to a shared SAS disk. The VHDX must reside on an SMB 3.x share or a Cluster Shared Volume.

# Create the shared VHDX (fixed, on a CSV or SMB share)
New-VHD -Path "\FileServerClusterShareSharedDisk.vhdx" -SizeBytes 500GB -Fixed

# Add as a shared disk to two cluster VMs
$VMs = @("ClusterNode01", "ClusterNode02")
foreach ($VM in $VMs) {
    Add-VMHardDiskDrive -VMName $VM `
        -Path "\FileServerClusterShareSharedDisk.vhdx" `
        -ControllerType SCSI `
        -ShareVirtualDisk
}

Step 8: Compact a Dynamic VHDX to Recover Host Space

When files are deleted inside a VM, the VHDX file does not shrink automatically. Use Optimize-VHD to compact unused space. The VM must be shut down first, or the disk must be in read-only mode.

$VHDXPath = "D:VMsMyVM-data.vhdx"

# Check current file size
$Before = (Get-Item $VHDXPath).Length / 1GB
Write-Host "Before compact: $([Math]::Round($Before, 2)) GB"

# Compact the VHDX
Optimize-VHD -Path $VHDXPath -Mode Full

# Check size after
$After = (Get-Item $VHDXPath).Length / 1GB
Write-Host "After compact: $([Math]::Round($After, 2)) GB"
Write-Host "Space recovered: $([Math]::Round($Before - $After, 2)) GB"

For best results before compacting, run Optimize-Volume -DriveLetter C -ReTrim -Verbose inside the guest VM to zero-fill deleted blocks, which gives Optimize-VHD more space to reclaim.

Conclusion

VHDX is the definitive virtual disk format for Hyper-V on Windows Server 2025. Its 64 TB capacity ceiling, 4 KB sector alignment, and metadata journaling make it suitable for everything from lightweight developer VMs to production SQL Server databases. The PowerShell cmdlets covered in this tutorial — New-VHD, Get-VHD, Mount-VHD, Resize-VHD, and Optimize-VHD — give you full programmatic control over the entire VHDX lifecycle, enabling consistent, repeatable disk management across your Hyper-V infrastructure. Choosing the right VHDX type at creation time and compacting dynamic disks regularly are the two habits that will keep your storage efficient over the long term.