You can try to do this with
- reset disk space inside vm by running
cat /dev/zero > /path/to/fill/z; sync; sleep 3; sync; rm -rf z
NOTE. Delete unnecessary files inside the virtual machine before running the above command. If you have several partitions, logical volumes, do it on each of them.
- compact / virtual disk compression (this works fine with VDI format but not sure about VMDK, you can try)
VBoxManage modifyhd --compact /path/to/vdisk.vmdk
You will see the progress, after completion, check its size.
Update : If you want to resize the virtual disk, you must use VBoxManage modifyhd --resize <megabytes> /path/to/vdisk.vmdk .
NOTE. The size of a virtual disk does not really matter; it is exactly the same as the maximum size of a virtual disk image that it can grow. By default, VMDK must be dynamically allocated, which means that the size of vmdk will be close to the amount of data in the virtual machine. The above method will help return the spaces that were freed up in the guest system.
IMPORTANT The growth of the vdisk size is fine, but you should be very careful when reducing / decreasing, there is a risk of losing data with a new size <actual data size in vdisk.
source share