Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have vdi file for a disk of 40GB. The vdi file itself is 36GB. I made some room in the disk and was able to resize the partition of the disk to 20GB, leaving an unpartitionned space of 20GB.

I tried:

VBoxManage.exe modifyhd thedisk.vdi --resize 20480

which gives an error, and:

VBoxManage.exe modifyhd thedisk.vdi --compact

which leaves a vdi file of... 36GB.

How can I reclaim the unused space?

share|improve this question
up vote 5 down vote accepted

One possibility is to fill the empty space from within the VM.

On Windows (sdelete is a Sysinternals tool, and X: is the letter of the drive):

sdelete -z X:

On Linux:

dd if=/dev/zero of=/tmp/zero
rm /tmp/zero

(The dd command may run faster if you say dd if=/dev/zero of=/tmp/zero bs=1M.)

And then use the command (from the host):

VBoxManage.exe modifyhd thedisk.vdi --compact
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.