smartctl 显示磁盘错误状态的指示是什么

yae*_*ael 3 linux smartctl disk

当我们在磁盘上运行 smartctl -a 时,我们会得到很多输出

指示磁盘坏或好的最终状态是什么?

smartctl -a /dev/sdb
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               SEAGATE
Product:              ST2000NX0433
Revision:             NS02
User Capacity:        2,000,398,934,016 bytes [2.00 TB]
Logical block size:   512 bytes
Formatted with type 2 protection
Logical block provisioning type unreported, LBPME=0, LBPRZ=0
Rotation Rate:        7200 rpm
Form Factor:          2.5 inches
Logical Unit id:      0x5000c5009eaededf
Serial number:        W46064KW
Device type:          disk
Transport protocol:   SAS
Local Time is:        Thu Nov 22 10:38:35 2018 UTC
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Disabled or Not Supported

=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK

Current Drive Temperature:     23 C
Drive Trip Temperature:        60 C

Manufactured in week 06 of year 2017
Specified cycle count over device lifetime:  10000
Accumulated start-stop cycles:  49
Specified load-unload count over device lifetime:  300000
Accumulated load-unload cycles:  550
Elements in grown defect list: 0

Vendor (Seagate) cache information
  Blocks sent to initiator = 1986603075
  Blocks received from initiator = 2165723528
  Blocks read from cache and sent to initiator = 1298028358
  Number of read and write commands whose size <= segment size = 201615101
  Number of read and write commands whose size > segment size = 0

Vendor (Seagate/Hitachi) factory information
  number of hours powered up = 12335.38
  number of minutes until next internal SMART test = 26

Error counter log:
           Errors Corrected by           Total   Correction     Gigabytes    Total
               ECC          rereads/    errors   algorithm      processed    uncorrected
           fast | delayed   rewrites  corrected  invocations   [10^9 bytes]  errors
read:   26648753        0         0  26648753          0      83475.092           0
write:         0        0         2         2          2     135145.593           0
verify: 3914513941        0         0  3914513941          0     109628.879           0

Non-medium error count:       14

SMART Self-test log
Num  Test              Status                 segment  LifeTime  LBA_first_err [SK ASC ASQ]
     Description                              number   (hours)
# 1  Background short  Completed                  96       2                 - [-   -    -]
Long (extended) Self Test duration: 20400 seconds [340.0 minutes]
Run Code Online (Sandbox Code Playgroud)

剂量以下是良好的指示?

smartctl -a /dev/sda | grep  Completed
Run Code Online (Sandbox Code Playgroud)

或者

 smartctl -a /dev/sda

echo $?
Run Code Online (Sandbox Code Playgroud)

Jür*_*gen 5

整体健康状况是smartctl -a解决全球问题的部分输出

驱动是好是坏?

最好的事物。在您引用的输出中,该状态报告在行中

SMART Health Status: OK

也可以通过使用, 而不是的-H选项单独获得(带有一些标题)。smartctl-a

请注意,此评估不是来自 smartmontools 而是来自驱动器本身(请参阅手册页smartctl(8) on -Hoption)并且其含义相当粗略:请参阅维基百科中的引用:

SMART 状态不一定表示驱动器过去或现在的可靠性。如果驱动器已经发生灾难性故障,则可能无法访问 SMART 状态。或者,如果驱动器过去遇到过问题,但传感器不再检测到此类问题,则根据制造商的编程,SMART 状态可能会提示驱动器现在正常。

和(相同来源):

通过检查 SMART 属性可以获得有关驱动器健康状况的更多详细信息。

整体运行状况由 的退出状态的第 3 位(从 0 开始计数)反映,该位smartctl设置在故障磁盘上。请参阅手册页smartctl(8) 中的“返回值”部分。

在执行之后smartctl,可以通过 (Bash) 表达式评估该位,$(($? & 8))

if [ $(($? & 8)) -eq 0 ]; then
   echo Good.
else
   echo Bad.
fi
Run Code Online (Sandbox Code Playgroud)

请注意,如果设置了第 3 位,则表达式的$(($? & 8))计算结果为 8,而不是 1。

smartctl对于一个健康的磁盘来说,零退出状态就足够了(就 SMART 可以判断的而言),但作为一个条件,这可能太强了:这个状态的第 6 位反映了设备日志中错误记录的存在,这也可能请参阅驱动器和主机之间的通信错误(读取 DMA 错误)。我有几个驱动器,它们的日志自其生命周期的最初几个小时以来就在其日志中显示此类错误,但多年来我每天都使用这些驱动器而没有任何问题。所以这个标准会给你很多误报。当然,这是有争议的,因为毕竟有错误。

总之,如果你想采取所有位,但一个(第6位)考虑在内,您可以使用您的测试这个表达式:$(($? & 191))

另一方面,标准

smartctl -a /dev/sda | grep Completed

您提到的内容并未说明驱动器的健康状况,因为它仅报告自检已完成,而未考虑其结果。