Wednesday, September 14, 2011

Hyper-V - Failed To Compact VHD - File System Limitation

If you find yourself wanting to compact a Hyper-V VHD file and see the error message "The system failed to compact disk.vhd. Error Code: The requested operation could not be completed due to a file system limitation" you may find the information below handy.

First, check to see that there are no VSS backups on the VHD by running a "vssadmin list shadows" command in an elevated command prompt.

Second, delete any VSS backups that are present by running "vssadmin delete shadows /all". If this fails to delete the VSS backups, you may need to resort to the "DiskShadow" utility in WS2K8 and WS2K8R2.  (There's some more information on DiskShadow here (free registration required) and also here.)

Finally, defragment the drive to enable greater compaction.  I'm using MyDefrag in this example, but I also use Defraggler and UltraDefrag at times.

After this you should be able to compact the VHD without any issues.


The Outspoken Wookie


Raj said...

Old post - question begs to be asked tho (newbie), did you defrag the host server or did you defrag the virtual server's VHD from within the virtual system?

Hilton Travis said...

G'day Raj,

Before compressing a VHD in the Hyper-V console, I will always run a full system defrag inside the Guest OS using Defraggler, MyDefrag or UltraDefrag and then if I really feel up to it, I'll also run an "sdelete" to ensure all of the reclaimed sectors are properly clean.

This (full defrag and sdelete) results in the most compact form of the VHDs which is a great way to go if you are about to perform exports for backup, relocation and so on. This is exactly what I do when I build a client system on our hardware and then move it to their hardware just before deployment.

Defrags of the host filesystem are next to useless if you're running Fixed VHDs, however if you're running Dynamic VHDs then it is recommended to defragment the host filesystems (after an appropriate backup).

Raj said...

Thanks for the followup, truly appreciated!

Hilton Travis said...

Hey, no probs. We're all here to learn! :)