MakeTechEasier.com have a great article describing how to shrink a VirtualBox disk image with lots of screenshots, but here are the basic steps for shrinking a VirtualBox image that runs a Windows 7 guest OS. This only works on VDI disk images.
On the Windows 7 guest OS follow these steps:
- Uninstall any unused programs
- Delete any files you don’t need
- Run Disk Cleanup Start->All Programs->Accessories->System Tools->Disk Cleanup
- Download CCLEANER and run it.
- Run Disk Defragmenter Start->All Programs->Accessories->System Tools->Disk Defragmenter
- Download SDELETE and run this command: sdelete –z C:\
The guest Windows 7 OS has now had all the free space zeroed out and is ready for compacting. So from a command line on the host OS:
- Navigate to the VirtualBox installation folder, on my Windows 7 x64 OS it’s located here: C:\Program Files\Oracle\VirtualBox\
- Run: vboxmanage modifyvdi YOUR-VDI-FILENAME.vdi compact
How To Shrink Your Virtualbox VM And Free Up Space For Your Hard Disk