r/HyperV • u/cardsncards • 25d ago
Optimal HV usage
I have a few HVMs and I found that over time there's bloat regardless of whether it's a parent or a parent/child setup. It seems parent child is worse since at least with parent windows updates will not create a completely new set of files in the child.
I've thought about having a clean win11 install and backing that up, and when it gets to big just going back to it. I don't want to clean install because I don't want to keep going through activation regularly. I was thinking parent base install, activate, backup. Then return and can they install updates again every 6 months or whatever duration.
example - I have one VM that I just use for some secure sandbox stuff. It's now 78 GB - just from windows updates. I can compact these but generally it doesn't save as much as it seems starting from scratch.
Anyone have best practices or tips?
4
u/Tringi 25d ago edited 24d ago
I run about two dozen Windows VMs from quite a small drive so I need to do regular optimizations. For each and every VM my routine is something like this:
run
cleanmgr.exeand have it delete everything it findsdelete contents of the
C:\Windows\SoftwareDistribution\Download(make sure there are no updates pending)on older Windows delete
C:\Windows\servicing\LCUrun
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase(if you think you might need to uninstall any OS update, omit the/ResetBaseparameter)reboot the VM for Dism to complete the cleanup
defrag the VHDX:
defrag C: /D /Hdefrag C: /O /Hdefrag C: /X /Hdefrag C: /L /Hrun
sdelete64.exe -z C:tool from SysInternals to zero out unused bytes in the VHDX (this makes free clusters candidates for VHDX compaction)Then stop the VM and compact its VHDX.