Background Back when I got my GL-AR150 mini router, I was blown away by the powerful capabilities of this $25 OpenWRT router,...
Shrinking VirtualBox Linux images with ZeroFreeStanislav Khromov
VirtualBox sparse VDI images always take up as much space as they have maximally had utilized at some point in time. To fix this, we need to fill the empty space on the vdi with zeros and resize it:
Download the SystemRescueCd Live Image.
Mount it as a CD on your virtual machine and boot into the live distro.
Open up a Root Terminal.
Find all available partition and LVM (volume groups) with:
After we find our partition run zerofree to zero out the free space. In our example we will run it on the LVM root partition.
zerofree -v /dev/mapper/vg_rheldev-lv_root
If you want to try a dry run without modifying the hard-drive, add the -n flag.
For LVM, there might also be a _home partition that needs a zerofree run as well.
Finally, boot down your virtual machine, and run VBoxManage on the host to resize the .vdi file.
VBoxManage.exe modifyhd --compact "C:\Users\k\VMs\CentOS Dev.vdi"
(Example is on a Windows host. Linux command should look the same, just omit .exe and add in the correct path.)