From: http://www.vmbest.com/school/2-virtualbox-school/388-virtualboxvdi
Virtualbox is a very helpful open-source Virtual Machine software. It is very small and runs fast. I use this software in Linux, virtual WindowsXP. However, after a period of time in use, especially when a large number of temporary files are used in the client, although the files are deleted, the size of the VDI file on the VM disk is only increased or decreased, the actual physical hard disk space will be wasted, resulting in insufficient disk space for the host. Now let's talk about how to return unused blank space in the VDI file to the host system and distribute it to the client when necessary.
I use Linux as the host, and the client is Windows XP with NTFS file system.
First install the sdelete software on the client. You can download it at the following address:
Http://www.microsoft.com/technet/sysinternals/Security/SDelete.mspx
Then input
Sdelete-C:
If there is a partition, fill in 0 blank disk space for each partition. That is, fill in all the blank spaces in NTFS format as '0 '.
Close the client and virtualbox, and enter
Vditool shrink windowxp_with_ntfs.vdi
Use vboxmanage modifyhd VDI file name compact in cmd
Vditool is a tool software provided by virtualbox. It mainly performs various operations on VDI files. Shrink is a parameter that indicates VDI file slimming.
After the VDI file is complete, it is restored to the current size, releasing unnecessary physical hard disk space.
I have verified that the original 23g is reduced to 17 GB, but the situation varies with each person, and the effect is not guaranteed to be obvious.