Wiping a Hard Drive with DD

Written by Mark Sanborn: Apr 7, 2008

A common assumption is that deleting or formatting a hard drive will be enough but in fact the data is still recoverable. In fact is fairly trivial and the process is quite easy to restore them. For this reason security is a great concern, especially for those who are selling or donating their old computers. I am going to show you a simple technique for erasing the entire drive. This is the same procedure that the US Government DoD uses to secure their own drives.

When you delete a file or format a hard drive you are basically just telling the computer that it can use this portion of the disk again if it is needed. If that portion of the disk is not every written over again. The data will remain indefinitely. So, in order to make deleted data unrecoverable we must write over it.

Wiping the Drive

Using dd to write over your entire drive with 0s:

dd if=/dev/zero of=/dev/hda

This would effectively write over the entire drive with ascii code 0x00 characters.

At this point the chances for recovering any data would be almost hopeless to most data recovering techniques.

Due to the way hard drives are made it is often possible to determine what was written beneath the most current write operation. If you write the entire drive with zeros, it will be quite easy to see what data was written before. It will be the one that is not a zero!

To further complicate the recovering process we will write over the entire drive with random data.

dd if=/dev/urandom of=/dev/hda

This will write over drive ‘hda’ with random data. Now the recovering process is hopeless.

If you are really paranoid or just want to be ultra secure you could write over the drive 7 times with random data. This is the same procedure the US Government uses to secure its own data.

for n in `seq 7`; do dd if=/dev/urandom of=/dev/sda bs=8b conv=notrunc; done
# chmod a+x wipeIt
sh wipeIt`

Notrunc means ‘do not truncate the output file’.

Other tools commonly used for wiping hard drives.

Darik’s Boot and Nuke

Need to print shipping labels on your site?

Checkout my product RocketShipIt for simple easy-to-use developer tools for UPS™ FedEx™ USPS™ and more.