VHD Liposuction–How to shrink a dynamic VHD file after reclaiming space

The Problem
You have a 250GB VHD Dynamic VHD file which has eaten too much of your Hyper-V host’s drive space (WSUS Instances come to mind).   You have accessed the virtual machine and deleted/removed the unwanted bloat that occurs over time.  But, you still can’t shrink the .VHD file on the host server.


The Solution

Simply deleting or otherwise removing files from your virtual machine’s drive does not allow the VHD to be shrunk.  You must “Zero Out” the unused sectors so Hyper-V can reclaim the space.

 

The How To

  1. Download Secure Delete from Microsoft onto the Virtual Machine
    http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx
    Important: Remember to unzip the file to an easy to access location.
  2. Open a Command Prompt
    Important: Remember to launch as Administrator!
  3. Execute SDelete as follows (where [path] is the located you unzipped the file)
    [PATH]sdelete –c -z
  4. Accept the terms and let it run
  5. Wait….
  6. Shutdown the virtual instance
  7. Launch Hyper-V Manager on the host server
  8. Open up the setting panel for the Hyper-V instance you wish to perform a VHD shrink for.
  9. Select the drive you wish to compact and click Edit
  10. Select Compact and click Finish
  11. Wait…

 

That is it!  Your done!

Leave a Reply

Your email address will not be published. Required fields are marked *