Shrinking a dynamic Virtualbox hard disk on Ubuntu

Mount a Ubuntu Live CD and boot into it. Install zerofree

sudo apt-get install zerofree

If the package cannot be found, try enabling Multiverse repository (Software Sources).

Find out which drive you want to shrink


Run zerofree

sudo zerofree /dev/sda1

Once finished, shut down the Virtualbox machine and use Virtualbox to compact the hard disk image file

VBoxManage modifyvdi /path/to/the/image.vdi compact


Comments are closed.