Wipe/Scrub A Hard Drive
Login | Register RSS
08/14/2011 - Linux 

Wipe/Scrub A Hard Drive

If you are a Linux guru, then you may already be aware of the power of the 'dd' command.  Other then being used to clone drives/partitons, it can also be used to wipe/scrub hard drives & most removal media (such as floppy disks, zip disks, flash drives, backup tapes, etc...).

To wipe the entire drive (MBR, all partitions & all data), use this command:

dd if=/dev/zero of=/dev/sda bs=1M

This fills the entire disk (i.e. /dev/sda) with zeros.  Depending upon the capacity & speed of the media being wiped, this may take quite a while to complete..

* Note: It is better to wipe a drive, instead of just formatting it.  However realize that when you wipe a drive with this method, the drive can still be recovered with the right tools.

If you are going to discard, give it away or sell the drive, its recommended that you scrub the drive clean, before it leaves your hands.  This way, you can ensure that whomever gets their hands on that media, they cannot recover your personal data.

To scrub a drive clean for security, you should populate it with random data (instead of zeros).  You should repeat the process several times in a row to prevent data recovery.  This process is really going to take a long time to complete, so its something you should start & leave it to do its thing -- just go on with your normal life & it will eventually complete.

To securely scrub the entire drive (MBR, all partitions & all data), use this command:

dd if=/dev/urandom of=/dev/sda bs=1M count=7

This fills the entire disk (i.e. /dev/sda) with random characters.  It does this process 7 times to prevent possible data recovery.  Depending upon the capacity & speed of the media being scrubbed, this will likely take a really really long time to complete.

* Note: This is the best way to scrub a drive clean, instead of just formatting it or performing a basic wipe of the drive.  However its very very time & system consuming process, but the result is that the media cannot be recovered at all.

On a side note, these same processes can also be used to target to a single partition on drive a well.  Simply specify the specific partition with the 'of=' part of the command.

For example, the below command will wipe only the 2nd partition on drive 'sda' with zeros (i.e. /dev/sda2)

dd if=/dev/zero of=/dev/sda2 bs=1M

You can also use 'dd' to wipe just the MBR of a drive, using this command:

dd if=/dev/zero of=/dev/sda bs=446 count=1

As you can see, the 'dd' command has some very special properties, which can be used with just about any Linux distro or Linux Live CD to handle things for you, instead of needing to purchase expensive software or paying a company to wipe the drives for you.

UPDATE - 01/09/2012:

Another alternative is to use the "shred" command from a Linux LiveCD/DVD
 An example of this command would be:

shred --force --iterations=100 --zero /dev/sda

This will do 100 iterations of overwriting with random data & perform a final pass with only zeroes.

If you like this site or any of its content, please help promote it. Use the social media buttons below to help spread the word. Don't forget to post in the comments section.

  Print   Email