1. install zerofree. If you are a gentoo user, you can directly emerge-a zerofree.
2. Reboot into the virtual machine with LiveCD;
3, read-only mount virtual disk, the purpose is to use zerofree just installed, refer to the command:
# mount-n-o ro-t ext 4/dev/sda 1/mnt/gentoo
4. Execute zerofree to fill the unused blocks in the specified partition. Please refer to the command:
#/mnt/gentoo/sbin/zero free/dev/sda 1
5. Shut down after execution, open the command line terminal when the physical machine enters the directory where vdi is located, and execute the vdi compression command (modified according to the actual file name):
vbox manage modifyvdi gento 64 . VDI compact
6. Not surprisingly, the vdi file is much slimmer than the original file. If you need to migrate, the effect will be better after packing with 7z extreme pressure (of course, you can also use VBox to ova everywhere)!