From ee5ebb5768e27968857a81fee2b625991365016d Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 28 Dec 2011 23:39:34 +0000 Subject: [PATCH] relocated failed sector using hdparm git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@285 191e9f34-6774-4a6d-acfc-7664dacd4a2a --- recepies/smart/smart-relocate-sector.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 recepies/smart/smart-relocate-sector.sh diff --git a/recepies/smart/smart-relocate-sector.sh b/recepies/smart/smart-relocate-sector.sh new file mode 100755 index 0000000..3a3ce0e --- /dev/null +++ b/recepies/smart/smart-relocate-sector.sh @@ -0,0 +1,25 @@ +#!/bin/sh -x + +DRIVE=$1 + +test -z "$DRIVE" && echo "usage: $0 /dev/sda" && exit + +smartctl -a $DRIVE > /tmp/smart.0 + +sector=`smartctl -a $DRIVE | grep 'Completed: read failure' | head -1 | awk '{ print $10 }'` + +if [ ! -z "$sector" ] ; then + + echo $sector + hdparm --read-sector $sector $DRIVE + smartctl -a $DRIVE > /tmp/smart.1 + hdparm --write-sector $sector --yes-i-know-what-i-am-doing $DRIVE + smartctl -a $DRIVE > /tmp/smart.2 + + smartctl -t long $DRIVE + + echo "when smartctl test finishes, re-check your arrays with:" + cat /proc/mdstat | grep sdd | cut -d' ' -f1 | xargs -i echo "echo check > /sys/block/{}/md/sync_action" + +fi + -- 2.20.1