如何在实践中使用smartctl?

如何在实践中使用smartctl?

我只是随意地smartctl查看我的磁盘,而没有真正深入研究。读完一篇文章后对黑客新闻的评论我决定安排每日短期测试和每周长期测试。

如何真正利用好它们?

当我查看 的结果时smartctl -a /dev/sda,我看到了很多并不是立即显而易见的信息:

# smartctl -a /dev/sda
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-32-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Crucial/Micron MX100/MX200/M5x0/M600 Client SSDs
Device Model:     Crucial_CT500MX200SSD4
Serial Number:    160311862C1C
LU WWN Device Id: 5 00a075 111862c1c
Firmware Version: MU03
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Form Factor:      < 1.8 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-3 T13/2161-D revision 4
SATA Version is:  SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Sep  3 10:49:49 2018 CEST
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:  (0x80) Offline data collection activity
                                        was never started.
                                        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:                ( 1271) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        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:        (   2) minutes.
Extended self-test routine
recommended polling time:        (   7) minutes.
Conveyance self-test routine
recommended polling time:        (   3) minutes.
SCT capabilities:              (0x0035) SCT Status 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     0x002f   100   100   000    Pre-fail  Always       -       0
  5 Reallocate_NAND_Blk_Cnt 0x0032   100   100   010    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       16446
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       44
171 Program_Fail_Count      0x0032   100   100   000    Old_age   Always       -       0
172 Erase_Fail_Count        0x0032   100   100   000    Old_age   Always       -       0
173 Ave_Block-Erase_Count   0x0032   094   094   000    Old_age   Always       -       139
174 Unexpect_Power_Loss_Ct  0x0032   100   100   000    Old_age   Always       -       29
180 Unused_Reserve_NAND_Blk 0x0033   000   000   000    Pre-fail  Always       -       5548
183 SATA_Interfac_Downshift 0x0032   100   100   000    Old_age   Always       -       0
184 Error_Correction_Count  0x0032   100   100   000    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   058   049   000    Old_age   Always       -       42 (Min/Max 23/51)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   100   100   000    Old_age   Always       -       0
202 Percent_Lifetime_Used   0x0030   094   094   001    Old_age   Offline      -       6
206 Write_Error_Rate        0x000e   100   100   000    Old_age   Always       -       0
210 Success_RAIN_Recov_Cnt  0x0032   100   100   000    Old_age   Always       -       0
246 Total_Host_Sector_Write 0x0032   100   100   000    Old_age   Always       -       15420692355
247 Host_Program_Page_Count 0x0032   100   100   000    Old_age   Always       -       481912759
248 Bckgnd_Program_Page_Cnt 0x0032   100   100   000    Old_age   Always       -       1753257160

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     16446         -
# 2  Short offline       Completed without error       00%     10532         -
# 3  Short offline       Completed without error       00%      8040         -
# 4  Vendor (0xff)       Completed without error       00%      3608         -
# 5  Vendor (0xff)       Completed without error       00%       597         -
# 6  Vendor (0xff)       Completed without error       00%       585         -
# 7  Vendor (0xff)       Completed without error       00%       520         -
# 8  Vendor (0xff)       Completed without error       00%       161         -
# 9  Vendor (0xff)       Completed without error       00%        98         -
#10  Vendor (0xff)       Completed without error       00%        65         -

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  Completed [00% left] (57881389-57946924)
    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.

具体来说,没有明确的指示

  • 错误
  • 测试历史

smartctl -a /dev/sdX除了不时运行并希望识别任何异常事件之外,是否有最佳分析实践?

答案1

如果您已配置智能监控工具这样它就可以向您发送电子邮件,如果它发现问题,您就会收到电子邮件。

除此之外,错误和日志在smartctl的输出中可见。我倾向于首先查看“Offline_Un Correctable”字段,因为非零意味着介质中存在驱动器无法执行任何操作的缺陷(在您的情况下,使用 SSD,通常意味着驱动器已运行对于已死亡的电池,无法更换闪存)。其他属性指示读取或写入错误,但其重要性可能取决于错误的原因。

驱动器错误也会记录在错误日志中:

SMART Error Log Version: 1
No Errors Logged

以及测试日志中的测试结果:

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%     16446         -
# 2  Short offline       Completed without error       00%     10532         -
# 3  Short offline       Completed without error       00%      8040         -
# 4  Vendor (0xff)       Completed without error       00%      3608         -
# 5  Vendor (0xff)       Completed without error       00%       597         -
# 6  Vendor (0xff)       Completed without error       00%       585         -
# 7  Vendor (0xff)       Completed without error       00%       520         -
# 8  Vendor (0xff)       Completed without error       00%       161         -
# 9  Vendor (0xff)       Completed without error       00%        98         -
#10  Vendor (0xff)       Completed without error       00%        65         -

在这里,您希望测试标记为“已完成,没有错误”,其寿命字段与驱动器的当前寿命不太远(取决于测试计划)。在您的情况下,驱动器的使用寿命为 16446 小时,并且您刚刚完成了测试。您还希望定期查看扩展的离线测试,因为那时某些属性会更新(例如离线无法纠正)。

我倾向于使用smartctl -x而不是smartctl -a,它显示更多信息。

答案2

智能技术大约十几年前开始在磁盘上使用,在内部记录表面上的潜在问题。您正在使用基于完全不同技术的 SSD 磁盘(以前称为电可擦除可编程 ROM)。数据被写入磁盘上称为扇区的块中,而在 SSD 上,数据被写入更大的块中,并且在写入块(实际上是编程)之前必须将其擦除。擦除块会对块元素造成轻微损坏,因此固件会尝试将写入(=擦除=损坏)均匀地分布在所有块上,因为对同一块的写入量是有限的(SLC大约100000次,MLC大约100000次) 5000次,TLC约300次而已)。

嗯,报告的错误对于这smartctl两种基本技术都有其他含义。在磁盘上,您需要检查Current_Pending_Sector什么表明写入错误(无法读取)数据(ID 197)和Reallocated_sector_countID 5)什么表明磁性表面不良以及ID 194 Temperature_Celsius。在 SSD 中,它ID 5被重命名为Reallocate_NAND_Blk_Cnt显示生命周期之外的块数。

在这两种情况下,仅仅存在一些坏块(扇区)并不一定意味着磁盘已损坏。问题可能是突然出现大量故障块,也可能是故障块的数量与日俱增。

通过仔细选择适合预期用途的良好品牌和类型(服务器 24x7、台式机、录像机)并为其提供尽可能好的条件(用于降低温度的风扇、足够的功率),可以延长磁盘的使用寿命,严格水平或垂直位置)。

SSD磁盘的寿命可以通过选择SLC来延长(更慢但更好)——现在你只能购买MLC,但即使是那些也可以比TLC寿命更长。并对不必要的写入进行任何可能的限制。因此,您必须将交换(pagefile.sys)移出磁盘作为用户目录(homes)和日志文件。在 Linux 中,您可以额外添加 noatime、nodiratime 挂载选项。并且经常做好备份!定期检查智能手机可能会有所帮助,但无法找回丢失的数据。

相关内容