在 CentOS 7.x 上使用 smartd 服務

為了能更精確掌握硬碟的健康狀態,免得最後硬碟出現問題,不能用時才做處理,所以使用 smartd 服務。
參考網頁:
Smartctl – Monitoring & Analysis tool for Hard drive
Install SMART on CentOS 6.4 | Zwiegnet Blog
Linux 下用 smartd 监测硬盘状况 | vpsee.com

1. 安裝 smartmontools 套件
# yum install smartmontools

2. 啟動 smartd 服務及設定開機時啟動
# systemctl start smartd.service
# systemctl enable smartd.service[@more@]3. 檢查 smartd 服務狀態
# systemctl status smartd.service
● smartd.service – Self Monitoring and Reporting Technology (SMART) Daemon
   Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled; vendor preset: enabled)
   Active: active (running) since 日 2016-08-14 13:45:13 CST; 33s ago
 Main PID: 2712 (smartd)
   CGroup: /system.slice/smartd.service
           mq2712 /usr/sbin/smartd -n -q never

 8月 14 13:45:13 localhost.localdomain systemd[1]: Starting Self Monitoring and Reporting Technology (SMART) Daemon…
 8月 14 13:45:13 localhost.localdomain smartd[2712]: smartd 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.28.2.el7.x86_64] (local build)
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Opened configuration file /etc/smartmontools/smartd.conf
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Configuration file /etc/smartmontools/smartd.conf was parsed, found DEVICESCAN, scanning devices
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Device: /dev/sda, opened
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Device: /dev/sda, [VMware,  VMware Virtual S 1.0 ], 21.4 GB
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Device: /dev/sda, IE (SMART) not enabled, skip device
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Try ‘smartctl -s on /dev/sda’ to turn on SMART features
 8月 14 13:45:13 localhost.localdomain smartd[2712]: Monitoring 0 ATA and 0 SCSI devices

4. 檢查硬碟資訊
# smartctl -i /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.28.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     TS128GSSD370S
Serial Number:    xxxxx
Firmware Version: xxxxx
User Capacity:    128,035,676,160 bytes [128 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sun Aug 14 13:49:10 2016 CST
SMART support is: Available – device has SMART capability.
SMART support is: Enabled

5. 顯示更詳盡的硬碟資訊
# smartctl -a -d ata /dev/sdb
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.28.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     ST4000VN000-2AH166
Serial Number:    xxxxx
LU WWN Device Id: xxxxx
Firmware Version: xxxxx
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5980 rpm
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 (unknown minor revision code: 0x006d)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sun Aug 14 13:52:53 2016 CST
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:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
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:                (  591) seconds.
Offline data collection
capabilities:                    (0x73) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        No 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:        (   1) minutes.
Extended self-test routine
recommended polling time:        ( 637) minutes.
Conveyance self-test routine
recommended polling time:        (   2) minutes.
SCT capabilities:              (0x50bd) SCT Status supported.
                                        SCT Error Recovery Control supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   073   070   044    Pre-fail  Always       –       20940518
  3 Spin_Up_Time            0x0003   095   095   000    Pre-fail  Always       –       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       –       6
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       –       0
  7 Seek_Error_Rate         0x000f   064   060   045    Pre-fail  Always       –       2719493
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       –       14 (58 128 0)
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       –       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       –       6
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       –       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       –       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       –       0
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       –       0
190 Airflow_Temperature_Cel 0x0022   065   058   040    Old_age   Always       –       35 (Min/Max 29/35)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       –       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       –       2
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       –       24
194 Temperature_Celsius     0x0022   035   042   000    Old_age   Always       –       35 (0 27 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       –       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      –       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       –       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      –       276698973077514
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      –       6425312
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      –       8038850139

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.

6. 檢查硬碟狀況
# smartctl -H  /dev/sdb
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.28.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

7. 進行快速檢查
# smartctl -t short /dev/sdb
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.28.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: “Execute SMART Short self-test routine immediately in off-line mode”.
Drive command “Execute SMART Short self-test routine immediately in off-line mode” successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Sun Aug 14 13:59:57 2016

Use smartctl -X to abort test.

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

=== START OF READ SMART DATA SECTION ===
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%        14         –

設定檔
/etc/smartmontools/smartd.conf