Note that these instructions tell you how to erase a disk for simple "keep prying eyes away from your data" purposes. If the device you're erasing contains sensitive data of any kind, and you care about data security, then you should consider "shredding" your device using a tool like DBan (Darik's Boot And Nuke).
#1 - Attach and Locate the Device You want to "Erase"
For a hard disk, you'll probably use /dev/hda. For a USB key, something like /dev/sdd is most common. You'll need to locate the correct device special file for your device; these vary from system to system.
#2 - Erase with All Zeros, or a Random Bit Pattern
Once you've located the DSF for your device, you can use dd to erase it by writing out a series of continuous zeros, or a random bit pattern. For the sake of this example, I'll assume the device you want to erase is /dev/hda. Erase the device with all zeros:
#/> dd if=/dev/zero of=/dev/hda bs=1024k
Or, erase the device with a random bit pattern using /dev/urandom:
#/> dd if=/dev/urandom of=/dev/hda bs=1024k
BTW, for the curious, you can also generate decent passwords using /dev/random.


Did you find this post helpful, or at least, interesting?