Smartctl(Self-Monitoring,AnalysisandReportingTechnology)是UNIX和Linux操作系统中执行SMART任务的命令行工具,例如打印SMART自检和错误日志,启用和禁用SMARTAutotest,设备自检。Smartctl在物理Linux服务器上很有用,可以检查智能磁盘是否有错误和坏扇区,并提取有关在硬件RAID后面使用的磁盘的信息。为Ubuntu系统安装Smartctl$sudoapt-getinstallsmartmontools对于Redhat/CentOS系统#yuminstallsmartmontools为Ubuntu系统启动Smartctl服务$sudo/etc/init.d/smartmontoolsstart对于CentOS/RHEL系统#servicesmartdstart;chkconfigsmartdon(1)查看硬盘是否有SmartCapability功能root@linuxtechi:~#smartctl-i/dev/sdbsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](localbuild)版权所有(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===信息部分开始===型号系列:希捷Momentus5400.6设备型号:ST9320325AS序列号:5VD2V59TLUWWN设备ID:5000a37Becware0202容量:320,072,933,376字节[320GB]扇区大小:512字节逻辑/物理旋转速率:5400rpm设备是:在smartctl数据库中[有关详细信息,请使用:-Pshow]ATA版本是:ATA8-ACST13/1699-D修订版是4SATA版本:SATA2.6,1.5Gb/s本地时间:SunNov1612:32:092014ISTSMART支持:可用-设备具有SMART功能。SMART支持:已启用其中“/dev/sdb”是您的硬盘。上面输出中的最后两行显示设备启用了SMART功能。(2)启动硬盘的SmartCapabilityroot@linuxtechi:~#smartctl-son/dev/sdbsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](本地构建)版权所有(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===启用/禁用命令部分开始===启用SMART。(3)禁止使用硬盘的智能能力功能root@linuxtechi:~#smartctl-soff/dev/sdbsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](localbuild)Copyright(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===启用/禁用命令部分开始===SMART已禁用。使用带有参数'on'的选项-s来启用它。(4)显示硬盘Smart的详细信息root@linuxtechi:~#smartctl-a/dev/sdb//ForIDEdriveroot@linuxtechi:~#smartctl-a-data/dev/sdb//对于SATA驱动器(5)显示整体磁盘健康状况root@linuxtechi:~#smartctl-H/dev/sdbsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](本地构建)版权所有(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===开始阅读智能数据部分===SMART整体健康自我评估测试结果:通过警告:此结果基于属性检查.please注意以下边际属性:id#attribute_name标志值最差的阈值类型更新时已更新时_failedraw_value190airflow_temperature_temperature_cel0x0022045045045045old_ageoldofind_past始终in_the_past33(min/max25/33)(最大25/33)(6)(6)(6)(6)(6)LongTestroot@linuxtechi:~#smartctl--test=long/dev/sdbsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](本地构建)版权所有(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===离线立即和自检部分开始===发送命令:“在离线模式下立即执行SMART扩展自检程序”。驱动命令“执行SMART扩展立即在离线模式下进行自检程序”成功。测试已经开始。请等待102分钟测试完成。测试将在SunNov1614:29:432014之后完成使用smartctl-X中止测试。或者我们可以重定向测试输出到日志文件,如下图root@linuxtechi:~#smartctl--test=long/dev/sdb>/var/log/long.textShort6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](本地构建)版权所有(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===STARTOFOFFLINEIMMEDIATEANDSELF-TESTSECTION===发送命令:“在离线模式下立即执行SMARTShort自检程序”。驱动命令“在离线模式下立即执行SMART短自检程序”成功。测试已经开始。请等待1分钟以完成测试。测试将在SunNov1612:51:452014之后完成使用smartctl-X中止测试。或root@linuxtechi:~#smartctl--test=short/dev/sdb>/var/log/short.text注意:短测试最多需要2分钟,而长测试没有时间限制,因为它读取并验证整个磁盘的每个段(7)查看硬盘自检结果root@linuxtechi:~#smartctl-lselftest/dev/sdbsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](localbuild)Copyright(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===开始读取智能数据部分===SMART自检日志结构修订号1NumTest_DescriptionStatusRemainingLifeTime(hours)LBA_of_first_error#1ShortofflineCompleted:readfailure90%492210841222#2ExtendedofflineCompleted:readfailure90%492210841222(8)计算执行测试的时间root@linuxtechi:~#smartctl-c/dev/sdbsmartctl6.22013-07-26r38414-linux[x86-3.13.0-32-generic](localbuild)Copyright(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===开始读取智能数据部分===通用智能值:离线数据收集状态:(0x00)离线数据收集活动从未启动。自动离线数据收集:已禁用。自检执行状态:(121)上一次自检已完成,但测试的读取元素失败。完成离线数据收集的总时间:(0)秒。离线数据收集功能:(0x73)SMART立即离线执行。自动离线数据收集开/关支持。根据新命令暂停离线收集。不支持离线表面扫描。支持自测。支持传输自检。支持选择性自检。SMART功能:(0x0003)在进入省电模式之前保存SMART数据。支持SMART自动保存定时器。错误记录功能:(0x01)支持错误记录。通用日志记录supported.Shortself-testroutinerecommendedpollingtime:(1)minutes.Extendedself-testroutinerecommendedpollingtime:(102)minutes.Conveyanceself-testroutinerecommendedpollingtime:(2)minutes.SCTcapabilities:(0x103b)SCT状态支持的。支持SCT错误恢复控制。支持SCT特征控制。支持SCT数据表。(9)显示磁盘的错误日志root@linuxtechi:~#smartctl-lerror/dev/sdbSampleOutputsmartctl6.22013-07-26r3841[x86_64-linux-3.13.0-32-generic](localbuild)版权所有(C)2002-13,BruceAllen,ChristianFranke,www.smartmontools.org===开始读取智能数据部分===SMART错误日志版本:1ATA错误计数:5CR=命令寄存器[HEX]FR=功能寄存器[HEX]SC=扇区计数寄存器[HEX]SN=扇区号寄存器[HEX]CL=柱面低位寄存器[HEX]CH=柱面高位寄存器[HEX]DH=Device/HeadRegister[HEX]DC=DeviceCommandRegister[HEX]ER=Errorregister[HEX]ST=Statusregister[HEX]Powered_Up_Time从通电开始测量,打印为DDd+hh:mm:SS.sss其中DD=天,hh=小时,mm=分钟,SS=秒,sss=毫秒。它在49.710天后“回绕”。导致错误的命令的命令是:CRFRSCSNCLCHDHDCPowered_Up_Time命令/Feature_Name---------------------------------------------------25da08e7e5a54c0000:30:44.515读取DMAEXT25da08dfe5a54c0000:30:44.514读取DMAEXT25da805fe5a54c0000:30:44.502读取DMAEXT25daf05fe6a54c0000:30:44.496读取DMAEXT25da104fe6a54c0000:30:44.383READDMAEXT我的开源项目course-tencent-cloud(酷瓜云课堂-gitee库)course-tencent-cloud(酷瓜云课堂-github库)
