Smartmontools是一种硬盘检测工具,通过控制和管理硬盘的SMART(Self Monitoring Analysis and Reporting Technology),自动检测分析及报告技术)技术来实现的,SMART技术可以对硬盘的磁头单元、盘片电机驱动系统、硬盘内部电路以及盘片表面介质材料等进行监测,当SMART监测并分析出硬盘可能出现问题时会及时向用户报警以避免计算机数据受损失。SMART技术必须在主板支持的前提下才能发生作用,而且SMART技术也不能保证能预报所有可能发生的硬盘故障。Windows没有内置SMART相关工具,需要安装第三方工具软件,vmware虚拟机的硬盘不支持SMART,Linux上很早就有了SMART支持了,可以yum命令安装该工具即可,smartctl是Smartmontools工具安装之后的可执行命令,我们通过此命令可以查看磁盘是否支持smart检测,执行smart检测等。
[root@s186 /]# yum install -y smartmontools
[root@s186 /]# smartctl -i /dev/sda
#Enabled表示启用了SMART #Available表示硬盘支持SMART
[root@s210 ~]# smartctl –smart=on –offlineauto=on –saveauto=on /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.el7.x86_64] (local build) Copyright © 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF ENABLE/DISABLE COMMANDS SECTION === SMART Enabled. SMART Attribute Autosave Enabled. SMART Automatic Offline Testing Enabled every four hours.
[root@s210 ~]# smartctl -a /dev/sda
[root@s210 ~]# smartctl -H /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.el7.x86_64] (local build) Copyright © 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED #请注意result后边的结果:PASSED,这表示硬盘健康状态良好,如果这里显示Failure,那么最好立刻给服务器更换硬盘。
[root@s210 ~]# smartctl -A /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.el7.x86_64] (local build) Copyright © 2002-18, 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 142 142 054 Pre-fail Offline – 68 3 Spin_Up_Time 0x0007 122 122 024 Pre-fail Always – 185 (Average 189) 4 Start_Stop_Count 0x0012 100 100 000 Old_age Always – 715 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 115 115 020 Pre-fail Offline – 34 9 Power_On_Hours 0x0012 099 099 000 Old_age Always – 12687 10 Spin_Retry_Count 0x0013 100 100 060 Pre-fail Always – 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always – 372 192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always – 830 193 Load_Cycle_Count 0x0012 100 100 000 Old_age Always – 830 194 Temperature_Celsius 0x0002 193 193 000 Old_age Always – 31 (Min/Max 7/41) 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
[root@s210 ~]# smartctl -l error /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.el7.x86_64] (local build) Copyright © 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART Error Log Version: 1 No Errors Logged
[root@s210 ~]# smartctl –test=long /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.el7.x86_64] (local build) Copyright © 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === 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 119 minutes for test to complete. Test will complete after Tue Oct 12 17:14:21 2021 Use smartctl -X to abort test.
(base) [root@s186 /]# smartctl -C -t short /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-957.5.1.el7.x86_64] (local build) Copyright © 2002-18, 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 captive mode”. Drive command “Execute SMART Short self-test routine immediately in captive mode” successful. Testing has begun. Please wait 1 minutes for test to complete. Test will complete after Tue Oct 12 16:03:19 2021
[root@s210 ~]# smartctl -X /dev/sda smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1062.el7.x86_64] (local build) Copyright © 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: “Abort SMART off-line mode self-test routine”. Self-testing aborted!
(base) [root@s186 /]# smartctl -l selftest /dev/sda
#smartctl [options] device
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/184514.html原文链接:https://javaforall.cn