Virtual Disk Image (VDI) is a Virtual Box container format for guest hard disk. I found that VDI files on the host system grows over the time. If your VDI file on the host system is much bigger than used spaces on guest partition it is time for compaction:
- Install zerofree tool (
apt-get install zerofree).
- Remove unused files (
- Reboot the guest system in single user mode (hit
eduring Grub boot and append single option to the Grub boot parameters).
- Remount filesystems as readonly (
mount -n -o remount,ro /).
- Fill unused block with zeros (
zerofree /). It’s time consuming operation.
- Shutdown the system (
- Compact VDI files on the host system (
VBoxManage modifyhd my.vdi compact). It’s time consuming operation.
That’s all, after the maintenance VDI file size on the host system should be very close to the used space on the guest partition.
Oh, I forgot to mention: you shoud have a backup before start ;–)