Poncho

Ⓐ&♥

VirtualBox

Shrink a vdi VirtualBox disk image

  • Run defrag in the guest (Windows only)
  • Nullify free space:

With a Linux Guest run this:

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

With a Windows Guest, download SDelete from Sysinternals and run this:

sdelete.exe c: -z

On Linux:

vboxmanage modifymedium disk /path/to/thedisk.vdi --compact

Source: https://superuser.com/questions/529149/how-to-compact-virtualboxs-vdi-file-size