Reclaiming space from VirtualBox on MacOS

Dynamic disks tend to be the preferred choice for virtual disk images as they only use the physic disk space they need. However while VirtualBox is a very good free virtual machine application, the dynamic disks are much better expanding than shrinking. While commercial tools such as VMWare and Parallels have a one click/automatic way to reclaim physical disk space, VirtualBox needs a little manual intervention.

The following steps will give you some physical disk space back, its a good idea to run these after a major service pack install or after removing a large application from your virtual machine. Steps 1-5 is recommend regardless of which VM application you are running as this frees space on the virtual machine.

1. Delete unwanted files
2. Run Windows Clean Up, use the advanced option to remove windows update files.
3. Empty Recycle Bin
4. Defrag
5. Clean garbage bits and bytes using SDelete by Windows Sysinternals, after installation open cmd and type

sdelete.exe C: -z

6. Shutdown Windows VM and close VirtualBox
7. Open Terminal app and enter

cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/

8. Then enter

VBoxManage modifyhd –compact “[/path/to/vdi]”