硬盘监控和分析工具:Smartctl
https://linux.cn/article-4682-1.html
Smartctl(S.M.A.R.T 自监控,分析和报告技术)是类Unix系统下实施SMART任务命令行套件或工具,它用于打印SMART自检和错误日志,启用并禁用SMRAT自动检测,以及初始化设备自检。
Smartctl对于Linux物理服务器十分有用,在这些服务器上,可以对智能磁盘进行错误检查,并将与硬件RAID相关的磁盘信息摘录下来。
在本帖中,我们将讨论smartctl命令的一些实用样例。如果你的Linux上海没有安装smartctl,请按以下步骤来安装。

安装 Smartctl
对于 Ubuntu
- $ sudo apt-get install smartmontools
对于 CentOS & RHEL
- # yum install smartmontools
启动Smartctl服务
对于 Ubuntu
- $ sudo /etc/init.d/smartmontools start
对于 CentOS & RHEL
- # service smartd start ; chkconfig smartd on
样例
样例:1 检查磁盘的 Smart 功能是否启用
- root@linuxtechi:~# smartctl -i /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
- Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
- === START OF INFORMATION SECTION ===
- Model Family: Seagate Momentus 5400.6
- Device Model: ST9320325AS
- Serial Number: 5VD2V59T
- LU WWN Device Id: 5 000c50 020a37ec4
- Firmware Version: 0002BSM1
- User Capacity: 320,072,933,376 bytes [320 GB]
- Sector Size: 512 bytes logical/physical
- Rotation Rate: 5400 rpm
- Device is: In smartctl database [for details use: -P show]
- ATA Version is: ATA8-ACS T13/1699-D revision 4
- SATA Version is: SATA 2.6, 1.5 Gb/s
- Local Time is: Sun Nov 16 12:32:09 2014 IST
- SMART support is: Available - device has SMART capability.
- SMART support is: Enabled
这里‘/dev/sdb’是你的硬盘。上面输出中的最后两行显示了SMART功能已启用。
样例:2 启用磁盘的 Smart 功能
- root@linuxtechi:~# smartctl -s on /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
- Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
- === START OF ENABLE/DISABLE COMMANDS SECTION ===
- SMART Enabled.
样例:3 禁用磁盘的 Smart 功能
- root@linuxtechi:~# smartctl -s off /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
- Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
- === START OF ENABLE/DISABLE COMMANDS SECTION ===
- SMART Disabled. Use option -s with argument 'on' to enable it.
样例:4 显示磁盘的详细 Smart 信息
- root@linuxtechi:~# smartctl -a /dev/sdb // For IDE drive
- root@linuxtechi:~# smartctl -a -d ata /dev/sdb // For SATA drive
样例:5 显示磁盘总体健康状况
- root@linuxtechi:~# smartctl -H /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (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
- Warning: This result is based on an Attribute check.
- Please note the following marginal Attributes:
- ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
- 190 Airflow_Temperature_Cel 0x0022 067 045 045 Old_age Always In_the_past 33 (Min/Max 25/33)
样例:6 使用long和short选项测试硬盘
Long测试
- root@linuxtechi:~# smartctl --test=long /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (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 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 102 minutes for test to complete.
- Test will complete after Sun Nov 16 14:29:43 2014
- Use smartctl -X to abort test.
或者,我们可以重定向测试输出到日志文件,就像下面这样
- root@linuxtechi:~# smartctl --test=long /dev/sdb > /var/log/long.text
Short测试
- root@linuxtechi:~# smartctl --test=short /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (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 Nov 16 12:51:45 2014
- Use smartctl -X to abort test.
或
- root@linuxtechi:~# smartctl --test=short /dev/sdb > /var/log/short.text
注意:short测试将花费最多2分钟,而在long测试中没有时间限制,因为它会读取并验证磁盘的每个段。
样例:7 查看驱动器的自检结果
- root@linuxtechi:~# smartctl -l selftest /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (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: read failure 90% 492 210841222
- # 2 Extended offline Completed: read failure 90% 492 210841222
样例:8 计算测试时间估值
- root@linuxtechi:~# smartctl -c /dev/sdb
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
- Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
- === START OF READ SMART DATA SECTION ===
- General SMART Values:
- Offline data collection status: (0x00) Offline data collection activity
- was never started.
- Auto Offline Data Collection: Disabled.
- Self-test execution status: ( 121) The previous self-test completed having
- the read element of the test failed.
- Total time to complete Offline
- data collection: ( 0) 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: ( 102) minutes.
- Conveyance self-test routine
- recommended polling time: ( 2) minutes.
- SCT capabilities: (0x103b) SCT Status supported.
- SCT Error Recovery Control supported.
- SCT Feature Control supported.
- SCT Data Table supported.
样例:9 显示磁盘错误日志
- root@linuxtechi:~# smartctl -l error /dev/sdb
- Sample Output
- smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
- Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
- === START OF READ SMART DATA SECTION ===
- SMART Error Log Version: 1
- ATA Error Count: 5
- CR = Command Register [HEX]
- FR = Features Register [HEX]
- SC = Sector Count Register [HEX]
- SN = Sector Number Register [HEX]
- CL = Cylinder Low Register [HEX]
- CH = Cylinder High Register [HEX]
- DH = Device/Head Register [HEX]
- DC = Device Command Register [HEX]
- ER = Error register [HEX]
- ST = Status register [HEX]
- Powered_Up_Time is measured from power on, and printed as
- DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
- SS=sec, and sss=millisec. It "wraps" after 49.710 days.
- Commands leading to the command that caused the error were:
- CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
- -- -- -- -- -- -- -- -- ---------------- --------------------
- 25 da 08 e7 e5 a5 4c 00 00:30:44.515 READ DMA EXT
- 25 da 08 df e5 a5 4c 00 00:30:44.514 READ DMA EXT
- 25 da 80 5f e5 a5 4c 00 00:30:44.502 READ DMA EXT
- 25 da f0 5f e6 a5 4c 00 00:30:44.496 READ DMA EXT
- 25 da 10 4f e6 a5 4c 00 00:30:44.383 READ DMA EXT
via: http://www.linuxtechi.com/smartctl-monitoring-analysis-tool-hard-drive/
硬盘监控和分析工具:Smartctl的更多相关文章
- Java虚拟机详解(七)------虚拟机监控和分析工具(1)——命令行
通过前面的几篇博客,我们介绍了Java虚拟机的内存分配以及内存回收等理论知识,了解这些知识对于我们在实际生产环境中提高系统的运行效率是有很大的帮助的.但是话又说回来,在实际生产环境中,线上项目正在运行 ...
- Java虚拟机详解(八)------虚拟机监控和分析工具(2)——可视化
上篇博客我们介绍了虚拟机监控和分析命令行工具,由于其不够直观,不是很容易排查问题,那么本篇博客我们就来介绍几个可视化工具. 1.JConsole JConsole(Java Monitoring an ...
- Linux网络流量监控与分析工具Ntopng
Ntopng工具 Ntopng是一个功能强大的流量监控.端口监控.服务监控管理系统 能够实现高效地监控多台服务器网络 Ntopng功能介绍 Ntop提供了命令行界面和web界面两种工作方式,通过web ...
- 5、JVM的监控与分析工具
一.JPS(虚拟机进程监控工具) 二.jstat:虚拟机统计信息监视工具 例子:jstat -gcutil 16478 s0:区域占比2.33%: s1占比0.00%: E:伊甸园区 : O:老年区: ...
- [转] python运行时内存分析工具meliae
转自:https://my.oschina.net/markco/blog/601773 利用meliae来监控python进程的内存占用情况 meliae是一个python进程内存占用监控.分析工具 ...
- JDK 中的监控与故障处理工具-01
当给系统定位问题的时候, 我们经常需要了解并分析 JVM 的运行时状态 . 那应该从哪些方面入手呢? 答案就是从数据入手 . 这里的数据包括: GC日志,异常堆栈, 线程快照(threaddump) ...
- 【性能测试】服务器性能监控、数据采集工具nmon安装使用详解
nmon nmon是一种在AIX与各种Linux操作系统上广泛使用的监控与分析工具,它能在系统运行过程中实时地捕捉系统资源的使用情况,并且能输出结果到文件中,然后通过nmon_analyzer工具产生 ...
- java虚拟机(八)--java性能监控与故障处理工具
问题定位: 除了个人经验,知识,工具也是很重要的,通过数据进行问题分析,包括:运行日志.异常堆栈.GC日志.线程快照(threaddump/javacore文件 ).堆转储快照(heapdump/hp ...
- linux使用nmon监控、分析系统性能
linux使用nmon监控.分析系统性能 一.概述 nmon是一种在AIX与各种Linux操作系统上广泛使用的监控与分析工具,相对于其它一些系统资源监控工具来说,nmon所记录的信息是比较全面的, ...
随机推荐
- zoj3229 Shoot the Bullet (有源汇最大流)
题目大意:文文要给幻想乡的女♂孩子们拍照,一共n天,m个女♂孩子,每天文文至多拍D[i]张照片,每个女♂孩子总共要被文文至少拍G[i]次.在第i天,文文可以拍c[i]个女♂孩子,c[i]个女♂孩子中每 ...
- 前端开发本地存储之localStorage和sessionStorage
1.localStorage 概念 HTML5 web 存储:HTML5 提供了两种在客户端存储数据的新方式:localStorage 和 sessionStorage ,两者都是仅在客户端(即浏览器 ...
- AT2070 Card Game for Three(组合数学)
传送门 解题思路 前面的思路还是很好想的,就是要枚举最后一个\(a\)在哪出现算贡献,之后我先想的容斥,结果彻底偏了..后来调了很久发现自己傻逼了,似乎不能容斥,终于走上正轨23333.首先可以写出一 ...
- speike
speike 题目描述 众所周知,Speike 狗是一条特别喜欢追着Tom 打的狗. 现在,Tom 又把Speike 惹生气了,现在Speike 需要跨越千山万水找Tom 报仇. Speike 所在的 ...
- python中split()函数的用法
函数:split() Python中有split()和os.path.split()两个函数,具体作用如下:split():拆分字符串.通过指定分隔符对字符串进行切片,并返回分割后的字符串列表(lis ...
- Asynchronous C# server[转]
It hasn't been thoroughly tested, but seems to work OK. This should scale pretty nicely as well. Ori ...
- Oracle 11g 体系结构 --SGA PGA 前后台进程
Oracle服务器主要由实例.数据库.程序全局区.前台进程 实例:用来提供管理数据库的功能 数据库:由Oracle数据库文件组成,用来存储系统数据 ;一般有:数据文件.控制文件.重做日志文件 而实例可 ...
- redux请求数据流程
redux请求数据流程 store里面的index.js文件 import {createStore,combineReducers,applyMiddleware} from "redux ...
- JNDI 笔记
原理: 在DataSource中事先建立多个数据库连接,保存在数据库连接池中.当程序访问数据库时,只用从连接池中取空闲状态的数据库连接即可,访问结束,销毁资源,数据库连接重新回到连接池 ...
- 搜狗拼音、QQ拼音输入法、2345拼音输入法、百度输入法 、手心输入法对比。(个人体会)
搜狗拼音.QQ拼音输入法.2345拼音输入法.百度输入法 .手心输入法对比. 这几个输入法对比的感觉,做个记录.自己记录一下,如果恰巧有朋友也遇到类似的情况,仅供参考. 词库量 搜狗 > 百度 ...