View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Blanking a hard drive

From LQWiki

Jump to: navigation, search

Sometimes it is necessary to perform a low-level format on a hard drive, so that the information stored on it cannot easily be recovered. For example, you might be selling an old drive on ebay, and don't want your personal files or data such as passwords to be readable.

With dd

dd can do this by writing ones and zeros to the drive the lowest level. The following will almost certainly be enough

This process is by design irreversable, and should not be done unless you are really sure

$ dd if=/dev/urandom of=/dev/hda #fill drive with random bits
$ dd if=/dev/zero of=/dev/hda    #fill drive with all zeros
$ dd if=/dev/urandom of=/dev/hda     #fill drive with random bits again
$ mkfs.ext3 -f /dev/hda              #optional - be nice and format the drive for the next (Linux) user

Remember to change /dev/hda to the appropiate drive or partition!

This will take some time, and if paranoia is not a priority one pass of random bits should be enough. A person with special equipment may still be able to read your 'erased' data, but it will be way beyond most users.

Because dd can be used to write any data, you are not limited to random bits or zeros. Anything can be piped to dd and it will write it. So if you find that kind of thing funny you might write "GNU forever!" a few billion times accross the drive.

$ yes "GNU Forever!" | dd of=/dev/hda

Some security experts recomend complex multiple passes, but if your data is that precious grinding the drive to dust is probably more appropiate than selling it on ebay.

With GNU shred

shred is part of the GNU coreutils that should be included with every distro. It can overwrite files (including devices such as drives) repeatedly to make it harder for even very expensive hardware probing to recover the data.

The default is for 25 passes, with various patterns of data. Although fewer itterations can be used, the default is very secure but will take a long time.

External Links

  • There is an excellent Linux-based boot disk that does this automatically, Darik's Boot And Nuke, or DBAN for short.
dban.sourceforge.net (dban.sourceforge.net)

Personal tools