Coding with Titans

so breaking things happens constantly, but never on purpose

Minimizing size of VHD on Windows

Virtual hard-drives used by virtual systems running under Hyper-V on Windows 8 Pro (or later) can very quickly become extremely huge in size. Thankfully there is a nice and easy procedure that I always use to minimize and compact them, which presents as following:

  • Turn on the system, that is going to be optimized and log in.
  • Clean the trash bins, clean temp folders and remove all other unneeded stuff from the system drive (like: old system restore points), turn off hibernation and finally turn off or reduce the size of paging file.
  • Defrag if necessary (do it even x3 times, if using Windows XP as guest OS).
  • critical – clean the reclaimed space using sdelete.exe utility from SysInternals (available here).
  • Turn off the guest system.
  • Run the Hyper-V management console and optimize the VHD size from there. Done. Good job!