My windows virtual machines vdi disk images were hitting over 35GB a piece, the following notes are a reminder of the steps required to shrink the VDI’s when they get oversized.
Clean up your VM
First – get rid of anything surplus to requirements, recycle bin, disk cleanup, the usual suspects.
Run defrag.
Download the Microsoft tool – sdelete and stick it in System32 – then open CMD and for each drive you are using run – (note the official documentation is wrong!)
sdelete -z
Now if like me you have set a high upper limit to your drive size prepare for a long wait… and make sure that your machine has enough space available to accommodate the full-sized HDD image as this command will expand the image whilst it’s being zeroed out.
And shrink
From the host environment you can then run –
VBoxManage modifyhd Disk.vdi --compact
Refs – official, at the time or writing the instructions are not correct… Oracle page
Oracles bug tracker regarding issues resizing Oracle tracker