More simple and reliable way
This commit is contained in:
parent
357c7120c6
commit
3ef9a9376a
34
fixBlocks.sh
34
fixBlocks.sh
@ -5,35 +5,25 @@
|
|||||||
#ACHTUNG! данные на диске могут быть утеряны!
|
#ACHTUNG! данные на диске могут быть утеряны!
|
||||||
#Написано для диска sdba с одним разделом sdb1 на весь диск
|
#Написано для диска sdba с одним разделом sdb1 на весь диск
|
||||||
|
|
||||||
DISK="/dev/sdb"
|
DISK="/dev/sda"
|
||||||
|
|
||||||
block=$(smartctl --all $DISK | grep 'Short offline' | grep '# 1' | awk '{print $10}')
|
block=$(sudo smartctl --all $DISK | grep 'Short offline' | head -1 | awk '{print $10}')
|
||||||
echo "Fixing: " $block
|
echo "Fixing: " $block
|
||||||
|
|
||||||
calcForm="(($block-2048)*512)/4096"
|
sudo hdparm --read-sector $block $DISK
|
||||||
|
sudo hdparm --repair-sector $block --yes-i-know-what-i-am-doing $DISK
|
||||||
|
sudo hdparm --read-sector $block $DISK
|
||||||
|
|
||||||
ddblock=$(echo $calcForm | bc)
|
sudo smartctl -t short $DISK -q errorsonly
|
||||||
|
|
||||||
#echo '(($block-2048)*512)/4096'
|
while `sudo smartctl -a $DISK | grep -q 'Self_test_in_progress'`
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
echo "seek (dd): " $ddblock
|
sleep 20
|
||||||
dd if=/dev/random of=$DISK'1' bs=4096 count=1 seek=$block
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
let ddblock+=1
|
|
||||||
echo "seek (dd): " $ddblock
|
|
||||||
dd if=/dev/random of=$DISK'1' bs=4096 count=1 seek=$block
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
let ddblock-=2
|
|
||||||
echo "seek (dd): " $ddblock
|
|
||||||
dd if=/dev/random of=$DISK'1' bs=4096 count=1 seek=$block
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
smartctl -t short $DISK -q errorsonly
|
|
||||||
sleep 10
|
|
||||||
echo "New badblock: "
|
echo "New badblock: "
|
||||||
smartctl --all $DISK | grep 'Short offline' | grep '# 1' | awk '{print $10}'
|
sudo smartctl --all $DISK | grep 'Short offline' | grep '# 1' | awk '{print $10}'
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user