Open a command prompt diskpart
select vdisk file="d:\store\vdisk.vhd"
attach vdisk readonly
compact vdisk
detach vdisk
Ed Price - MSFT edited Revision 2. Comment: Title casing and tag. Great article!
Thanks for this concise article, and the tip on using sdelete to clean free space in the VHD.
If you look at the sdelete syntax technet.microsoft.com/.../bb897443 (under "Using SDelete"), you'll notice that the -V switch is specific for cleaning VHD files.z
So you would run 'sdelete.exe -z V:' [where V: is the drive letter of the mounted VHD file] and then repeat the steps above to compact the VHD.
Cool !!!
So using sdelete made my .VHD file grow from 85GB to 120GB. Diskpart compact completed successfully but did not result in a smaller file. Following these steps expanded my VHD and made my problem worse. I now have a completely full host drive...
Shan, sorry to hear that. Actually when I did try the sdelete pass, the file grow at first, because it fill empty space with 0 (thus the file grow to it maximum's possible's size), but another compact did the job on my side to simply shrink it.