Cleaning up a VHD used by Citrix Provisioning Services

These are the steps we performed to reclaim disk space on our VHD.

  1. ​Boot the PVS VHD from a target machine
  2. From an elevated CMD on target machine, run “cleanmgr.exe” (this will find Windows updates and other temp files to remove)
  3. Shutdown the target machine
  4. On the PVS server, mount the VHD through Disk Management
  5. From elevated CMD on PVS server, run “sdelete.exe -z X:” (where X is the drive letter of the mounted VHD’s system drive)
  6. On the PVS server, unmount the VHD through Disk Management
  7. From elevated CMD on PVS server, run the following:
    1. ​diskpart
    2. select vdisk FILE=<c:\ path to vhd>\name.vhd
    3. 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.


If needed, I’ve uploaded the sdelete.exe tool and the full SysinternalsSuite for you to easily download




Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.