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.
Regards,
The Outspoken Wookie
4 comments:
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?
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).
Thanks for the followup, truly appreciated!
Hey, no probs. We're all here to learn! :)
Post a Comment