How to reclaim space in .vhdx files and shrink disc

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. Remember this wil max out the capcity of the .vhdx files so you wil need to have enough space on your host.

 

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…

Source: http://blog.armgasys.com/?p=426

 

Kommentarer er stengt.

Blogg på WordPress.com.

opp ↑

%d bloggere like this: