How to Configure VM Disk Types (VHD and VHDX) on Windows Server 2012 R2
Virtual hard disk configuration is foundational to Hyper-V performance and reliability. Windows Server 2012 R2 supports two virtual disk formats — the legacy VHD and the modern VHDX — each with their own characteristics, size limits, and operational considerations. Choosing the right disk format, type, and configuration for each workload directly impacts VM performance, backup efficiency, and storage utilisation. This guide provides a detailed reference for working with VHD and VHDX files on Windows Server 2012 R2.
VHD Format
VHD (Virtual Hard Disk) is the original Hyper-V disk format introduced with the first version of Hyper-V. Its limitations include:
- Maximum disk size: 2,040 GB (approximately 2 TB minus a small overhead)
- Internal block size: 512 bytes — causes performance problems on Advanced Format (4K native sector) disks due to misalignment
- No metadata journaling — metadata corruption on unexpected shutdown is more likely
- Supported by all Hyper-V versions including Windows Server 2008/R2
VHDX Format
VHDX was introduced with Windows Server 2012 and is the recommended format for all new Hyper-V deployments:
- Maximum disk size: 64 TB
- Internal block size: 1 MB for dynamic/differencing, configurable for fixed — better performance on modern storage
- 4K sector alignment: avoids performance issues with Advanced Format physical disks
- Metadata journaling: significantly reduces the risk of metadata corruption on unexpected host shutdown
- Custom metadata support: allows embedding of custom information about the disk
- Requires Hyper-V on Windows Server 2012 or later (cannot be used on older Hyper-V hosts)
Prerequisites
- Windows Server 2012 R2 with Hyper-V role installed
- Hyper-V PowerShell module
- Sufficient host storage space
Step 1 — Creating VHD and VHDX Files
Create a fixed VHDX (pre-allocates all space immediately — best sequential I/O performance):
New-VHD -Path "D:VMsAppServer-OS.vhdx" -SizeBytes 80GB -Fixed
Create a dynamically expanding VHDX:
New-VHD -Path "D:VMsAppServer-Data.vhdx" -SizeBytes 500GB -Dynamic
Create a differencing VHDX (stores only changes from a parent disk):
New-VHD -Path "D:VMsAppServer-Diff.vhdx" -ParentPath "D:TemplatesWS2012R2-Base.vhdx" -Differencing
Create a fixed VHD (legacy format — use only when the VM must run on older Hyper-V versions):
New-VHD -Path "D:VMsLegacyServer-OS.vhd" -SizeBytes 127GB -Fixed
Step 2 — Inspecting Disk Properties
Get-VHD -Path "D:VMsAppServer-OS.vhdx"
The output includes: VhdType, VhdFormat, FileSize (current on-disk size), Size (maximum/allocated size), MinimumSize, LogicalSectorSize, PhysicalSectorSize, BlockSize, and ParentLocation (for differencing disks). Key values to note:
- FileSize: Actual space consumed on the host disk
- Size: Maximum virtual size presented to the guest OS
- Fragmentation: Percentage of internal fragmentation in dynamic disks
Step 3 — Converting Between Disk Formats and Types
Convert a VHD to VHDX (VM must be off):
Convert-VHD -Path "D:VMsOldServer.vhd" -DestinationPath "D:VMsOldServer.vhdx"
Convert a dynamic VHDX to fixed (VM must be off):
Convert-VHD -Path "D:VMsAppServer-Data.vhdx" -DestinationPath "D:VMsAppServer-Data-Fixed.vhdx" -VHDType Fixed
Convert a fixed VHDX to dynamic:
Convert-VHD -Path "D:VMsAppServer-OS.vhdx" -DestinationPath "D:VMsAppServer-OS-Dynamic.vhdx" -VHDType Dynamic
Step 4 — Resizing a VHDX
Expand a VHDX (the guest OS partition must be separately extended after this operation):
Resize-VHD -Path "D:VMsAppServer-Data.vhdx" -SizeBytes 1TB
Shrink a VHDX (VM must be off; the guest OS partition must be shrunk first to ensure no data is in the area to be removed):
# First, find the minimum size (allows you to know the maximum shrink target):
Get-VHD -Path "D:VMsAppServer-Data.vhdx" | Select-Object MinimumSize
# Shrink to the minimum possible size:
Resize-VHD -Path "D:VMsAppServer-Data.vhdx" -ToMinimumSize
Step 5 — Optimising Dynamic VHDX Files
Dynamic VHDX files grow as data is written but do not automatically shrink when data is deleted. Use Optimize-VHD to reclaim unused space:
# Quick optimisation (compacts free sectors without zeroing deleted data):
Optimize-VHD -Path "D:VMsAppServer-Data.vhdx" -Mode Quick
# Full optimisation (zeros deleted data blocks — requires guest OS to support trim/discard):
Optimize-VHD -Path "D:VMsAppServer-Data.vhdx" -Mode Full
# Pre-zero the guest OS disk before optimisation for best compaction (run inside the VM):
# sdelete64.exe -z C:
# Then compact from the host:
Optimize-VHD -Path "D:VMsAppServer-OS.vhdx" -Mode Full
Step 6 — Merging a Differencing Disk Chain
When checkpoints are deleted, Hyper-V automatically merges the differencing disk into the parent. You can also manually merge a differencing disk:
Merge-VHD -Path "D:VMsAppServer-Diff.vhdx" -DestinationPath "D:VMsAppServer-OS.vhdx"
Step 7 — Mounting a VHDX on the Host
Mount a VHDX file to the host OS for file-level access without booting the VM:
# Mount read-write:
Mount-VHD -Path "D:VMsAppServer-Data.vhdx"
# Mount read-only (safe for live VMs if disk is not currently attached):
Mount-VHD -Path "D:VMsAppServer-Data.vhdx" -ReadOnly
# Verify it's mounted:
Get-Disk | Where-Object { $_.Location -like "*AppServer-Data*" }
# Dismount:
Dismount-VHD -Path "D:VMsAppServer-Data.vhdx"
Step 8 — Setting the Physical Sector Size
VHDX supports configuring the physical sector size. For modern Advanced Format (4K sector) physical disks, setting the correct physical sector size improves performance:
New-VHD -Path "D:VMsNewDisk.vhdx" -SizeBytes 200GB -Dynamic -PhysicalSectorSizeBytes 4096 -LogicalSectorSizeBytes 512
Summary
VHD and VHDX disk management on Windows Server 2012 R2 Hyper-V involves understanding the trade-offs between fixed and dynamic allocation, format conversion pathways, resizing constraints, and optimisation techniques. For all new deployments, VHDX with fixed allocation on fast storage provides the best combination of performance and reliability. Dynamic VHDX is appropriate for development and test environments where storage efficiency matters more than peak I/O throughput. Mastering disk lifecycle operations — creation, conversion, resizing, optimisation, and mounting — gives you complete control over your VM storage estate.