Compact a VHD disk in Hyper-V 1

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.

Anders Rødland

Anders Rødland started his IT career in 2006. My main focus is MS Configuration Manager and client management, and I have passed 17 Microsoft certifications since then. My main expertise is on client management with Microsoft Endpoint Manager: Intune and Configuration Manager. I also do a lot of work on the security side with Microsoft Defender for Endpoint. In addition to my Microsoft certification, I also have an ITIL v3 Foundation certification. This is my private blog and do not represent my employer. I use this to share information that I find useful. Sharing is caring.

Leave a Reply

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