当前位置: 移动技术网 > 科技>操作系统>Linux > linux硬盘检测健康状态

linux硬盘检测健康状态

2018年11月08日  | 移动技术网科技  | 我要评论

定期检查硬盘的健康状态是每个系统管理员必须要做的事情。说到硬盘的健康状态,这里就得先说一下s.m.a.r.t.了。

smart是一种磁盘自我分析检测技术,早在90年代末就基本得到了普及
每一块硬盘(包括ide、scsi)在运行的时候,都会将自身的若干参数记录下来
这些参数包括型号、容量、温度、密度、扇区、寻道时间、传输、误码率等
硬盘运行了几千小时后,很多内在的物理参数都会发生变化
某一参数超过报警阈值,则说明硬盘接近损坏
此时硬盘依然在工作,如果用户不理睬这个报警继续使用
那么硬盘将变得非常不可靠,随时可能故障


smart是和主板bios上相应功能配合的
要使用smart,必须先进入到主板bios设置里边启动相关设置
一般从pentium2级别起的主板,都支持smart
bios启动以后,就是操作系统级别的事情了
很遗憾,windows没有内置smart相关工具(需要安装第三方工具软件)
好在linux上很早就有了smart支持了
如果把linux装在vmware等虚拟机上,在系统启动时候可以看到有个服务启动报错:smartd
这个服务器就是smart的daemon进程(因为vmware虚拟机的硬盘不支持smart,所以报错)


可以使用下面的命令来确认硬盘是否打开了smart支持

复制代码
代码如下:

smartctl -i /dev/sda

正常情况下应该会得到下面这样的信息


复制代码
代码如下:

[root@localhost ~]# smartctl -i /dev/sda
smartctl version 5.38 [i686-redhat-linux-gnu] copyright (c) 2002-8 bruce allen
home page is <a href="http://smartmontools.sourceforge.net/">http://smartmontools.sourceforge.net/</a>


复制代码
代码如下:

=== start of information section ===
model family: seagate barracuda 7200.10 family
device model: st3160815as
serial number: 5ra6a1k9
firmware version: 4.aab
user capacity: 160,041,885,696 bytes
device is: in smartctl database [for details use: -p show]
ata version is: 7
ata standard is: exact ata specification draft version not indicated
local time is: sat jul 7 17:18:02 2012 cst
smart support is: available – device has smart capability.

在这里,如果看到smart support is: disabled,则表示smart未启用


如果我们需要执行如下命令,启动smart:

复制代码
代码如下:

smartctl –smart=on –offlineauto=on –saveauto=on /dev/sda

查看硬盘当前的健康状态使用如下命令


复制代码
代码如下:

[root@localhost ~]# smartctl -h /dev/sda
smartctl version 5.38 [i686-redhat-linux-gnu] copyright (c) 2002-8 bruce allen
home page is <a href="http://smartmontools.sourceforge.net/">http://smartmontools.sourceforge.net/</a>


复制代码
代码如下:

=== start of read smart data section ===
smart overall-health self-assessment test result: passed

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


执行如下命令可以看到详细的参数:


复制代码
代码如下:

[root@localhost ~]# smartctl -a /dev/sda
smartctl version 5.38 [i686-redhat-linux-gnu] copyright (c) 2002-8 bruce allen
home page is <a href="https://www.jb51.net/">https://www.jb51.net/</a>


复制代码
代码如下:

=== 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 100 253 006 pre-fail always – 0
3 spin_up_time 0×0003 097 097 000 pre-fail always – 0
4 start_stop_count 0×0032 100 100 020 old_age always – 818
5 reallocated_sector_ct 0×0033 100 100 036 pre-fail always – 0
7 seek_error_rate 0x000f 085 060 030 pre-fail always – 369003829
9 power_on_hours 0×0032 084 084 000 old_age always – 14527
10 spin_retry_count 0×0013 100 100 097 pre-fail always – 0
12 power_cycle_count 0×0032 100 100 020 old_age always – 817
187 reported_uncorrect 0×0032 100 100 000 old_age always – 0
189 high_fly_writes 0x003a 100 100 000 old_age always – 0
190 airflow_temperature_cel 0×0022 052 046 045 old_age always – 48 (lifetime min/max 47/52)
194 temperature_celsius 0×0022 048 054 000 old_age always – 48 (0 11 0 0)
195 hardware_ecc_recovered 0x001a 074 062 000 old_age always – 188295533
197 current_pending_sector 0×0012 100 100 000 old_age always – 0
198 offline_uncorrectable 0×0010 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 0×0000 100 253 000 old_age offline – 0
202 ta_increase_count 0×0032 100 253 000 old_age always – 0

上边列出的参数表中可供进行技术分析和参考,使用下边的命令可以输出完整结果:

复制代码
代码如下:

smartctl -a /dev/sda

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网