大佬教程收集整理的这篇文章主要介绍了linux – 如何使用hdparm来修复挂起的扇区?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的“smartctl”中的一些信息:
Error 95 occurred at disk power-on lifetime: 20184 hours (841 days + 0 hours) When the command that caused the error occurred,the device was active or idle. After command completion occurred,registers were: ER ST SC SN CL CH DH -- -- -- -- -- -- -- 40 51 00 d7 55 dd 02 Error: UNC at LBA = 0x02dd55d7 = 48059863 Commands leading to the command that caused the error were: CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name -- -- -- -- -- -- -- -- ---------------- -------------------- c8 00 08 d6 55 dd e2 00 18d+05:13:42.421 READ DMA 27 00 00 00 00 00 e0 00 18d+05:13:42.392 READ NATIVE MAX ADDRESS EXT ec 00 00 00 00 00 a0 02 18d+05:13:42.378 IDENTIFY DEVICE ef 03 46 00 00 00 a0 02 18d+05:13:42.355 SET FEATURES [Set transfer mode] 27 00 00 00 00 00 e0 00 18d+05:13:42.327 READ NATIVE MAX ADDRESS EXT smaRT Self-test log structure revision number 1 Num test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Extended offline Completed: read failure 90% 20194 48059863 # 2 Short offline Completed without error 00% 15161 -
有了“糟糕的LBA”(48059863),我该如何使用hdparm?参数“–read-sector”和“–write-sector”应该具有哪种类型的地址?
如果我发出命令hdparm –read-sector 48095863 / dev / sda,它会读取并转储数据.如果这个命令是正确的,我应该期待一个I / O错误,对吗?
相反,它转储数据:
$./hdparm --read-sector 48059863 /dev/sda /dev/sda: reading sector 48059863: succeeded 4b50 5d1b 7563 a932 618d 1f81 4514 2343 8a16 3342 5e36 2591 3b4e 762a 4dd7 037f 6a32 6996 816f 573f eee1 bc24 eed4 206e (...)
您可能更喜欢运行badblocks,hdparm安全擦除(SE)(https://wiki.archlinux.org/index.php/Securely_wipe_disk)或其他一些实际为此设计的工具.甚至制造商也提供像SeaTools这样的工具(有一个32位的linux’企业’版本,谷歌它).
在执行此操作之前,请确保有问题的驱动器完全未使用/未安装.另外,我知道,虽然循环,没有任何借口.这是一个黑客,你可以让它变得更好……
baddrive=/dev/sdb badsect=1 while true; do echo TesTing from LBA $badsect smartctl -t SELEct,${Badsect}-max ${BaddrivE} 2>&1 >> /dev/null echo "WaiTing for test to stop (each dot is 5 seC)" while [ "$(smartctl -l SELEctive ${BaddrivE} | awk '/^ *1/{print substr($4,1,9)}')" != "Completed" ]; do echo -n . sleep 5 done echo badsect=$(smartctl -l SELEctive ${BaddrivE} | awk '/# 1 SELEctive offline Completed: read failure/ {print $10}') [ $badsect = "-" ] && exit 0 echo AttempTing to fix sector $badsect on $baddrive hdparm --repair-sector ${Badsect} --yes-i-kNow-what-i-am-doing $baddrive echo ConTinuning test done
使用’selftest’方法的一个优点是负载由驱动器固件处理,因此它连接的PC不像dd或badblock那样被加载.
while [ "$(smartctl -l SELEctive ${BaddrivE} | awk '/^ *1/{print $4}')" = "Self_test_in_progess" ]; do
并且脚本的退出条件变为:
[ $badsect = "-" ] || [ "$badsect" = "" ] && exit 0
以上是大佬教程为你收集整理的linux – 如何使用hdparm来修复挂起的扇区?全部内容,希望文章能够帮你解决linux – 如何使用hdparm来修复挂起的扇区?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。