第三节. smartctl用法
基本用法
扫描当前系统中所有支持SMART的设备
$ sudo smartctl --scan
/dev/sda -d scsi # /dev/sda, SCSI device
查看设备SMART是否开启
sudo smartctl -i /dev/sda
...
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
将设备SAMRT开启
$ sudo smartctl -s on /dev/sda
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
仅显示设备的所有SMART属性信息
$ sudo smartctl -a /dev/sda
显示设备的所有属性信息
$ sudo smartclt -x /dev/sda
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x84) Offline data collection activity
was suspended by an interrupting command from host.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
...
查看设备的自检评估结果
$ sudo smartctl -H /dev/sda
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
简单用法
smartctl -a
smartctl -s on
smartctl -t short
smartctl -t long
smartctl -C -t short
smartctl -C -t long
smartctl -X
smartctl -l selftest
smartctl -l error
smartctl -A
SMART属性解析
输出SMART属性
sudo smartctl --all /dev/sda
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-38-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Hitachi Ultrastar A7K1000
Device Model: Hitachi HUA721050KLA330
Serial Number: GTF402P6GX1P5F
LU WWN Device Id: 5 000cca 214ccc0b5
Firmware Version: GK6OAB0A
User Capacity: 500,107,862,016 bytes [500 GB]
Sector Size: 512 bytes logical/physical
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA/ATAPI-7 T13/1532D revision 1
Local Time is: Thu Oct 13 12:38:45 2016 HKT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x84) Offline data collection activity
was suspended by an interrupting command from host.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 8579) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 143) minutes.
SCT capabilities: (0x003f) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 016 Pre-fail Always - 0
2 Throughput_Performance 0x0005 130 130 054 Pre-fail Offline - 152
3 Spin_Up_Time 0x0007 143 143 024 Pre-fail Always - 390 (Average 309)
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 490
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 134 134 020 Pre-fail Offline - 32
9 Power_On_Hours 0x0012 096 096 000 Old_age Always - 32582
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 490
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 721
193 Load_Cycle_Count 0x0012 100 100 000 Old_age Always - 721
194 Temperature_Celsius 0x0002 125 125 000 Old_age Always - 48 (Min/Max 16/60)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
各项 SMART 属性
sudo smartctl -A /dev/sda
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-38-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000b 100 100 016 Pre-fail Always - 0
2 Throughput_Performance 0x0005 130 130 054 Pre-fail Offline - 152
3 Spin_Up_Time 0x0007 143 143 024 Pre-fail Always - 390 (Average 309)
4 Start_Stop_Count 0x0012 100 100 000 Old_age Always - 490
5 Reallocated_Sector_Ct 0x0033 100 100 005 Pre-fail Always - 0
7 Seek_Error_Rate 0x000b 100 100 067 Pre-fail Always - 0
8 Seek_Time_Performance 0x0005 134 134 020 Pre-fail Offline - 32
9 Power_On_Hours 0x0012 096 096 000 Old_age Always - 32582
10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 490
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 721
193 Load_Cycle_Count 0x0012 100 100 000 Old_age Always - 721
194 Temperature_Celsius 0x0002 125 125 000 Old_age Always - 48 (Min/Max 16/60)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0
ID 属性编号, 从1到255
ATTRIBUTE_NAME 属性名称
FLAGS 标识,K 自动保持 ,C 事件统计, R 错误率, S速度/性能 , O 在线更新, P 故障预警
VALUE 当前Normalized value, 取值范围1到253. 越低表示越差. 越高表示越好
WORST 历史最差值,表示SMART开启以来的, 所有Normalized values的最低值
THRESH 阈值/极限值,当Normalized value小于等于THRESH值时, 表示这项指标已经failed了.
FAIL 已经失效.
RAW_VALUE 物理值(通常对应于计数或物理单位,如扇区个数,摄氏度或秒)
TYPE (简要模式不可见)存在两种类型, Pre-failed(故障预警)和Old_age(正常损耗).
UPDATED (简要模式不可见)存在两种更新模式 Always(持续更新)和 Offline(离线更新)
详细说明
每个驱动器制造商定义了一组属性,并设置阈值制,不同厂商提供的数目不同,有些特定属性具体含义由各个厂商自行定义,支持SMART的制造商包括希捷,日立,富士通,迈拓,东芝,英特尔,STEC公司,西部数据与易拓科技,三星等。
SMART的属性分为Critical Attributes(关键属性)和 Informative attributes(信息属性)两类,其中关键属性包括了有关硬盘健康的最重要的数据,而信息属性所提供的数据一般只是辅助性的。区分它们的方法是看threshold(阈值/极限值),值为非零代表关键属性,为零代表信息属性。
归一化值,从实际的物理属性值转化来的,取值范围为1~253(一般来说 1代表最坏的情况下和253代表最好),根据不同的生产厂家,100或200的值通常是初始标准值。 物理值, 通常对应于计数或物理单位,如扇区个数,摄氏度或时间单位。
S.M.A.R.T检测参数含义:
1.ID检测代码
ID检测代码不是唯一的,厂商可以根据需要,使用不同的ID代码或根据检测参数的多少增减ID代码的数量。例如,西数公司的产品ID检测代码为 “04”,检测的参数是Start/Stop Count(加电次数),而富士通公司同样代码的检测参数却为“Number of times the spindle motor is activated”(电机激活时间)。
2.属性描述(Attribute Name)
属性描述(Attribute Name)即检测项目名称。可由厂商自定义增减,由于ATA标准不断更新,有时候同一品牌的不同型号产品也会有所不同。但必须确保S.M.A.R.T规定的几个主要检测项目(虽然不同厂商对检测项目都有特定的命名规则,但这些监测项目的实质其实是一样的)。
Read Error Rate 错误读取率
Start/Stop Count 启动/停止次数(又称加电次数)
Relocated Sector Count 重新分配扇区数
Spin up Retry Count 旋转重试次数(即硬盘启动重试次数)
Drive Calibration Retry Count 磁盘校准重试次数
ULTRA DMA CRC Error Rate (ULTRA DMA奇偶校验错误率)
Multi-zone Error Rate 多区域错误率
Vendor-specific 厂商特性
需要注意的是,不同厂商、不同类型产品的属性描述不尽相同。对用户而言,无须深入了解它们的具体含义,只需了解属性监测值的含义即可。
3.阈值(Threshold)
又称门限值。是由硬盘厂商指定的可靠的属性值,通过特定公式计算而得。如果有一个属性值低于相应的阈值,就意味着硬盘将变得不可靠,保存在硬盘里的数 据也很容易丢失。可靠属性值的组成和大小对不同硬盘来说是有差异的。这里需要注意的是,ATA标准中只规定了一些S.M.A.R.T参数,它没有规定具体 的数值,“Threshold”的数值是厂商根据自己产品特性而确定的。因此,用厂商自己提供的检测软件往往会跟Windows下的检测软件(例如 AIDA32)的检测结果有较大出入。这里我们推荐以厂商软件的检测结果为标准,因为Windows环境下,系统要求硬盘的启动程序比DOS下多得多, 这可能导致硬盘S.M.A.R.T值比DOS环境下检测的波动更大。以参数Raw ErrorRate(错误读取率)为例:该参数的计算公式为10×log10(主机和硬盘之间所传输数据的扇区数)×512×8/重读的扇区数。其中 “512×8”是把扇区数转化为所传输的数据位(bits),这个值只在所传输的数据位处于10^10~10^12范围时才作计算,而当Windows系 统启动后,主机和硬盘之间所传输的数据扇区大于或等于10^12时,此值将重新复位。这就是为什么有些值在不同的操作环境、不同检测程序下时波动较大的原 因。
4.属性值(Attribute value)
属性值是指硬盘出厂时预设的最大正常值,一般范围为1~253。通常,最大的属性值等于100(适用于IBM、昆腾、富士通)或253(适用于三 星)。当然也有例外的时候,比如由西部数据公司生产的部分型号硬盘,就用了两个不同的属性值,最初生产时属性值设为200,但后来生产的硬盘属性值又改 为100。
5.最大出错值(Worst)
最大出错值是硬盘运行中曾出现过的最大的非正常值。它是对硬盘累计运行的计算值,根据运行周期,该数值会不断地刷新,并且会非常接近阈值。 S.M.A.R.T分析和判定硬盘的状态是否正常,就是根据这个数值和阈值的比较结果而定。新硬盘开始时有最大的属性值,但随着日常使用或出现错误,该值会不断减小。因此较大的属性值意味着硬盘质量较好而且可靠性较高,而较小的属性值则意味着故障发生的可能性增大。
6.实际值(Date)
是硬盘各检测项目运行中的实际数值,很多项目是累计值。例如:Start/Stop Count(启停次数),累计的实际值是436,即该硬盘从开始到现在累计加电启停436次。
7.属性状态(Status)
这是S.M.A.R.T针对前面的各项属性值进行比较分析后,提供的硬盘各属性目前的状态,也是我们直观判断硬盘“健康”状态的重要信息。根据 S.M.A.R.T的规定,这种状态一般有正常、警告和报告故障或错误等3种状态。S.M.A.R.T判定出这3个状态与S.M.A.R.T的 Pre-failure/advisory BIT(预知错误/发现位)参数的赋值密切相关。
当Pre-failure/advisory BIT=0,并且可靠属性值远大于阈值的情况下,为正常提示“OK”标志。当Pre-failure/advisory BITt=0,并且可靠属性值大于阈值但接近阈值临界值时,为警告提示“!”标志;当Pre-failure/advisory BITt=1,并且可靠属性值小于阈值时,为报告故障或错误提示“!!!”标志。
需要特别注意的是:每一个参数所给出的值都是经过一些特定的计算公式而给出的。作为用户,只要观察“Worst”和“Threshold”值的关系,并注意状态提示属性状态信息即可大致了解硬盘的健康状况。
重要的关键属性
一般来说,如果下面这10项指标开始明显变化,说明硬盘开始进入不稳定的状态,甚至有随时停止工作的可能性: 编号 十六进制值 名称 中文名称 最优状态 01 0x01 Read Error Rate 底层数据读取错误率 越低越好 05 0x05 Reallocated Sectors Count 重新分配的扇区统计值 越低越好 10 0x0A Spin Retry Count 起转重试次数 越低越好 184 0xB8 End-to-End error/IOEDC(HP专属) 端到端错误 越低越好 188 0xBC Command Timeout 命令超时 越低越好 196 0xC4 Reallocation Event Count 重映射操作记数 越低越好 197 0xC5 Current Pending Sector Count 当前等待中扇区计数 越低越好 198 0xC6 Offline Uncorrectable 无法修正的扇区总数 越低越好 201 0xC9 Soft Read Error Rate 逻辑读取错误率 越低越好 230 0xE6 Drive Life Protection Statui(Kingston专属) 驱动器寿命保护状态 越越高好
这些参数所代表的一些常见意义
Raw Read Error Rate 这个属性的值取决于读取错误次数,磁盘表面状态和当从磁盘表面读取数据硬件发生读取错误时的比例。即底层硬件读取故障率,值高暗示盘体、磁头有问题。
Spin Up Time 主轴马达从0转速到达正常速度时候所用时间。硬盘从加速到正常转动速度消耗的时间,这段时间不能读写,到正常速度转动速度后才能读写。
start/stop 电机启动和关闭次数
Reallocated Sector Ct 重定位扇区统计,当磁盘上一个扇区发生一个读、写或者校验错误时,它标志着这个扇区需要重新分配,然后将数据写到一个特殊的保留扇区中。这个需要“重新分配”的扇区,应该有坏扇区。一般情况这个值应该为0,如果不为0也不必惊慌,应该密切关注该值的变化。这个参数是值得注意的!
Seek Error Rate 磁盘寻道错误率,每个厂家定义不同,但是不断增高需要留意,表示机械定位系统或者盘体、磁头有故障。
Power On Hours 硬盘从出厂到目前的开电统计时间。根据参考厂家给出的MTBF(平均无故障时间)可以估算出故障概率。
Spin Retry Count 从磁盘马达开始旋转到达到正常转速时,如果发生一次转速失败的统计计数。这种情况一般是硬盘机械子系统出现故障。
Calibration Retry Count 校准重试统计计数,磁盘磁头校准的次数,是因为非法关机或者突然断电导致磁头复位计数加一。写入smart后不能清零。
Power Cycle Count 硬盘加电次数总和,这个没什么说的
Power-off Retract Count 磁头在没有加电时不移进硬盘的值统计。
Temperature Celsius 硬盘的环境温度
Reallocated Event Count 重映射次数统计,表示坏扇区较多。增加需要注意
Current Pending Sector Count 未使用到的扇区重置