Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.