Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 had a common question here, I using Virtual Box to create virtual machine, the situation is I need to reduce the VM size, as it grow when there is data moved into the VM, and after the data has been clear out, the VM size never reduce.

How can I reduce the unnecessary size?

Thank you in advanced.

share|improve this question

closed as off topic by Chopper3, Michael Hampton, MDMarra, Brent Pabst, John Gardeniers Oct 8 '12 at 6:39

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

anyone? please help – sams5817 Sep 13 '12 at 2:59
sigh Honestly, your question doesn't provide enough detail for an answer, is probably off-topic for the site, and you should be able to find your answer on Google anyway, but... "you inspire terrible pity," so why not. Got nothing better to do while this database is crunching along anyway. I'll put something up for you in a little bit here... – HopelessN00b Sep 13 '12 at 3:53

Have a look at VBoxManage modifyhd

I think this command will do what you want:

VBoxManage modifyhd diskname.vdi --compact

This command will only be effective on VDI images.

With the --compact option, can be used to compact disk images, i.e. remove blocks that only contains zeroes. This will shrink a dynamically allocated image again; it will reduce the physical size of the image without affecting the logical size of the virtual disk. Compaction works both for base images and for diff images created as part of a snapshot.


For this operation to be effective, it is required that free space in the guest system first be zeroed out using a suitable software tool. For Windows guests, you can use the sdelete tool provided by Microsoft. Execute sdelete -z in the guest to zero the free disk space before compressing the virtual disk image. For Linux, use the zerofree utility which supports ext2/ext3 filesystems.

share|improve this answer

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