检查SMART是否可用

使用“-i”选项运行SmartCtl实用程序,查看s.m.a.r.t是否启用:

$sudo smartctl -i /dev/sda

命令的输出如下:

=== START OF INFORMATION SECTION ===
Model Family:     Western Doirtal Red
Device Model:     WDC WD10EFRX-68FYTN0
LU WWN Device Id: 5 0014ee 20c672def
Firmware Version: 82.00A82
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Thu Sep 24 18:13:19 2016 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Disabled

我们可以看到显示基本信息,例如设备系列,模型,扇区大小等。
然而,我们最兴趣的是最后两行的内容。

Linux 启用硬盘SMART:

$sudo smartctl -s on /dev/sda
smartctl 6.6 2015-11-05 r4594 [armv6l-linux-5.4.51+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

安装smartmontools

在Debian和ubuntu上:

$sudo apt-get update && sudo apt-get install smartmontools

在Red Hat Enterprise Linux,CentOS和Fedora上,我们可以使用DNF:

$sudo dnf install smartmontools

Archlinux系统可以使用Pacman:

$sudo pacman -S smartmontools
如何使用SmartCTL检查硬盘状态

smartmontools包通常在所有主要Linux发行版的默认存储库中提供。它包含两个实用程序,用于通过S.M.A.R.T支持(自我监控分析和报告技术)检查存储状态:smartcl和smartd。前者是我们直接用于检查S.M.A.R.T属性、运行测试或者执行其他操作的实用程序;后者是后台进程,可用于在后台调度操作。

smartctl

要获取有关存储设备的所有可用智能信息,我们可以使用-a--all的缩写)选项启动实用程序。

检查/dev/sda设备的当前状态:

$sudo smartctl -a /dev/sda

上面的命令产生了大量的输出。
我们可以看到各种智能参数的状态:

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   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   135   125   021    Pre-fail  Always       -       4216
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       941
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   085   085   000    Old_age   Always       -       11285
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       446
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       108
193 Load_Cycle_Count        0x0032   199   199   000    Old_age   Always       -       4258
194 Temperature_Celsius     0x0022   111   099   000    Old_age   Always       -       32
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   200   200   000    Old_age   Offline      -       0

要检查的非常重要的参数是“RealLocated_sector_ct”和“current_pending_sector”中的。
在这两种情况下,如果raw_value是0以外的东西,我们应该非常小心并开始备份硬盘上的数据。
RealLocated_sector_ct 是块设备上无法正确使用的扇区数。

在输出中,我们还可以看到在设备上执行的测试日志:

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%      9590         
# 2  Short offline       Completed without error       00%      2941         
# 3  Extended offline    Completed without error       00%        21         
# 4  Short offline       Completed without error       00%        18         
# 5  Short offline       Completed without error       00%         0         
# 6  Short offline       Completed without error       00%         0         

在Test_description列中,我们可以看到各种测试运行,并且所有类型的测试都没有错误完成。

日期:2020-07-07 20:56:10 来源:oir作者:oir