securely delete (wipe) a file/partition
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.
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 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:
# figure out the device reference of the partition: df -h # then wipe it: sudo shred -n 5 -v /dev/XXX
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.
- 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:
sfill(wipe free space)
sswap(wipe swap partition)