Compacting Virtual Box Drives

By Mathias Westerdahl / 2013-10-09 / In categories notes

Too many times I’ve forgotten the exact commands on how to compact the virtual drives. Especially for windows, where the tool used, used to have a different name of the argument passed to it. Compacting the drive can save you lots of disc space (last time my drive went from 12GB to 5GB), and for a smaller lap top drive, that makes a big difference.

Windows Guest: Download SDelete from SysInternals and then run

SDelete.exe z

Linux Guest: Here, we create a file that fills the entire empty space, and then deleting it:

dd if=/dev/zero of=fillfile bs=1M rm fillfile

Host: Finally, you let VirtualBox compact the drive

VBoxManage modifyhd harddrivename.vdi --compact

That’s it really! I hope I’ll remember it a little better this time.

Further info:

Mathias Westerdahl

Author

Mathias Westerdahl

A game developer since 2001. Currently at http://www.defold.com