'via Blog this'
This worked for me on Debian Testing which has a habit of increasing in size purely due to the number of updates required.
I first tried compacting the disk without zeroing the space and the disk size went down from 12.485GB to 12.476, a massive 9MB saving. ;)
I then followed the procedure in the post modified slightly for Debian:
- Install zerofree using 'sudo apt install zerofree'
- Power off the virtual system using 'sudo poweroff'
- Boot the system holding left shift
- Select advanced options
- Select recovery mode using the latest installed kernel
- Identify your root filesystem (and any other filesystems you want to compact) using 'mount'; take a note of the filesystem type they are using as well
- 'service rsyslog stop'
- 'service network-manager stop'
- Run the following two commands for all the required filesystems:
- 'mount -n -o remount,ro -t ext4 /dev/sda1 /'
- 'zerofree -v /dev/sda1'
- Replace ext3 with the required filesystem type, / with the required mount point, and /dev/sda1 with the required device
- Compact the files system using cmd prompt if on Windows:
- 'cmd' (run as administrator)
- 'cd "\Program Files\Oracle\VirtualBox"'
- 'vboxmanage modifyhd "D:\VMs\Debian Testing\Debian Testing.vdi"' (replace the .vdi path with our own disk image)
My Debian testing disk image was then reduced to 7.333GB saving a further 5.143GB or 41% of the total space.