These are the steps we performed to reclaim disk space on our VHD.
- Boot the PVS VHD from a target machine
- From an elevated CMD on target machine, run “cleanmgr.exe” (this will find Windows updates and other temp files to remove)
- Shutdown the target machine
- On the PVS server, mount the VHD through Disk Management
- From elevated CMD on PVS server, run “sdelete.exe -z X:” (where X is the drive letter of the mounted VHD’s system drive)
- On the PVS server, unmount the VHD through Disk Management
- From elevated CMD on PVS server, run the following:
- select vdisk FILE=<c:\ path to vhd>\name.vhd
- compact vdisk
I’ve found that sometimes I have to run the sdelete command a few times or use the -p switch to specify a # of passes to make. Sdelete will usually expand the VHD but that is where the diskpart command comes in and reclaims the zero’d space.
This link has some helpful write ups and pictures. http://www.pwrusr.com/tips-and-tricks/2-ways-to-compact-your-dynamically-expanding-vhds
If needed, I’ve uploaded the sdelete.exe tool and the full SysinternalsSuite for you to easily download