Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement