三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

centos 7 查看硬盘健康状态S.M.A.R.T(smartctl)

三三 2022-03-08 2406 0条评论 Linux使用 CentOS7磁盘健康检查smartctlsmartmontools

首页 / 正文

1.安装工具smartmontools
命令:

yum -y install smartmontools

Tips:只有root用户才有权限安装

2.通过smartmontools工具查看硬盘信息
命令:

smartctl -i /dev/sda
lsscsi -g
dmesg | grep ATA
dmidecode|more 服务器品牌
smartctl -i -d cciss,0 /dev/sda
smartctl --all /dev/sda     //这里的Vendor和Product实际上是磁盘阵列卡的信息,而不是磁盘信息。
smartctl -a -d sat+megaraid,0 /dev/sda   
smartctl --all /dev/sda -d megaraid,1
smartctl -i /dev/sda   //查看硬盘信息
smartctl -H /dev/sda    // 查看硬盘的SMART健康 PASSED表示没问题
smartctl -A /dev/sda    //查看原厂信息

Tips:其中/dev/sda为系统的第一块硬盘,可以到/dev目录下查看服务器有多少块硬盘

上面两行分别是是否支持SMART,是否启用SMART,如果支持是有的,但是下面的状态是DISABLED的,则需要通过以下命令启用SMART

smartctl -s on /dev/sda

3.查看硬盘的SMART健康
命令:

smartctl -H /dev/sda

PASSED表示健康,否则意味着磁盘已经故障,或很快就会发生故障。

查看原厂信息

smartctl -A /dev/sda

如果要检测磁盘状态可以使用:

smartctl --test=short /dev/sda

或者

smartctl -t short /dev/sda

显示如下:

smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.el7.x86_64] (local build)
Copyright (C) 2002-18, 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 2 minutes for test to complete.
Test will complete after Wed May  4 07:56:59 2022

Use smartctl -X to abort test.

观察测试进度

通过-c 参数,可以观察到测试的进度:

smartctl -c /dev/sda

结果如下:

Self-test execution status:      ( 241) Self-test routine in progress...
                                        10% of test remaining.

观察测试结果

通过-l selftest 参数,可以看到/dev/sda测试的结果记录:

“#1”代表的那一次测试,Completed without error表示完成,没有错误。

“#2”代表的那一次测试,Aborted by host表示测试被用户终止,还有90%没有完成。

smartctl -l selftest /dev/sda

Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error

# 1 Short offline Completed without error 00% 9535 -

# 2 Extended offline Aborted by host 90% 9534 -

代码含义

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          
  1 Raw_Read_Error_Rate     读取错误率
  3 Spin_Up_Time            起转时间
  4 Start_Stop_Count        启动停止次数
  5 Reallocated_Sector_Ct   重新分配扇区计数
  7 Seek_Error_Rate         寻道错误率
  9 Power_On_Hours          通电时间
 10 Spin_Retry_Count        起转重试次数
 11 Calibration_Retry_Count 重新校准重试次数
 12 Power_Cycle_Count       启动<->关闭循环次数
192 Power-Off_Retract_Count 断电磁头缩回计数
193 Load_Cycle_Count        磁头加载/卸载循环计数
194 Temperature_Celsius     温度
196 Reallocated_Event_Count 在分配扇区物理位置事件计数(与坏道无关)
197 Current_Pending_Sector  当前等待中扇区数(状态存疑/不稳定-等待后续判断)
198 Offline_Uncorrectable   无法修正的扇区总数
199 UDMA_CRC_Error_Count    UltraDMA CRC错误计数
200 Multi_Zone_Error_Rate   写入错误率
241 Total_LBAs_Written     总写入量,算法:数字x512/1024/1024/1024= 单位G

4.其他命令

-h 帮助信息
-V 版本信息
-i 打印基本信息(磁盘设备号、序列号、固件版本…)
-a 打印磁盘所有的SMART信息

运行时行为参数:

-q TYPE 指定输出的安静模式。
TYPE可以有3种选择:
eorsonly 只打印错误日志。
slent 有任何打印。
nserial 不打印序列号

-d TYPE 指定磁盘的类型。如果没有指定,smartctl会根据磁盘的名字来
猜测磁盘类型。

-T TYPE 指定当发生错误时,smartctl的容忍程度,是否继续运行。
TYPE可以有4种选择:
conservative 一有错就会退出
normal 如果必须支持的SMART命令失败,则退出
permissive 忽略一次必须支持的SMART命令失败
verypermissive 忽略所有必须支持的SMART命令失败

-b TYPE 指定当发生校验错误时,smartctl的动作。
TYPE有3种选择:
warn 发出警告,继续执行
exit 退出smartctl
ignore 不发出告警,继续执行 
-r TYPE smartmontools开发人员相关。
-n POWERMODE 指定当磁盘处于节能模式时,smartctl是否继续检查,
默认是不检查。

POWERMODE有4种选择:
never 检查
sleep 除了sleep模式,检查。
standby 除了sleep或standby模式,检查。
idle 除了sleep或standby或idle模式,检查。

SMART功能开关参数:
-s on/off 打开或关闭磁盘的SMART功能
-o on/off 打开或关闭SMART自动离线检测,该功能每4小时就会自动扫描磁盘是
否有缺陷。
-S on/off 打开或关闭“自动保存厂商指定属性”功能。

SMART 读和显示数据参数
-H 报告磁盘的是否健康。如果报告不健康,则说明磁盘已经损坏或会在24小时
内损坏。
-c 显示磁盘支持的普通SMART功能,以及这些功能当前的状态。
-A 显示磁盘支持的厂商指定SMART特性。这些特性的编号从1-253,并且有指
定的名字。
-l TYPE 指定显示的log类型。

TYPE有4种选择:
error 只显示error log。
selftest 只显示selftest log
selective 只显示selective self-test log
directory 只显示Log Directory
-v N,OPTION 显示厂商指定SMART特性N时,使用厂商相关的显示方式。
-F TYPE 设置smartctl的行为,当出现一些已知但还没有解决的硬件或软件bug时,
smartctl应该怎么做。
-P TYPE 设置smartctl是否对磁盘使用数据库中已有的参数。
SMART 离线测试、自测试 参数
-t TEST 立刻执行测试,可以和-C参数一起使用。
TEST可以有以下几个选择:
offline 离线测试。可以在挂载文件系统的磁盘上使用
short 短时间测试。可以在挂载文件系统的磁盘上使用。
long 长时间测试。可以在挂载文件系统的磁盘上使用。
conveyance [ATA only]传输zi测试。可以在挂载文件系统的磁盘上使用。
select, N-M 
select, N+SIZE [ATA only]有选择性测试,测试磁盘的部分LBA。N表示
LBA编号,M表示结束LBA编号,SIZE表示测试的LBA
范围。
-C 在captive模式下运行测试。

注意:(1)-C必须配合-t一起使用,但如果是-t offline,则-C不生效。
(2)-C会使得磁盘很忙,所以最好是在没有挂载文件系统的磁盘上使用。
-X 中断no-captive模式下运行的测试。

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张