Scripting HowTo's Security HowTo's

Secure Erase a Hard Drive

Share This:

If you decide that you want to overwrite one of your hard disk drives before reusing or perhaps giving to a friend, you don’t need to download a tool just use a simple script.

Be careful with this script as it will overwrite whatever disk you tell it to for example your boot drive

You can change the loop counter so that it does less than 7 passes as that might be a bit overkill for normal use, you could also change out /dev/zero for /dev/random if you wanted.

if [ -u $1 ]
then
echo "Please set a disk to wipe eg. For device sdb then: ./script.sh sdb"
else
touch "/var/log/disk_wipe.log"
for i in `seq 1 7`;
do
	echo "Running Pass $i on /dev/$1" >> /var/log/disk_wipe.log
	dd if=/dev/zero of=/dev/$1
	echo "Pass $i Complete" >> /var/log/disk_wipe.log
done
fi

To monitor the progress of this script just tail the log file

tail -f /var/log/disk_wipe.log &

If you are wiping a hard disk drive to dispose of it remember that nothing beats shattering the platter with a hammer or running through a drill press or a shredder for total security.

Similar Posts: