Difference between revisions of "Electromagnet Hard Drive Erasure"
(→Project Details) |
(→Procedure) |
||
| Line 23: | Line 23: | ||
[[File:Chart3.png|frameless]] | [[File:Chart3.png|frameless]] | ||
| − | = | + | = Project Steps = |
| − | == | + | == Preparation == |
First, I cleared the whole disk with zeros: | First, I cleared the whole disk with zeros: | ||
Revision as of 01:26, 31 May 2019
Torture test of a Seagate hard drive using magnets, including my grossly overpowered electromagnet made from a microwave oven transformer (MOT). I try to quantify the difference in magnetic strength between the different magnets. I then inflict a series of escalating traumas upon the hard drive, following each assault by a scripted routine of tests that generates a wealth of data about the drive's status. When will this hard drive fail? And how? Can you really erase data from a hard drive using a magnet?
Warning: Powerful magnets pose a risk of pinching, broken bones, and damaged electronic devices including medical devices.
Video
[placeholder video]
Gallery
Project Steps
Preparation
First, I cleared the whole disk with zeros:
dd if=/dev/zero of=$device conv=notrunc,noerror,fdatasync bs=1M
Then I wrote random bits to the first 1 gigabyte of the disk:
dd if=/dev/urandom of=$device conv=notrunc,noerror,fdatasync bs=1M count=1000
I then generated a 1 gig file full of random bits:
dd if=/dev/urandom of=$HOME/writefile.bin conv=notrunc,noerror,fdatasync bs=1M count=1000
Scripts
magtest.sh
#!/bin/bash
#
# Script for testing a hard drive after attempting to destroy it with magnets.
#
# Parameters:
# - $1 test_no
# - $2 "description"
#
# Example: sudo ./magtext.sh 1 baseline
#
# Test results will be written to this log file
outfile="$HOME/results-magtest.csv"
# Device of test drive
device="/dev/sdb"
# File containing random bits for doing a write test (1G size)
writefile="$HOME/writefile.bin"
# Sound to play when done
sound="fanfare3.wav"
# Parameter check
if [ $# != 2 ];then
echo "Usage: $0 test_no \"description\""
exit 1
fi
# Root check
if [ "$(whoami)" != "root" ];then
echo "Must be root."
exit 1
fi
begun=false
exit_f(){
badblocks_interrupted=true
}
#if [ $begun ];then
# echo "INTERRUPT"
# if [ -f "$outfile" ];then
# dtend="$(date +%Y-%m-%d_%H:%M:%S)"
# echo "$1|$dt|$dtend|\"$2\"|\"$badblocks\"|\"$smarttest\"|\"$readperf\"|\"$writeperf\"|$checksum|\"$imagefile\"" >>$outfile
# echo "OUTFILE WRITTEN"
# exit 1
# else
# echo "OUTFILE NOT WRITTEN"
# fi
#fi
trap "exit_f $1 $2" INT
# Get confirmation from user
echo "You are about to perform hard drive test #$1 on $device: \"$2\""
echo -n "Is this correct? [y,N] ";read ans
if ! [[ $ans =~ [yY].* ]];then
echo "Cancelled by user."
exit 0
fi
# Define imagefile
imagefile="$HOME/hddread$1.img"
# If imagefile exists, make sure it's okay to overwrite it
if [ -f $imagefile ];then
echo -n "Overwrite existing imagefile: $imagefile ? [y,N] ";read ans2
if ! [[ $ans2 =~ [yY].* ]];then
echo "Cancelled by user."
exit 0
fi
rm -f $imagefile
fi
## Start test
begun=true
dt="$(date +%Y-%m-%d_%H:%M:%S)"
echo "STARTING TEST: $dt"
if ! [ -f "$outfile" ];then
outhead="test_no|start_time|end_time|description|badblocks|health|read_perf|write_pref|checksum|imagefile"
echo $outhead >$outfile
fi
# Badblocks test
echo "TEST: Badblocks"
badblocks="BAD BLOCKS"
badblocks_interrupted=false
badblocks $device -o badblocks$1.out
sleep 1
if [ -z $(cat badblocks$1.out) ] && ! [ $badblocks_interrupted ];then
badblocks="good blocks"
elif [ $badblocks_interrupted ];then
badblocks="INTERRUPT"
fi
# SMART test
echo "TEST: SMART Test"
smartctl -s on -t short $device >/dev/null 2>&1
sleep 120
smarttest="$(smartctl -s on -a $device | grep 'Short offline' | tail -1 | sed -E 's/\ +/ /g;s/\ -//g')"
# Read performance
echo "TEST: Read performance"
readperf="$(hdparm -Tt $device | tail -2)"
# Write performance
echo "TEST: Write performance"
writeperf="$(dd if=$writefile of=$device conv=notrunc,noerror,fdatasync bs=1M seek=1000 2>&1 | tail -1)"
# Get image file of both read and write sections (2G total)
echo "TEST: Get image file"
dd if=$device of=$imagefile conv=notrunc,noerror,fdatasync bs=1M count=2000 >/dev/null 2>&1
# Clear the write section with zeros
echo "CLEANUP: Clear write section"
dd if=/dev/zero of=$device conv=notrunc,noerror,fdatasync bs=1M count=1000 seek=1000 >/dev/null 2>&1
# Get checksum of image file
echo "CLEANUP: Get checksum"
checksum="$(md5sum $imagefile | awk '{print $1}')"
# Write results to CSV file
echo "RECORD: Log results"
dtend="$(date +%Y-%m-%d_%H:%M:%S)"
echo "$1|$dt|$dtend|\"$2\"|\"$badblocks\"|\"$smarttest\"|\"$readperf\"|\"$writeperf\"|$checksum|\"$imagefile\"" >>$outfile
# Play a sound
paplay $sound
echo "COMPLETE: Test $1 finished $dtend"
hdd-readtest.sh
#!/bin/bash
device=/dev/sdb
dd if=$device of=rtest.img conv=notrunc,noerror,fdatasync bs=1M count=2000
rm -f rtest.img
Small Magnet: 2.5cm
Medium Magnet: 7.5cm
Large Magnet: 20.5cm
Links
- http://www.emfs.info/limits/limits-organisations/acgih/: The American Conference of Governmental Industrial Hygienists (ACGIH), TLVs (Threshold Limit Values) and BEIs (Biological Exposure Indices)