-
Notifications
You must be signed in to change notification settings - Fork 1
/
burn-in.sh
executable file
·66 lines (53 loc) · 1.43 KB
/
burn-in.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#
# Burn-in procedure for hard disks using
# SMART and badblocks.
#
# WARNING: This will destroy all data on the drive!
set -euo pipefail
if [ $# -ne 1 ]
then
echo "Usage: $0 <device> (eg: /dev/sdb)"
exit 1
fi
DRIVE="$1"
echo "Starting burn in procedure for drive ${DRIVE}..."
if [ ! -e "${DRIVE}" ]
then
echo "Drive ${DRIVE} not found!"
exit 1
fi
for dependency in parted smartctl badblocks
do
if [ ! "$(which $dependency)" ]
then
echo "Error: Missing dependency $dependency"
exit 1
fi
done
if [ $EUID -ne 0 ]
then
echo "Error: This script must be executed as root!"
exit 1
fi
parted "${DRIVE}" print
BLOCK_SIZE=$(cat "/sys/block/${DRIVE/\/dev\//}/queue/physical_block_size")
echo -n "WARNING: The burn in procedure involves writing multiple passes of "
echo "data onto the disk."
echo "This will irrevocably destroy all data on the disk!"
echo "Is ${DRIVE} the correct disk with physical sector size ${BLOCK_SIZE}?"
echo -n "Type 'YES' to continue: "
read -r confirmation
if [ "$confirmation" != "YES" ]
then
echo "Burn in procedure aborted!"
exit 1
fi
echo -e "\nRunning initial SMART tests..."
smartctl -Ct long "${DRIVE}"
echo -e "\nStarting badblocks burn in procedure. This can take a long time..."
badblocks -ws -b "${BLOCK_SIZE}" "${DRIVE}"
echo -e "\nRunning final SMART tests..."
smartctl -Ct long "${DRIVE}"
echo -e "\nFinal SMART results:"
smartctl -A "${DRIVE}"