Chinaunix首页 | 论坛 | 博客
  • 博客访问: 341927
  • 博文数量: 60
  • 博客积分: 1793
  • 博客等级: 上尉
  • 技术积分: 675
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-17 18:21
文章存档

2012年(30)

2011年(30)

我的朋友

分类: LINUX

2012-05-21 15:29:54

Smartmontools是一种硬盘检测工具,通过控制和管理硬盘的SMART(Self Monitoring Analysis and Reporting Technology,自动检测分析及报告技术)技术来实现的,SMART技术可以对硬盘的磁头单元、盘片电机驱动系统、硬盘内部电路以及盘片表面介质材料等进行监测,当SMART监测并分析出硬盘可能出现问题时会及时向用户报警以避免计算机数据受损失。SMART技术必须在主板支持的前提下才能发生作用,而且 SMART技术也不能保证能预报所有可能发生的硬盘故障。SMART(SFF-8035i) 是硬盘生产商们建立的一个工业标准,这个标准就是在硬盘上保存一个跟执行情况,可靠程度,读找错误率等属性的表格。所有属性都有一个1byte(大小范围1-253)的标准化值,还包含另一个1byte的关键阶段值,如果属性表格内某个数据接近小于或达到关键阶段值,表明硬盘工作不正常了。

smartmontools的使用

一:
功能:可以查看生产厂商、型号、序列号、容量、是否支持SMART、开启否
主页:
Centos安装: (现在很多发行版已经默认安装)
yum -y install smartmontools

smartctl 
-i 指定设备
-d 指定设备类型,例如:ata, scsi, marvell, sat, 3ware,N
-a 或A 显示所有信息
-l 指定日志的类型,例如:TYPE: error, selftest, selective, directory,background, scttemp[sts,hist]
-H 查看硬盘健康状态
-t short 后台检测硬盘,消耗时间短
-t long 后台检测硬盘,消耗时间长
-C -t short 前台检测硬盘,消耗时间短
-C -t long 前台检测硬盘,消耗时间长
-X 中断后台检测硬盘
-l selftest 显示硬盘检测日志
HP硬盘:
smartctl -s on -d  cciss,0 /dev/cciss/c0d0 开启SMART
smartctl  -a  -d cciss,0 -i /dev/cciss/c0d0  显示所有SMART信息
smartctl  -l error  -d cciss,0 -i /dev/cciss/c0d0 查看磁盘错误日志
+++++++++++++++++++++++smarted服务+++++++++++++++++

简单说下smartctl:smartd由kernel-utils包缺省安装。用命令 rpm -ql kernel-utils 可以列出kernel-utils包中的文件
它是一个守护进程(一个帮助程序),它能监视拥有自我监视,分析和汇报技术(Self-Monitoring, Analysis, and Reporting Technology - SMART)的硬盘。
主配置文件:/etc/smartd.conf 
添加一行/dev/cciss/c0d0 -H -m sys@5iqiong.com
上边的配置表示smartd以静默状态工作,当SMART中报告PASSED的时候不理睬一旦出现Failure,立刻用邮件通知用户指定的邮箱

二:

1、启动监控进程
# /etc/init.d/smartd start
启动 smartd:                                              [  确定  ]
2、检查硬盘是否支持SMART 1993年以后出厂的硬盘基本上都支持SMART技术,使用如下命令可以来查看:
# smartctl -i /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== START OF INFORMATION SECTION ===
Device Model:     ST3160212A
Serial Number:    5LS2EDKN
Firmware Version: 3.AAE
User Capacity:    160,041,885,696 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   7
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Mon Sep 17 02:13:37 2007 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
在上面的信息可以看到,该硬盘是支持SMART技术,且当前是开启的。如果SMART support is: Disabled表示SMART未启用,执行如下命令,启动SMART:
smartctl --smart=on --offlineauto=on --saveauto=on /dev/hdb
3、检查硬盘健康状态
# smartctl -H /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
请注意result后边的结果:PASSED,这表示硬盘健康状态良好,如果这里显示Failure,那么最好立刻给服务器更换硬盘。SMART只能报告磁盘已经不再健康,但是报警后还能继续运行多久是不确定的,通常,SMART报警参数是有预留的,磁盘报警后,不会当场坏掉,一般能坚持一段时间,有的硬盘SMART报警后还继续跑了好几年,有的硬盘SMART报错后几天就坏了,千万不要存在侥幸心理。执行如下命令可以看到详细的参数:
# smartctl -A /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000f   114   100   006    Pre-fail  Always       -       81812244
  3 Spin_Up_Time            0x0003   100   099   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       257
  5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   078   060   030    Pre-fail  Always       -       64781708
  9 Power_On_Hours          0x0032   096   096   000    Old_age   Always       -       4365
10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       276
187 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
189 Unknown_Attribute       0x003a   100   100   000    Old_age   Always       -       0
190 Unknown_Attribute       0x0022   058   053   045    Old_age   Always       -       773324842
194 Temperature_Celsius     0x0022   042   047   000    Old_age   Always       -       42 (Lifetime Min/Max 0/21)
195 Hardware_ECC_Recovered  0x001a   052   048   000    Old_age   Always       -       1562815
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0000   100   253   000    Old_age   Offline      -       0
202 TA_Increase_Count       0x0032   100   253   000    Old_age   Always       -       0
FLAG是标记,标准数值(VALUE)应当小于或等於关键值(THRESH)。WHEN_FAILED 代表错误信息,上面显示的WHEN_FAILED纵行是空行,说明硬盘没有故障。如果WHEN_FAILED显示数字,表明硬盘磁道可能有比较大的坏道。
4、对硬盘进行检测 手工对硬盘进行测试的方法有以下四种:
smartctl -t short     后台检测硬盘,消耗时间短
smartctl -t long       后台检测硬盘,消耗时间长
smartctl -C -t short  前台检测硬盘,消耗时间短
smartctl -C -t long   前台检测硬盘,消耗时间长
例如,在后台对硬盘进行详细的检查,命令如下:
# smartctl -t long /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== 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 54 minutes for test to complete.
Test will complete after Mon Sep 17 03:53:32 2007
Use smartctl -X to abort test.
上面的信息显示54分钟后将完成检查,同时可以使用 smartctl -X 终止检查。终止硬盘检查命令的使用方法是:
# smartctl -X /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Abort SMART off-line mode self-test routine".
Self-testing aborted!
5、查看硬盘日志 使用“smartctl -l logtype ”可以查看硬盘的日志,日志又分为多种类型,如selftest、error等等。例如查看硬盘检测的日志,如下:
# smartctl -l selftest /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== 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  Extended offline    Aborted by host               90%      4365         -
# 2  Extended offline    Completed without error       00%      4247         -
# 3  Short offline       Aborted by host               30%      4246         -
# 4  Short offline       Aborted by host               10%      4246         -
# 5  Extended offline    Completed without error       00%      4229         -
查看硬盘错误日志:
# smartctl -l error /dev/hdb
smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen
Home page is
=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
No Errors Logged
简单用法:
1、smartctl -a           检查该设备是否已经打开SMART技术。
2、smartctl -s on    如果没有打开SMART技术,使用该命令打开SMART技术。
3、smartctl -t short    后台检测硬盘,消耗时间短;
      smartctl -t long      后台检测硬盘,消耗时间长;
      smartctl -C -t short 前台检测硬盘,消耗时间短;
      smartctl -C -t long  前台检测硬盘,消耗时间长。
其实就是利用硬盘SMART的自检程序。
4、smartctl -X  中断后台检测硬盘。
5、smartctl -l selftest  显示硬盘检测日志。
6、smartctl -l error 显示硬盘错误汇总。


阅读(3454) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~