Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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've seen instructions for shrinking the .vdi image for a Windows guest machine in VirtualBox 4.1.8. However, it used a tool to write zeroes to free space in the .vdi (nullfile-1.02.exe) that is for Windows only.

The page did say you should find a zerospace.c to do so in a Linux guest, but I can't find such a file any where on the Internet.

Does anyone here have experience shrinking VirtualBox Linux guests?

share|improve this question
up vote 1 down vote accepted

Writing zeroes to free space isn't difficult (even on Windows!). Just write a file containing zeroes, until you run out of space. On unix, it's a simple shell command:

cat /dev/zero >fill_er_up
rm fill_er_up
share|improve this answer
oh yeah good idea! I'll try it and report back... – hpy Feb 5 '12 at 1:36
And it worked! Thanks for your tip! – hpy Feb 5 '12 at 2:56

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.