Hyper-V AVHDX File Growth Mystery: How to Prevent Disk Full Errors During Automatic Merge Operations


2 views

Many Windows Server administrators running Hyper-V have encountered this puzzling scenario: your VM suddenly stops with "disk full" errors despite having ample free space, and you discover temporary .avhdx files consuming all available storage. Let's examine a typical case:

# Typical error sequence from Hyper-V logs
ProviderName: Microsoft-Windows-Hyper-V-StorageVSP

11.03.2018 5:36:08   5 Information  Storage device 'D:\\DBS82-Data.vhdx' changed recovery state
11.03.2018 5:36:08   4 Information  New status = Disk Full
11.03.2018 5:36:08   6 Information  IO failure with error = SRB_STATUS_ERROR_RECOVERY

These .avhdx files are differencing disks created during Hyper-V's automatic merge operations. When you see VMs in "merging" state, it means Hyper-V is attempting to consolidate checkpoint (snapshot) data back into the main VHDX.

The process follows this pattern:

  • 1. Hyper-V creates temporary AVHDX files during merge
  • 2. System needs 2x original VHDX size during operation
  • 3. If disk space is insufficient, merge fails but AVHDX remains

For immediate resolution when disk is full:

# PowerShell commands to manage merge operations
# List all AVHDX files
Get-VHD -Path D:\*.avhdx | Format-Table Path,FileSize,ParentPath

# Manually trigger merge if automatic one failed
Merge-VHD -Path "D:\DBS82-Data_E8D5659C--CBA3-4813-8543-F30F264A7A2F.avhdx" -DestinationPath "D:\DBS82-Data.vhdx"

# Alternative: Delete broken merge files (ONLY if you have recent backup)
Remove-Item -Path "D:\DBS82-Data_*.avhdx" -Force

Implement these proactive measures:

  1. Storage Monitoring: Set up alerts when disk reaches 70% capacity
  2. Checkpoint Policy: Avoid long-lived checkpoints in production
  3. Defrag Schedule: Don't run defrag during merge windows
  4. Space Calculation: Always maintain FreeSpace > (LargestVHDX * 2)

For high-availability environments, modify these registry settings:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization]
"MergeStartTime"="03:00"  # Change default 5:36AM merge time
"MergeTimeout"=dword:00002710  # Increase timeout from 10,000ms (10s)

Remember to reboot after registry changes and test during maintenance windows.


If you're seeing sudden disk full errors in Hyper-V with Windows Server 2016, particularly during scheduled maintenance hours (like 5:36 AM in this case), you're likely encountering the automatic merge operation feature introduced in newer Hyper-V versions. The .avhdx files are differencing disks created during checkpoint (formerly snapshot) operations.

Unlike Windows Server 2008, modern Hyper-V implementations automatically create and merge checkpoint chains. When you see VM status as "merging", Hyper-V is:

  1. Creating temporary AVHDX files
  2. Processing the checkpoint chain
  3. Attempting to consolidate changes

You can manage this through PowerShell (recommended) or Hyper-V Manager:

# Check current checkpoint settings
Get-VM -Name "YourVMName" | Select-Object Name, CheckpointType

# Disable automatic checkpoints (production recommended)
Set-VM -Name "YourVMName" -CheckpointType Disabled

# Alternative: Configure checkpoint location
Set-VM -Name "YourVMName" -SnapshotFileLocation "E:\\HyperV\\Checkpoints"

When you hit the disk full scenario:

# Find all AVHDX files older than 1 day
Get-ChildItem -Path "D:\\" -Filter *.avhdx | 
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-1) } |
Remove-Item -Force -WhatIf

# For stuck merge operations
Get-VM | Where-Object { $_.State -eq "Merging" } | 
Stop-VM -Force -WarningAction SilentlyContinue
  • Monitor disk space with threshold alerts (15% free minimum)
  • Place checkpoints on separate physical disks
  • Schedule merges during low-usage periods
  • Consider using Production Checkpoints instead
# Scheduled task to cleanup old merge files
$Trigger = New-ScheduledTaskTrigger -Daily -At 3AM
$Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-Command "Get-ChildItem -Path 'D:\\' -Filter *.avhdx | Where-Object { $_.LastWriteTime -lt (Get-Date).AddHours(-6) } | Remove-Item -Force""
Register-ScheduledTask -TaskName "HyperV_MergeCleanup" -Trigger $Trigger -Action $Action -RunLevel Highest