Freigeben über


Problem with Compacting VHDs in Hyper-V Management Console

 

If you are using Hyper-V as your virtualization solution, you might be familiar with expand and compact of VHD (virtual hard disk) process. Few days back when I was trying to compact one of my VM’s Dynamic VHDs (Guest OS: Windows Server 2008 R2), I encountered the following error;

[Window Title]

Edit Virtual Hard Disk Wizard

[Error Message]

The server encountered an error trying to edit the virtual disk.

[Content]

'The system failed to compact

'D:\HYPER-V\VM001\Virtual Hard Disks\VM001-Disk1.vhd'. Error Code: The requested operation could not be completed due to a file system limitation.

After researching this issue, it turned out that I had some Volume Shadow Copy (VSS) snapshots inside the guest operating system and needed to remove those first.

Normally I would use <vssadmin.exe delete shadows /all> command to do so but this time I received the following error;

Error: Snapshots were found, but they were outside your allowed context. Try removing them with the backup application which created them.

In this case, I had to use DiskShadow.exe tool that is part of Windows Server 2008 (R2) and delete all the existing VSS snapshots. and the steps are;

1- Start the VM

2- Logon with a local administrator account

3- Run the following command from an elevated command prompt

DiskShadow.exe

DISKSHADOW>Delete Shadows All

     This successfully removed all the VSS snapshots.

4- Shutdown your VM and try compacting the VHD again

 

More Information;

DiskShadow.exe

https://technet.microsoft.com/en-us/library/cc772172(WS.10).aspx

https://technet.microsoft.com/en-us/library/ee221016(WS.10).aspx

https://blogs.technet.com/b/josebda/archive/2007/11/30/diskshadow-the-new-in-box-vss-requester-in-windows-server-2008.aspx

Vssadmin delete shadows

https://technet.microsoft.com/en-us/library/cc788026(WS.10).aspx