You may get the following error when attempting to compact a Hyper-V virtual hard disk (VHD):
The system failed to compact disk.vhd. Error Code: The requested operation could not be completed due to a file system limitationThis can be happen for several of reasons.
- Windows Server 2008 R2 does not support hosting VHDs on compressed NTFS volumes. See the article, Virtual Hard Disk (VHD) Architecture Explained.
- The NTFS volume where the VHD resides is very heavily fragmented. See Microsoft KB967351.
The VHD in question was an Exchange 2010 data volume where I had run an Exchange-aware VSS backup using the native Windows Server Backup utility. See my article, How to Backup Exchange 2010 RTM at Release Timeframe.
In order to compact the VHD, all VSS shadows must be deleted from the VHD volume within the VM. This can be done by running the vssadmin utility, as such:
vssadmin delete shadows /allNow you can compact the VHD to reduce the physical size of the VHD file and regain space on the Hyper-V host.
That's it! Thanks for solving my problem.
ReplyDeleteI removed my shadow copies and it worked! Excellent solution - thank you!
ReplyDeleteIt works perfect for me!!
ReplyDeleteThank you, thank you, thank you!!!
Thanks! Deleting shadow copies saved me too.
ReplyDeleteBlogged: Hyper-V Failed to Compact VHD.
If the VM is Vista - disable the "System Restore" feature to delete the VSS backups since vssadmin can't do it in this scenario.
ReplyDeleteThanks for this article - VSS backup in the guest (as a system restore point) was my issue as well!
great thanks. that just worked for me. I'm using Windows 2003 VHD.
ReplyDeleteThat did the trick for me too, thanks!
ReplyDeleteWorked for me too. And I can see the logic behind it is that way. Thanks
ReplyDeleteThanks for the hint that this was caused by VSS backups. Mine couldn't even be removed using vssadmin, and I had to resort to the diskshadow tool, but I got there in the end.
ReplyDeleteThanks Jeff. In my case it was VSS shadow copies on the partiton, a SBS 2008 box. Following your instructions did the trick. Great blog BTW.
ReplyDeleteThanks for posting this, solved my problem as well!
ReplyDeleteR.
Thanks! That worked!
ReplyDeleteThis saved my day! Winows 7 x64 / Windows Server 2008 R2 x64!
ReplyDeleteExcellent post!
ReplyDeleteThe following is added to lure Google users here for a good answer:
Compacting a VHD of Windows 7 can fail "due to a file system limitation" because of System Restore.
Boot back into your VHD - turn off System Restore - and try again.
Fantastic!!!
ReplyDeleteWorks fine!!!
Disabled shadow copy - and it worked!
ReplyDeleteOS is Windows 2008 R2 + SP1.
Big thanks from Canada.
worked - thank you!
ReplyDeleteThanks, it worked
ReplyDeleteRavi Luchmun
Saved me a ton of time, thank you.
ReplyDeleteJust thought I'd say that if you have a problem removing the shadows using vssadmin, try using the diskshadow command instead. It seems to remove problem shadows that vssadmin won't remove.
ReplyDeleteThings just don't work straigthforward anymore these days :-(
ReplyDeleteThx.