VBoxManage modifyhd --compact my-virtual-drive.vdiPlease note, that you can compact only drives that are registered with VirtualBox Media Manager.
Thursday, November 18, 2010
While working with dynamically expanding virtual drives you might notice that it actually virtual drive takes more space than it actually use by the virtual machine, e.g. you removed a bunch of files, defragmented volume, etc. Here is how you can compact VDI drive: