Cleansing a Disk Drive with wipe

Author Note: This was originally posted on linux.com in 2008. I am replicating it here for posterity.

At one point or another everybody that owns a computer will likely need to dispose of a disk drive. The drive may be going out with the whole machine or on it’s own. Whatever the case, it is a good idea to cleanse the drive before it changes hands. Deleting files and reformatting is not sufficient; data can still be harvested from a drive even after it appears to be gone. To do a more through job I suggest using wipe.

When files are deleted they are not really gone. Most operating systems, including Linux on an ext2 file system, just delete the pointer to the file. This means that the data still exists on the drive. It is not effectively removed until every bit of the space it was occupying on the drive has been overwritten. Even then there are ways, albeit difficult, to analyze the drive and extract data. The only way, short of melting the drive, to ensure the data is gone for good is to overwrite the drive several times with random data.

There are several Linux utilities that can be used to fully cleanse files and drives. There is no real advantage to using wipe over any of the others, they all do the same thing. It does have more options than some of the other tools. One of the more useful is the ability to erase a block of data on a partition.

If the target drive is installed in a working system the easiest way to clean it is to run wipe off of a Linux live CD. Knoppix, the granddaddy of Linux live distributions, comes with a ready to use version of wipe.

To get started download and burn the latest version of Knoppix. Then put the CD in the ROM drive of the target machine and boot. If all goes well Knoppix should boot and present the KDE interface. Now launch Konsole (KDE’s terminal emulator)using the icon in the bottom toolbar.

Next, find the partition names of the target hard drive by listing all of the disk devices in the /dev directory. For IDE based drives:

ls /dev/hd*

For SCSI based drives:

ls /dev/sd*

The command should list several items. The primary drive is typically /dev/hda or /dev/sda. There will be an item in the output for every partition on the device.

It should go without saying that running wipe will nuke everything on the target file system. Everything beyond this point is destructive, so make sure anything important is backed up.

wipe’s developers suggest only wiping one partition at a time so for every partition, including the swap partition, run the following command.

sudo wipe /dev/<partition>

Note that the command is ran using sudo so that there are no permission errors. The wipe process will take several hours to complete for a moderately sized hard drive. If you want it to go faster you can tell it how many passes you want it to make by using the -Q option with a number less than 4 — 4 is the default. Do note the more passes wipe makes the better the protection, or at least that is the theory.

If the target drive is not in a working machine it can be placed in a USB enclosure and attached to a Linux machine. Most distributions have wipe in their respective repositories.

To get started install wipe using your distributions package manager. Next, launch a terminal session, find the device, and run wipe on each partition, using the command above. Note that most window managers will automatically mount external USB storage devices when they are attached; unmount the drive before running wipe.

The software does not absolutely guarantee that data on the drive cannot be recovered, but it will go a long way in making it difficult.

wipe is not the only utility for cleansing files and disk drives. shred is another, it can do anything that wipe can do. Another tool is the secure-delete suite. secure-delete comes with 4 separate programs: srm, smem, sfill, and sswap.

  • srm is used for deleting files and directory.
  • smem wipes memory space.
  • sfill will cleanse all of the free space on a drive.
  • sswap cleans swap spaces.

All of these tools essentially do the same thing, and they all do it well.