Shrinking Virtualbox Hard Drives
Derived from these instructions on HowToGeek
In this tutorial we assume a linux host and a windows guest
- Clean up files
- Delete Unused programs
-
empty all recycle bins
Clear-Recycle-Bin -Force -
delete winsxs: https://helpdeskgeek.com/windows-11/what-is-the-winsxs-folder-why-is-it-huge-and-how-to-cleanup/
DISM.exe /Online /Cleanup-Image /AnalyzeComponentStore DISM.exe /Online /Cleanup-Image /StartComponentCleanup Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase -
Clean up system files (search for "disk cleanup" in start menu)
-
Turn off hibernate
powercfg.exe -h off -
Turn off page file
-
Turn off system restore
https://www.howtogeek.com/5482/make-system-restore-use-less-space-in-windows-7/
control panel --> recovery --> config disable system protection
-
find and delete shadow copies and backups:
-
limit size for shadow copies:
#vssadmin Resize ShadowStorage /For=C: /On=C: /MaxSize=320MB vssadmin list shadowstorage /for=c: vssadmin list shadows /for=c: vssadmin delete shadows /for=c: vssadmin Resize ShadowStorage /For=C: /On=C: /MaxSize=1% -
delete winreaagent folder: https://www.majorgeeks.com/content/page/what_is_the_winreagent_folder_and_can_i_delete_it.html
-
Delete / shrink serviceprofiles directory
netsh branchcache flush -
Remove edge: https://www.lifewire.com/uninstall-microsoft-edge-4156669
-
defrag hard drive
defrag c: /U /Vhttps://www.partitionwizard.com/clone-disk/optimization-not-available.html
-
write zeros to hard drive
.\sdelete.exe c: -z -
Find the virtual hard drive you want to shrink. In the host OS, type:
VBoxManage list hdds -
Execute the shrink command
VBoxManage modifymedium disk "/path/to/disk" --compact