小樱 发表于 2017/11/26 01:03

Linux下centos使用smartctl 检测独立物理服务器SSD硬盘型号和Smart信息 机械磁盘坏道,09通电时间

Linux下centos使用smartctl 检测独立物理服务器SSD硬盘型号和Smart信息 机械磁盘坏道,09通电时间

安装
yum -y install smartmontools


检查磁盘的 Smart 功能是否启用,/dev/sda为你的磁盘,一般都是这个,可以通过df -h查看输出的磁盘是什么。
smartctl -i /dev/sda


返回如下信息
smartctl 5.43 2016-09-28 r4347 (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Model Family:   Western Digital Blue
Device Model:   WDC WD10EZEX-08WN4A0
Serial Number:    WD-WCC6Y4FCKJ0U
LU WWN Device Id: 5 0014ee 2643ffa4a
Firmware Version: 01.01A01
User Capacity:    1,000,204,886,016 bytes
Sector Sizes:   512 bytes logical, 4096 bytes physical
Device is:      In smartctl database
ATA Version is:   8
ATA Standard is:ACS-3 (unknown minor revision code: 0x001f)
Local Time is:    Sat Nov 25 11:35:41 2017 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled


上面输出中的最后两行显示了SMART功能已启用
根据你的需求进行选择是否启用或者禁用SMART功能。
启用磁盘的 Smart 功能
smartctl -s on /dev/sda

禁用磁盘的 Smart 功能
smartctl -s off /dev/sda


显示通电时间
smartctl -a /dev/sda | grep Power_On_Hours


显示磁盘信息,一个IDE,一个SATA,看哪个能用就哪个,输出内容是一样的
smartctl -a /dev/sda

smartctl -a -d ata /dev/sda


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

General SMART Values:
Offline data collection status:(0x85)        Offline data collection activity
                                        was aborted 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:                 (11100) 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:        ( 115) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.
SCT capabilities:              (0x3035)        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      UPDATEDWHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate   0x002f   200   200   051    Pre-failAlways       -       0
3 Spin_Up_Time            0x0027   100   253   021    Pre-failAlways       -       0
4 Start_Stop_Count      0x0032   100   100   000    Old_age   Always       -       1
5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-failAlways       -       0
7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       1423
10 Spin_Retry_Count      0x0032   100   253   000    Old_age   Always       -       0
11 Calibration_Retry_Count 0x0032   100   253   000    Old_age   Always       -       0
12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       1
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       0
193 Load_Cycle_Count      0x0032   200   200   000    Old_age   Always       -       21
194 Temperature_Celsius   0x0022   115   112   000    Old_age   Always       -       28
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector0x0032   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   100   253   000    Old_age   Offline      -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
NumTest_Description    Status                  RemainingLifeTime(hours)LBA_of_first_error
# 1Short offline       Completed without error       00%      1423         -
# 2Short offline       Completed without error       00%      1423         -
# 3Extended offline    Aborted by host               90%      1423         -

SMART Selective self-test log data structure revision number 1
SPANMIN_LBAMAX_LBACURRENT_TEST_STATUS
    1      0      0Not_testing
    2      0      0Not_testing
    3      0      0Not_testing
    4      0      0Not_testing
    5      0      0Not_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.



显示磁盘总体自检健康状况,例如查看坏扇区数量,显示FAILED就要注意啦
smartctl -H /dev/sda

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


手动使用long和short选项测试硬盘坏道
long完整测试,预计大概115分钟,测试结果后台自动执行,过一段时间查看即可。
smartctl --test=long /dev/sda 2>&1 | tee long.log

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 115 minutes for test to complete.
Test will complete after Sat Nov 25 13:42:37 2017

Use smartctl -X to abort test.


Short快速测试,预计大概2分钟,测试结果后台自动执行,过一段时间查看即可。
smartctl --test=short /dev/sda 2>&1 | tee short.log

=== 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 2 minutes for test to complete.
Test will complete after Sat Nov 25 11:55:30 2017

Use smartctl -X to abort test.


查看驱动器的自检测试坏道结果
smartctl -l selftest /dev/sda

=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
NumTest_Description    Status                  RemainingLifeTime(hours)LBA_of_first_error
# 1Short offline       Completed without error       00%      1423         -
# 2Extended offline    Aborted by host               90%      1423         -



计算测试时间估值
smartctl -c /dev/sda

=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status:(0x85)        Offline data collection activity
                                        was aborted 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:                 (11100) 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:        ( 115) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.
SCT capabilities:              (0x3035)        SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.


显示磁盘错误日志
smartctl -l error /dev/sda

=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
No Errors Logged


不可名 发表于 2017/11/26 13:58

标·{:3001:}
页: [1]
查看完整版本: Linux下centos使用smartctl 检测独立物理服务器SSD硬盘型号和Smart信息 机械磁盘坏道,09通电时间