Archive

Posts Tagged ‘wipe’

securely delete (wipe) a file/partition

July 1, 2011 2 comments

Problem

I had a USB stick that I wanted to clean, i.e. even if I lose it, I don’t want anyone to be able to recover the data on it.

Solution

Removing a file with rm or formatting a partition (with gparted for instance) is not enough. There are tools that can restore deleted files. A better way is to overwrite a file/partition repeatedly with random garbage (wipe). And there is still the most secure way: smash your drive with a hammer and pour acid on it :)

shred

Shred can wipe a file or an entire partition. If you shred a partition, all data on it will be lost. If you only want to wipe the free space, you’ll need another tool. Here is how I wiped my USB stick:

<br>
# figure out the device reference of the partition:<br>
df -h<br>
# then wipe it:<br>
sudo shred -n 5 -v /dev/XXX<br>

Where -n 5 means we want to overwrite the paprtition 5 times; -v means verbosity; and /dev/XXX is the device reference of the partition.

Credits: http://www.linux.com/archive/feature/52258.

Alternatives

  • secure-delete tools (sudo apt-get install secure-delete); more info here
  • wipe (sudo apt-get install wipe); more info here
  • dban; more info here

The toolset secure-delete comes with four commands:

  1. srm (remove files/directories)
  2. sdmem (wipe memory)
  3. sfill (wipe free space)
  4. sswap (wipe swap partition)

Update (20230222)

You can also use dd for this purpose. For instance, to wipe an entire disk, you can do this:

$ sudo dd if=/dev/urandom of=/dev/sdX bs=1M status=progress

More info here.

Categories: bash, security Tags: , , , ,