1 |
#!/bin/sh -x |
2 |
|
3 |
DRIVE=$1 |
4 |
|
5 |
test -z "$DRIVE" && echo "usage: $0 /dev/sda" && exit |
6 |
|
7 |
smartctl -a $DRIVE > /tmp/smart.0 |
8 |
|
9 |
sector=`smartctl -a $DRIVE | grep 'Completed: read failure' | head -1 | awk '{ print $10 }'` |
10 |
|
11 |
if [ ! -z "$sector" ] ; then |
12 |
|
13 |
echo $sector |
14 |
hdparm --read-sector $sector $DRIVE |
15 |
smartctl -a $DRIVE > /tmp/smart.1 |
16 |
hdparm --write-sector $sector --yes-i-know-what-i-am-doing $DRIVE |
17 |
smartctl -a $DRIVE > /tmp/smart.2 |
18 |
|
19 |
smartctl -t long $DRIVE |
20 |
|
21 |
echo "when smartctl test finishes, re-check your arrays with:" |
22 |
cat /proc/mdstat | grep sdd | cut -d' ' -f1 | xargs -i echo "echo check > /sys/block/{}/md/sync_action" |
23 |
|
24 |
fi |
25 |
|