- Remove all unnecessary applications and files, empty the trash, etc.
- Do a defrag. You can use Defraggler if you want.
Use sdelete to write all zeros to the free space by downloading sdelete and extract it to your desktop.
Open a command prompt and cd to the sdelete directory. Type in the following command:
sdelete -z c:/
Now we can use the VboxManage command (This was tested using version 184.108.40.206) . This should be in your path already but if not add it.
Open a command prompt where your vdi file is located and use the command as follows:
vboxManage modifyvdi /path/to/your/VM.vdi compact
Give it some time, possibly hours depending on the size of your vdi file and it should shrink down to the actual usage of the data in the vdi file.