Marius van Witzenburg 【ツ】 We have to bring the world together and learn to live as one.

4Feb/100

How to secure wipe a disk

Posted by mariusvw

If you need to trash disk its always smart to first erase all your data on a way others cannot recover it easily.

This script is a nice way to wipe it on a DoD 5220.22-M compatible way.

#!/bin/sh
 
if [ -z "$1" ]
then
   echo "Usage: $0 ad1"
   exit
fi
 
doExit() {
   exit $?
}
trap doExit SIGINT
 
confirmed=0
for n in 1 2 3 4 5 6 7
do
   if [ -c "/dev/$1" ]
   then
       if [ "$confirmed" -eq 0 ]
       then
           echo "Erase /dev/$1 ?"
           read -e confirm
       fi
       if [ "$confirm" = "yes" ]
       then
           confirmed=1
           /bin/dd if=/dev/urandom of=/dev/$1 bs=8b
       else
           echo "Be careful!"
           exit
       fi
   else
       echo "Device not found!"
       exit
   fi
done

%d bloggers like this: