If you use VirtualBox ‘Dynamically Expanding’ disk images, you can also compact the image back down in size.
This example shows how to shrink down a Windows virtual machine guest running on a Linux host.
Inside the Windows VM, defrag the hard drive. Go ahead and defrag even if it says a defrag is not necessary.
Programs > Accessories > System Tools > Disk Defragmenter
Inside the Windows VM, empty the free space to zeros with the sysinternals app sdelete.
sdelete.exe is available from: http://live.sysinternals.com/
Start -> Run -> cmd
cd to the location of sdelete, then run:
sdelete -c -z c:
Note: This may temporarily max out the disk size. We will compact it down in the next step.
After sdelete completes, completely shut down your Windows VM.
From your host, run the following command to compact your Windows VM:
$ VBoxManage modifyhd /fullpath/to/windowsdisk.vdi --compact
Note: You must specify the full path for the .vdi for this command to work!
With some VMs I saved 10GB of space! Check it out!