Wednesday, March 4, 2009

Challenge #1: Waste disk space

The other day, I gave an old hard drive to my cousin so he can build a linux machine. I wanted to erase the disk first, but it was taking too long, so I told him that once he gets unix installed, I'd show him how to use dd to blank the rest of the disk.

So that's the challenge: create a file full of nulls (zeros) that uses up all the available space on the local disk (not the netfiler). As "df" will show you, /tmp will be on the local disk.

As yourself (not as root), use dd to read from /dev/zero and write to a file in /tmp until it runs out of space and dies. Then delete it before your system starts freaking out.

For extra credit, fill it with random data and tell us how it compares with /dev/zero for speed and CPU usage (xosview and top can help with this). Can you get dd to tell you its current write speed on demand using "kill"?

Maybe these challenges should all come with an implicit spoiler warning: post your solution once you get it, and if you haven't got it, don't peek at everybody else's answers.


  1. Before I moved over to encrypting my home partition, I used this trick periodically to zero out the sectors on my file system where I knew deleted (but not actually blanked out) files were lurking.

    I won't give away the solution to the challenge, but I'll mention that something like 'watch df -h' is nice for keeping an eye on your disk space.

  2. Let's hope the extra credit is done with the dev that has a 'u' in it... It could take a while otherwise...