SHARE
TWEET

Untitled

a guest Jul 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. baddrive=/dev/sda
  2. badsect=1
  3. while true; do
  4.   echo Testing from LBA $badsect
  5.   smartctl -t select,${badsect}-max ${baddrive} 2>&1 >> /dev/null
  6.  
  7.   echo "Waiting for test to stop (each dot is 5 sec)"
  8.   while [ "$(smartctl -l selective ${baddrive} | awk '/^ *1/{print $4}')" = "Self_test_in_progess" ]; do
  9.     echo -n .
  10.     sleep 5
  11.   done
  12.   echo
  13.  
  14.   badsect=$(smartctl -l selective ${baddrive} | awk '/# 1  Selective offline   Completed: read failure/ {print $10}')
  15.   [ $badsect = "-" ] || [ "$badsect" = "" ] && exit 0
  16.  
  17.   echo Attempting to fix sector $badsect on $baddrive
  18.   hdparm --repair-sector ${badsect} --yes-i-know-what-i-am-doing $baddrive
  19.   echo Continuning test
  20. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top