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

  1. $ sudo apt-get install smartmontools

对于 CentOS & RHEL

  1. # yum install smartmontools

启动Smartctl服务

对于 Ubuntu

  1. $ sudo /etc/init.d/smartmontools start

对于 CentOS & RHEL

  1. # service smartd start ; chkconfig smartd on

样例

样例:1 检查磁盘的 Smart 功能是否启用

  1. root@linuxtechi:~# smartctl -i /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF INFORMATION SECTION ===
  5. Model Family: Seagate Momentus 5400.6
  6. Device Model: ST9320325AS
  7. Serial Number: 5VD2V59T
  8. LU WWN Device Id: 5 000c50 020a37ec4
  9. Firmware Version: 0002BSM1
  10. User Capacity: 320,072,933,376 bytes [320 GB]
  11. Sector Size: 512 bytes logical/physical
  12. Rotation Rate: 5400 rpm
  13. Device is: In smartctl database [for details use: -P show]
  14. ATA Version is: ATA8-ACS T13/1699-D revision 4
  15. SATA Version is: SATA 2.6, 1.5 Gb/s
  16. Local Time is: Sun Nov 16 12:32:09 2014 IST
  17. SMART support is: Available - device has SMART capability.
  18. SMART support is: Enabled

这里‘/dev/sdb’是你的硬盘。上面输出中的最后两行显示了SMART功能已启用。

样例:2 启用磁盘的 Smart 功能

  1. root@linuxtechi:~# smartctl -s on /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF ENABLE/DISABLE COMMANDS SECTION ===
  5. SMART Enabled.

样例:3 禁用磁盘的 Smart 功能

  1. root@linuxtechi:~# smartctl -s off /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF ENABLE/DISABLE COMMANDS SECTION ===
  5. SMART Disabled. Use option -s with argument 'on' to enable it.

样例:4 显示磁盘的详细 Smart 信息

  1. root@linuxtechi:~# smartctl -a /dev/sdb // For IDE drive
  2. root@linuxtechi:~# smartctl -a -d ata /dev/sdb // For SATA drive

样例:5 显示磁盘总体健康状况

  1. root@linuxtechi:~# smartctl -H /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF READ SMART DATA SECTION ===
  5. SMART overall-health self-assessment test result: PASSED
  6. Warning: This result is based on an Attribute check.
  7. Please note the following marginal Attributes:
  8. ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
  9. 190 Airflow_Temperature_Cel 0x0022 067 045 045 Old_age Always In_the_past 33 (Min/Max 25/33)

样例:6 使用long和short选项测试硬盘

Long测试

  1. root@linuxtechi:~# smartctl --test=long /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
  5. Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
  6. Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
  7. Testing has begun.
  8. Please wait 102 minutes for test to complete.
  9. Test will complete after Sun Nov 16 14:29:43 2014
  10. Use smartctl -X to abort test.

或者,我们可以重定向测试输出到日志文件,就像下面这样

  1. root@linuxtechi:~# smartctl --test=long /dev/sdb > /var/log/long.text

Short测试

  1. root@linuxtechi:~# smartctl --test=short /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
  5. Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
  6. Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
  7. Testing has begun.
  8. Please wait 1 minutes for test to complete.
  9. Test will complete after Sun Nov 16 12:51:45 2014
  10. Use smartctl -X to abort test.

  1. root@linuxtechi:~# smartctl --test=short /dev/sdb > /var/log/short.text

注意:short测试将花费最多2分钟,而在long测试中没有时间限制,因为它会读取并验证磁盘的每个段。

样例:7 查看驱动器的自检结果

  1. root@linuxtechi:~# smartctl -l selftest /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF READ SMART DATA SECTION ===
  5. SMART Self-test log structure revision number 1
  6. Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
  7. # 1 Short offline Completed: read failure 90% 492 210841222
  8. # 2 Extended offline Completed: read failure 90% 492 210841222

样例:8 计算测试时间估值

  1. root@linuxtechi:~# smartctl -c /dev/sdb
  2. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  3. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  4. === START OF READ SMART DATA SECTION ===
  5. General SMART Values:
  6. Offline data collection status: (0x00) Offline data collection activity
  7. was never started.
  8. Auto Offline Data Collection: Disabled.
  9. Self-test execution status: ( 121) The previous self-test completed having
  10. the read element of the test failed.
  11. Total time to complete Offline
  12. data collection: ( 0) seconds.
  13. Offline data collection
  14. capabilities: (0x73) SMART execute Offline immediate.
  15. Auto Offline data collection on/off support.
  16. Suspend Offline collection upon new
  17. command.
  18. No Offline surface scan supported.
  19. Self-test supported.
  20. Conveyance Self-test supported.
  21. Selective Self-test supported.
  22. SMART capabilities: (0x0003) Saves SMART data before entering
  23. power-saving mode.
  24. Supports SMART auto save timer.
  25. Error logging capability: (0x01) Error logging supported.
  26. General Purpose Logging supported.
  27. Short self-test routine
  28. recommended polling time: ( 1) minutes.
  29. Extended self-test routine
  30. recommended polling time: ( 102) minutes.
  31. Conveyance self-test routine
  32. recommended polling time: ( 2) minutes.
  33. SCT capabilities: (0x103b) SCT Status supported.
  34. SCT Error Recovery Control supported.
  35. SCT Feature Control supported.
  36. SCT Data Table supported.

样例:9 显示磁盘错误日志

  1. root@linuxtechi:~# smartctl -l error /dev/sdb
  2. Sample Output
  3. smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)
  4. Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
  5. === START OF READ SMART DATA SECTION ===
  6. SMART Error Log Version: 1
  7. ATA Error Count: 5
  8. CR = Command Register [HEX]
  9. FR = Features Register [HEX]
  10. SC = Sector Count Register [HEX]
  11. SN = Sector Number Register [HEX]
  12. CL = Cylinder Low Register [HEX]
  13. CH = Cylinder High Register [HEX]
  14. DH = Device/Head Register [HEX]
  15. DC = Device Command Register [HEX]
  16. ER = Error register [HEX]
  17. ST = Status register [HEX]
  18. Powered_Up_Time is measured from power on, and printed as
  19. DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,
  20. SS=sec, and sss=millisec. It "wraps" after 49.710 days.
  21. Commands leading to the command that caused the error were:
  22. CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name
  23. -- -- -- -- -- -- -- -- ---------------- --------------------
  24. 25 da 08 e7 e5 a5 4c 00 00:30:44.515 READ DMA EXT
  25. 25 da 08 df e5 a5 4c 00 00:30:44.514 READ DMA EXT
  26. 25 da 80 5f e5 a5 4c 00 00:30:44.502 READ DMA EXT
  27. 25 da f0 5f e6 a5 4c 00 00:30:44.496 READ DMA EXT
  28. 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的更多相关文章

  1. Java虚拟机详解(七)------虚拟机监控和分析工具(1)——命令行

    通过前面的几篇博客,我们介绍了Java虚拟机的内存分配以及内存回收等理论知识,了解这些知识对于我们在实际生产环境中提高系统的运行效率是有很大的帮助的.但是话又说回来,在实际生产环境中,线上项目正在运行 ...

  2. Java虚拟机详解(八)------虚拟机监控和分析工具(2)——可视化

    上篇博客我们介绍了虚拟机监控和分析命令行工具,由于其不够直观,不是很容易排查问题,那么本篇博客我们就来介绍几个可视化工具. 1.JConsole JConsole(Java Monitoring an ...

  3. Linux网络流量监控与分析工具Ntopng

    Ntopng工具 Ntopng是一个功能强大的流量监控.端口监控.服务监控管理系统 能够实现高效地监控多台服务器网络 Ntopng功能介绍 Ntop提供了命令行界面和web界面两种工作方式,通过web ...

  4. 5、JVM的监控与分析工具

    一.JPS(虚拟机进程监控工具) 二.jstat:虚拟机统计信息监视工具 例子:jstat -gcutil 16478 s0:区域占比2.33%: s1占比0.00%: E:伊甸园区 : O:老年区: ...

  5. [转] python运行时内存分析工具meliae

    转自:https://my.oschina.net/markco/blog/601773 利用meliae来监控python进程的内存占用情况 meliae是一个python进程内存占用监控.分析工具 ...

  6. JDK 中的监控与故障处理工具-01

    当给系统定位问题的时候, 我们经常需要了解并分析 JVM 的运行时状态 . 那应该从哪些方面入手呢? 答案就是从数据入手 . 这里的数据包括: GC日志,异常堆栈, 线程快照(threaddump) ...

  7. 【性能测试】服务器性能监控、数据采集工具nmon安装使用详解

    nmon nmon是一种在AIX与各种Linux操作系统上广泛使用的监控与分析工具,它能在系统运行过程中实时地捕捉系统资源的使用情况,并且能输出结果到文件中,然后通过nmon_analyzer工具产生 ...

  8. java虚拟机(八)--java性能监控与故障处理工具

    问题定位: 除了个人经验,知识,工具也是很重要的,通过数据进行问题分析,包括:运行日志.异常堆栈.GC日志.线程快照(threaddump/javacore文件 ).堆转储快照(heapdump/hp ...

  9. linux使用nmon监控、分析系统性能

    linux使用nmon监控.分析系统性能   一.概述 nmon是一种在AIX与各种Linux操作系统上广泛使用的监控与分析工具,相对于其它一些系统资源监控工具来说,nmon所记录的信息是比较全面的, ...

随机推荐

  1. QUartus 使用之001_空格_箭头切换----FPGA--001

    Quartus里的Tab键,按下后,显示的为什么是箭头,以前显示的是空白,图片如下: 解决方式如下: 修改后效果图如下:

  2. k-近邻算法(kNN)笔记

    #mat()函数可以将数组(array)转化为矩阵(matrix)# randMat = mat(random.rand(4,4))# 求逆矩阵:randMat.I# 存储逆矩阵:invRandMat ...

  3. [CSP-S模拟测试]:String Master(暴力)

    题目描述 所谓最长公共子串,比如串$A:"abcde"$,串$B:"jcdkl"$,则它们的最长公共子串为串$"cd"$,即长度最长的字符串 ...

  4. 前端每日实战:94# 视频演示如何用纯 CSS 创作一台拍立得照相机

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/YjYgey 可交互视频 此视频是可 ...

  5. grid布局快速入门

    Grid布局快速入门 常用Grid布局属性介绍 下面从一个简单Grid布局例子说起.CSS Grid 布局由两个核心组成部分是 wrapper(父元素)和 items(子元素). wrapper 是实 ...

  6. 建站手册-浏览器信息:Mozilla 项目

    ylbtech-建站手册-浏览器信息:Mozilla 项目 1.返回顶部 1. http://www.w3school.com.cn/browsers/browsers_mozilla.asp 2. ...

  7. WebBrowser元素定位的常用方法

    在delphi中想要使用WebBrowser控件,需要一了解一些浏览器和网站制作的知识.操作元素(增删改查).需要提前了解HTML DOM.

  8. 二分查找法:x 的平方根

    实现 int sqrt(int x) 函数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. public int mySqrt(int x) { long left=0; long r ...

  9. centOS不显示ipv4地址的解决办法

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/lx_Frolf/article/deta ...

  10. 小程序中封装base64

    function Base64() { // private property var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn ...