Securely wipe disk

From ArchWiki
Revision as of 19:24, 11 May 2009 by Graysky (Talk | contribs) (Created page with '== Introduction == There are a variety of software titles out there that one can use to securely wipe a disk partition (or an entire disk). Utils such as shred for example. One...')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

There are a variety of software titles out there that one can use to securely wipe a disk partition (or an entire disk). Utils such as shred for example. One can also use dd to accomplish the same task.

Using dd to Overwrite with Zeros

Select a Target Drive/Partition

You can use fdisk to locate all your read/write devices on the system. Theoretically, this will include USB drives (thumb and HDD) provided that you can access the devices from the O/S. To list them, enter the following:

# fdisk -l

Inspect the output looking for lines that start with devices such as /dev/sda or /dev/hda (ide drives). On my system, my USB thumb drive comes up as /dev/sdc as shown:

Disk /dev/sdc: 4063 MB, 4063232000 bytes
125 heads, 62 sectors/track, 1024 cylinders
Units = cylinders of 7750 * 512 = 3968000 bytes
Disk identifier: 0x00000000

In my case, I want to totally fill my thumb drive with zeros so I will be targeting the /dev/sdc as shown above. If you're interest is a specific HDD partition, make note of the correct location from the fdisk -l output. For example, /dev/sda1 or /dev/sdb5 etc.

Start the Overwrite

Warning: There is no conformation regarding the sanity of this command so TRIPLE CHECK that you have selected the correct drive partition or drive!

Now that you have selected a target issue the following to have dd overwrite the entire partition/drive with zeros:

# dd if=/dev/zero of=/dev/sdc bs=1M
Tip: Make sure that you specify a blocksize (bs). I have always used 1M but others have reported that using a bs of 4M is effective as well. If you do not, the default is a very small number and it will take MUCH longer to overwrite the device.

Checking on the progress

By default, there is no output of dd until the task has finished. You can force some output simply by opening up a 2nd root terminal and issuing the following command:

# kill -USR1 <PID_OF_dd_COMMAND>

You can obtain the PID of your dd command by issuing this line:

# ps aux | grep dd

Here is an example output on my system:

root      4709  0.0  0.0  17764  1128 ?        S    14:34   0:00 hald-addon-storage: polling /dev/sr0 (every 2 sec)
root      4711  0.0  0.0  17772  1088 ?        S    14:34   0:00 /usr/lib/hal/hald-addon-cpufreq
hal       4712  0.0  0.0  15356   984 ?        S    14:34   0:00 hald-addon-acpi: listening on acpi kernel interface /proc/acpi/event
user1     7773  0.0  0.0   8776  1448 ?        Ss   14:36   0:00 /usr/bin/dbus-daemon --fork --print-pid 6 --print-address 9 --session
root     25873  0.0  0.0  17768  1108 ?        S    14:59   0:00 hald-addon-storage: polling /dev/sdc (every 2 sec)
root     29201  8.0  0.0  10612  1684 pts/0    D+   15:04   0:00 dd if=/dev/zero of=/dev/sdc bs=1M

In my case, the correct PID is 29201 so I would issue:

# kill -USR1 29201

This causes the terminal in which dd is running to output the progress at the time you ran the command. Example:

605+0 records in
605+0 records out
634388480 bytes (634 MB) copied, 8.17097 s, 77.6 MB/s