by lunarg on April 29th 2007, at 19:40


There are two things you need:

  • A bootable linux LiveCD, preferrably Knoppix, but any other distro with all basic linux tools will do.
  • Some knowledge on how to use commandline based programs (and perhaps some knowledge with linux in general).

The steps

First, make sure to boot with your LiveCD. You won't need to boot entirely into the graphical interface.
For Knoppix, the boot: commandline would be something like:

boot: knoppix 2 lang=your-keyboard-layout vga=normal

You can leave out the vga=normal to use framebuffer instead of plain text mode. Replace your-keyboard-layout (keyboard layout) with your country code: for Belgium (azerty), this would be lang=be; for standard US (qwerty), use lang=us.
Once booted, check the partition layouts of the disks. You don't want to erase the wrong disks. Do this with:

# fdisk -l

A list of partition layouts of all the disks will be shown.

Once you're familiar with which disk (or partition, if you only want to erase a part of it), it's time to do the actual erasing.
The thing we will do is write a whole bunch of zeroes to the disk (or partition). This is done with the dd command.
For our project, this would be something like this:

# dd if=/dev/zero of=/dev/hda bs=32M

A little explanation is required: what we're doing here is to take /dev/zero (a special device that generates nothing but zeroes) as input, and the harddisk special block device file as output. So, we're effectively writing the harddisk with zeroes, disregarding the file system, partition layout, and such. For the last, we specify a block size. Although this parameter is not necessarily required, it may (or may not) speed up the transfer. It's good practice to set this to the transfer speed of one second. If it's around 30MB (for standard ATA66), you would, for instance, set this to 32MB.

An alternative would be to change the input file to /dev/urandom. This would not write zeroes but use the random number generator to fill the disk with. If you use this, however, do mind that this is far more slower than /dev/zero, and takes up quite some CPU time.