-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLI_smarttest.sh
65 lines (49 loc) · 1.25 KB
/
CLI_smarttest.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
#!/bin/sh
echo ""
echo "Batch Smart Test Script"
echo ""
echo "Be sure to edit your drives in the script"
drives="sda" #Drives are space separated when multiple eg: "sda sdb sdc sdd sde sdf"
command -v smartctl >/dev/null 2>&1 || if [[ $? -ne 0 ]] ; then
echo -e "Error : Smartmontools not installed."
exit
fi
for drive in $drives
do
(
brand="$(smartctl -i /dev/"$drive" | grep "Model Family" | awk '{print $3, $4, $5}')"
serial="$(smartctl -i /dev/"$drive" | grep "Serial Number" | awk '{print $3}')"
size="$(blockdev --getsize64 /dev/"$drive")"
sizefinal=$(($size / 1000000000))
echo $sizefinal
echo ""
echo "########## SMART status report for ${drive} drive (${brand}: ${serial}) [$sizefinal GB] ##########"
echo ""
smartctl -c /dev/"$drive"
)
done
#Ask test length
read -p "Execute test [Short or Long] or Quit ? " prompt_test
case $prompt_test in
[sS] | [sS][hH][oO][rR][tT] )
echo "Starting short test..."
for drive in $drives
do
(
smartctl -t short /dev/"$drive"
)
done
;;
[lL] | [lL][oO][nN][gG] )
echo "Starting long test..."
for drive in $drives
do
(
smartctl -t short /dev/"$drive"
)
done
;;
[qQ] | [qQ][uU][iI][tT] )
exit
;;
esac