Wiping a Hard Drive with DD

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 0×00 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.

#!/bin/bash
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


Was this information useful?


4 Responses to "Wiping a Hard Drive with DD"
  1. Securely Wipe a File with DD on April 15th, 2008

    [...] If you looking for a way to wipe an entire hard drive check out, Wiping a Hard Drive with DD. [...]

  2. wilson on August 13th, 2009

    how about for windows OS?

  3. Tomas on October 5th, 2009

    wilson, if you’re using Windows then your valuable data is available on the net anyway ;)

    But seriously, you could use the same technique. The dd utility that is used in the article can be found for Windows as well: http://www.chrysocome.net/dd

  4. JesperJ on January 26th, 2010

    Here comes some data from a real world usage experience:

    “dd if=/dev/urandom of=/dev/sda bs=8b conv=notrunc”, tog 1878 minuter på en 400gb hårddisk, med snitt 3.6mb/sek. 1878 min = 31,3 timmar. Jag tror jag gissade på att det skulle ta ca 33 timmar \o/. Systemet är: core2duo @ 2.4ghz, 2gb ram, sata hdd

    “dd if=/dev/urandom of=/dev/sda bs=8b conv=notrunc”, took 178 minutes on a 499gb harddrive, with a 3.6mb average. 1878 min == 31.3 hours. I guessed it would take around 33 hours \o/

    System info: core2duo @ 2.4ghz, 2gb ram, motherboard Asus P5B Deluxe, harddrive is a sata drive, model “ATA SAMSUNG HD401LJ”.

    More data would be interesting to see.