Compact a VHD disk in Hyper-V

I have a lab environment with System Center using Hyper-V on my Windows 8 laptop. This is how I compact the virtual disks using powershell when they get too big.

  1. Mount-Vhd –path <full path the vhd file> -readonly
  2. Optimize-Vhd -path <full path the vhd file> -Mode Full
  3. Dismount-vhd -path <full path the vhd file>

Sometimes I have to run the optimize-vhd command a few times before it actually optimizes it, this seems to be a bug. You can automate this by scheduling it as a task and never worry about it again.

Leave a Comment

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

Scroll to Top