VitrualBox: reducing the size of the vdi disk
2018-10-11 07:36:35 5 2
It is always good to save disk space on your computer, especially if you have lots of virtualbox machines to work with. There is the way to have them small enough to keep on the disk or to export to the .ova file etc. This method works only with dynamic types of the disks, so it is important to discover the virtualbox disk type before the start. Other thing that should be taken in consideration is what all unwanted data should be removed from the disk before start as well.
1. Zeros should be written to the disk on the guest machine
Linux Mint 18.3:installing zerofree
sudo apt install zerofreeand then use it is -v (verbose) option to see the output
zerofree -v /path/to/partition
Windows 10:At first is needed to defragment the disks which should be resized. Than sdelete app should be used
sdelete.exe c: -z
macOS 10.13.6 High Sierra:For macOS standard util diskutil should be used
diskutil secureErase freespace 1 /path/to/volumeFor some reasons this approach doesn't work for me. I used type 4 instead of 1 to fill the disk with zeros.
2. VBoxManage command on the host to reduce virtual disk
VBoxManage modifymedium disk "/path/to/.vdi" --compact