linux 服务器 硬盘测试工具,linux硬盘检测工具:Smartmontools使用指南

在服务器管理的实际环境中,硬盘是最容易出现问题及发生故障的硬件,而且硬盘中存储着大量重要的数据,万一出现故障所造成的损失也是无法估计的,轻则需要化费大量的时间与精力去做数据恢复,重则硬盘报废,里面重要的数据也无法100%挽回,所以对硬盘健康状态的监控,就显得尤为重要,下面我们来介绍一下Linux中一款开源的硬盘检测工具Smartmontools,通过该软件我们可以对硬盘进行高效的监控,一旦硬盘发生故障,我们也能及早的发现问题,尽量避免重大的损失发生。

smartmontools是一款开源的磁盘控制,监视工具,可以运行在 Linux,Unix,BSD,Solaris,Mac OS,OS/2,Cygwin和Windows上,同时它还可以从启动光盘或启动软盘运行,支持ATA/ATAPI/SATA-3(到-8)位的硬盘和 SCSI硬盘,另外还支持磁带设备,它的老家在smartmontools.sourceforge.net,实际上它是一个软件包,包括了两个实用程序:smartctl和smatd。

目前smartmontools的最新版本为2012年6月30日发布的smartmontools v5.43-1,下载地址如下:

Windows版本:http://sourceforge.net/projects/smartmontools/files/smartmontools/5.43/smartmontools-5.43-1.win32-setup.exe/download

Linux版本:http://sourceforge.net/projects/smartmontools/files/smartmontools/5.43/smartmontools-5.43.tar.gz/download

Debian Linux中的安装:

#dpkg -i smartmontools_5.39-1_i386.deb

Red Hat Enterprise Linux, CentOS and Fedora Linux中的安装:

#yum install smartmontools

其它使用RPM包的Linux发行版:

#rpm -ivh smartmontools_5.39-1_i386.deb

如需删除smartmontools包,请使用以下命令:

#rpm -e --noscripts smartmontools

源码包的安装:

#tar zxvf smartmontools-5.42.tar.gz

#cd smartmontools-5.42

#./configure

#make

#make install

1.1 什么是Smartmontools?

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

摘要:2.1 Smartmontools的使用 1、启动监控进程 # /etc/init.d/smartd

start 启动 smartd: [ 确定 ] 2、检查硬盘是否支持SMART ,

1993年以后出厂的硬盘基本上都支持SMART技术,使用如下命令可以来查看: # smartctl -i

2.1 Smartmontools的使用

1、启动监控进程

# /etc/init.d/smartd start

启动 smartd: [ 确定 ]

2、检查硬盘是否支持SMART ,     1993年以后出厂的硬盘基本上都支持SMART技术,使用如下命令可以来查看:

# smartctl -i /dev/sda

smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===

Device Model:     ST3320418AS

Serial Number:    9VM1R2WY

Firmware Version: CC35

User Capacity:    320,072,933,376 bytes

Device is:        Not in smartctl database [for details use: -P showall]

ATA Version is:   8

ATA Standard is:  ATA-8-ACS revision 4

Local Time is:    Sun Aug 16 21:25:18 2009 EDT

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/sda

3、检查硬盘健康状态

# smartctl -H /dev/sda

smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===

SMART overall-health self-assessment test result: PASSED

请注意result后边的结果:PASSED,这表示硬盘健康状态良好,如果这里显示Failure,那么最好立刻给服务器更换硬盘。SMART只能报告

磁盘已经不再健康,但是报警后还能继续运行多久是不确定的,通常,SMART报警参数是有预留的,磁盘报警后,不会当场坏掉,一般能坚持一段时间,有的硬

盘SMART报警后还继续跑了好几年,有的硬盘SMART报错后几天就坏了,千万不要存在侥幸心理。执行如下命令可以看到详细的参数:

# smartctl -A /dev/sda

smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== 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   109   100   006    Pre-fail  Always       -       21618934

3 Spin_Up_Time            0x0003   098   098   000    Pre-fail  Always       -       0

4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       12

5 Reallocated_Sector_Ct   0x0033   100   100   036    Pre-fail  Always       -       0  7 Seek_Error_Rate         0x000f   100   253   030    Pre-fail  Always       -       116923

9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       58

10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0

12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       6

183 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0

184 Unknown_Attribute       0x0032   100   100   099    Old_age   Always       -       0

187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0

188 Unknown_Attribute       0x0032   100   099   000    Old_age   Always       -       4

189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0

190 Airflow_Temperature_Cel 0x0022   057   056   045    Old_age   Always       -       43 (Lifetime Min/Max 29/44)

194 Temperature_Celsius     0x0022   043   044   000    Old_age   Always       -       43 (0 25 0 0)

195 Hardware_ECC_Recovered  0x001a   048   047   000    Old_age   Always       -       21618934

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

240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       226628244340804

241 Unknown_Attribute       0x0000   100   253   000    Old_age   Offline      -       30093291

242 Unknown_Attribute       0x0000   100   253   000    Old_age   Offline      -       2423580

FLAG是标记,标准数值(VALUE)应当小于或等於关键值(THRESH)。WHEN_FAILED 代表错误信息,上面显示的WHEN_FAILED纵行是空行,说明硬盘没有故障。如果WHEN_FAILED显示数字,表明硬盘磁道可能有比较大的坏道。

linux硬盘检测工具:Smartmontools使用指南(3)

2012-08-13 22:25来源:风信网 作者:末信 点击:2168次

摘要:4、对硬盘进行检测 手工对硬盘进行测试的方法有以下四种: smartctl

-t short device 后台检测硬盘,消耗时间短 smartctl -t long device 后台检测硬盘,消耗时间长

smartctl -C -t short device 前台检测硬盘,消

4、对硬盘进行检测 手工对硬盘进行测试的方法有以下四种:

smartctl -t short 后台检测硬盘,消耗时间短

smartctl -t long 后台检测硬盘,消耗时间长

smartctl -C -t short 前台检测硬盘,消耗时间短

smartctl -C -t long 前台检测硬盘,消耗时间长

例如,在后台对硬盘进行详细的检查,命令如下:

# smartctl -t long /dev/sda

smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen

Home page is

http://smartmontools.sourceforge.net/

=== 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/sda

smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen

Home page is http://smartmontools.sourceforge.net/

=== 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/sda

smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen

Home page is

http://smartmontools.sourceforge.net/

=== 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/sda

smartctl version 5.33 [i686-turbo-linux-gnu] Copyright (C) 2002-4 Bruce Allen

Home page is

http://smartmontools.sourceforge.net/

=== START OF READ SMART DATA SECTION ===

SMART Error Log Version: 1

No Errors Logged

说明没有错误日志

我主要是要看通电时间

所以只用了

smartctl -A /dev/sda

其中

Power_On_Hours 就是我要的数据

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值