Derived from these instructions on HowToGeek
In this tutorial we assume a linux host and a windows guest
Clean up files
delete winsxs: https://helpdeskgeek.com/windows-11/what-is-the-winsxs-folder-why-is-it-huge-and-how-to-cleanup/
Clean up system files (search for “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/
find and delete shadow copies and backups: https://superuser.com/questions/1746099/system-volume-information-folder-huge
limit size for shadow copies: vssadmin Resize ShadowStorage /For=C: /On=C: /MaxSize=320MB
delete winreaagent folder: https://www.majorgeeks.com/content/page/what_is_the_winreagent_folder_and_can_i_delete_it.html
defrag hard drive
defrag c: /U /V
https://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