linux smartctl 命令,使用smartctl命令检查磁盘

linux smartctl 命令,使用smartctl命令检查磁盘使用smartctl命令检查磁盘在TS过程中会碰到很多磁盘异常出现影响系统数据或者生产数据的情况,但是有时候无法判断磁盘出现问题是由于磁盘物理损坏还是磁盘SATA口接触不良导致,这个时候smartctl命令就可以很容易判断出磁盘是否存在物理损坏问题,并且及时作出预警。使用smartctl进行SMART测试所有现代硬盘都可通过SMART属性监视其当前状态。这些值提供有关硬盘各种参数的信息,并可提供有…

大家好,又见面了,我是你们的朋友全栈君。

使用smartctl命令检查磁盘

在TS过程中会碰到很多磁盘异常出现影响系统数据或者生产数据的情况,但是有时候无法判断磁盘出现问题是由于磁盘物理损坏还是磁盘SATA口接触不良导致,这个时候smartctl命令就可以很容易判断出磁盘是否存在物理损坏问题,并且及时作出预警。

使用smartctl进行SMART测试

所有现代硬盘都可通过SMART属性监视其当前状态。这些值提供有关硬盘各种参数的信息,并可提供有关磁盘剩余寿命或任何可能的错误的信息。此外,可以执行各种SMART测试,以确定磁盘上的任何硬件问题。本文介绍如何使用smartctl(Smartmontools)对Linux进行此类测试。

安装Smartmontools

Smartmontools可以使用yum直接安装:

# yum install -y smartmontools

要确保硬盘支持SMART并启用,请使用以下命令(本例中为硬盘/ dev / sda):

# smartctl -i /dev/sda

smartctl 6.4 2015-06-04 r4109 [x86_64-linux-3.10.0-514.el7.x86_64] (local build)

Copyright (C) 2002-15, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===

Device Model: HGST HUS726030ALE610

Serial Number: N8GH1H5Y

LU WWN Device Id: 5 000cca 244c6d728

Firmware Version: APBDT7JN

User Capacity: 3,000,592,982,016 bytes [3.00 TB]

Sector Sizes: 512 bytes logical, 4096 bytes physical

Rotation Rate: 7200 rpm

Form Factor: 3.5 inches

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

ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 4

SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)

Local Time is: Wed Oct 11 07:09:17 2017 CST

SMART support is: Available – device has SMART capability.

SMART support is: Enabled

上面的参数中,SMART support is: Available – device has SMART capability.显示磁盘SMART是支持的,SMART support is: Enabled是可用的

可用测试

SMART根据规格类型和SCSI设备提供两种不同的测试。这些测试中的每一个都可以以两种模式进行:

前景模式

背景模式

在背景模式下,测试的优先级低,这意味着正常指令继续由硬盘处理。如果硬盘驱动器正忙,则测试暂停,然后以较低的加载速度继续运行,因此不会中断操作。

在前景模式下,所有命令将在测试期间以“检查条件”状态进行应答。因此,仅当不使用硬盘时,才建议使用此模式。

原则上,背景模式是首选模式。

ATA / SCSI测试

短期测试

短期测试的目标是快速识别有缺陷的硬盘驱动器。因此,短测试的最大运行时间为2分钟。测试通过将磁盘划分成三个不同的段来检查磁盘。测试以下几个方面:

电气特性:控制器测试自己的电子元件,由于这是每个制造商特有的,因此无法准确解释正在测试的内容。例如,可以想到测试内部RAM,读/写电路或头电子元件。

机械特性:要测试的伺服系统和定位机制的确切顺序也是每个制造商特有的。

读/校验:它将读取磁盘的某个区域并验证某些数据,读取的区域的大小和位置也是每个制造商特有的。

长期测试

长期测试被设计为生产中的最终测试,与短暂测试相同,有两个差异。

第一个:没有时间限制,并且在读/校验中检查整个磁盘,而不仅仅是一个部分。例如,长期测试可以用于确认短测试的结果。

ATA指定测试

此处列出的所有测试仅适用于ATA硬盘驱动器。

运输测试

可以执行该测试以确定在几分钟内传输硬盘时的损坏。

选择测试

在选定的测试期间,检查指定的逻辑块范围。要扫描的逻辑块以以下格式指定:

# smartctl -t select,10-20 /dev/sda ## LBA 10 to LBA 20(incl.)

# smartctl -t select,10+11 /dev/sda ## LBA 10 to LBA 20(incl.)

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===

Sending command: “Execute SMART Selective self-test routine immediately in off-line mode”.

SPAN STARTING_LBA ENDING_LBA

0 10 20

Drive command “Execute SMART Selective self-test routine immediately in off-line mode” successful.

Testing has begun.

也可以有多个范围(最多5个)进行扫描:

# smartctl -t select,0-10 -t select,10-20 /dev/sda

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===

Sending command: “Execute SMART Selective self-test routine immediately in off-line mode”.

SPAN STARTING_LBA ENDING_LBA

0 0 10

1 10 20

Drive command “Execute SMART Selective self-test routine immediately in off-line mode” successful.

Testing has begun.

smartctl的测试程序

在执行测试之前,使用以下命令显示各种测试的持续时间的近似值:

# smartctl -c /dev/sda

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

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

General SMART Values:

Offline data collection status: (0x02) Offline data collection activity

was completed without error.

Auto Offline Data Collection: Disabled.

Self-test execution status: ( 0) The previous self-test routine completed

without error or no self-test has ever

been run.

Total time to complete Offline

data collection: ( 0) seconds.

Offline data collection

capabilities: (0x7d) SMART execute Offline immediate.

No Auto Offline data collection support.

Abort Offline collection upon new

command.

Offline surface scan supported.

Self-test supported.

Conveyance Self-test supported.

Selective Self-test supported.

SMART capabilities: (0x0003) Saves SMART data before entering

power-saving mode.

Supports SMART auto save timer.

Error logging capability: (0x01) Error logging supported.

General Purpose Logging supported.

Short self-test routine

recommended polling time: ( 1) minutes.

Extended self-test routine

recommended polling time: ( 48) minutes.

Conveyance self-test routine

recommended polling time: ( 2) minutes.

SCT capabilities: (0x0025) SCT Status supported.

SCT Data Table supported.

以下命令启动所需的测试(在后台模式下):

# smartctl -t /dev/sda

也可以执行“离线”测试。但是,仅进行标准自检(Short Test)。

示例输出:

# smartctl -t short /dev/sda

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== 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 1 minutes for test to complete.

Test will complete after Wed Oct 11 15:40:28 2017

Use smartctl -X to abort test.

要在前台模式下执行测试,必须在命令中添加“-C”。

# smartctl -t -C /dev/sda

查看测试结果

通常,测试结果包含在以下命令的输出中:

# smartctl -a /dev/sda

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===

Device Model: KINGSTON SV300S37A60G

Serial Number: 50026B724A01E182

LU WWN Device Id: 5 0026b7 24a01e182

Firmware Version: 580ABBF0

User Capacity: 60,022,480,896 bytes [60.0 GB]

Sector Size: 512 bytes logical/physical

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

ATA Version is: 8

ATA Standard is: ACS-2 revision 3

Local Time is: Wed Oct 11 15:41:49 2017 CST

SMART support is: Available – device has SMART capability.

SMART support is: Enabled

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

SMART overall-health self-assessment test result: PASSED

General SMART Values:

Offline data collection status: (0x02) Offline data collection activity

was completed without error.

Auto Offline Data Collection: Disabled.

Self-test execution status: ( 0) The previous self-test routine completed

without error or no self-test has ever

been run.

Total time to complete Offline

data collection: ( 0) seconds.

Offline data collection

capabilities: (0x7d) SMART execute Offline immediate.

No Auto Offline data collection support.

Abort Offline collection upon new

command.

Offline surface scan supported.

Self-test supported.

Conveyance Self-test supported.

Selective Self-test supported.

SMART capabilities: (0x0003) Saves SMART data before entering

power-saving mode.

Supports SMART auto save timer.

Error logging capability: (0x01) Error logging supported.

General Purpose Logging supported.

Short self-test routine

recommended polling time: ( 1) minutes.

Extended self-test routine

recommended polling time: ( 48) minutes.

Conveyance self-test routine

recommended polling time: ( 2) minutes.

SCT capabilities: (0x0025) SCT Status supported.

SCT Data Table supported.

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 0x0032 095 095 050 Old_age Always – 8601004262

5 Reallocated_Sector_Ct 0x0033 099 099 003 Pre-fail Always – 0

9 Power_On_Hours 0x0032 085 085 000 Old_age Always – 145066815403100

12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always – 120

171 Unknown_Attribute 0x000a 100 100 000 Old_age Always – 0

172 Unknown_Attribute 0x0032 100 100 000 Old_age Always – 0

174 Unknown_Attribute 0x0030 000 000 000 Old_age Offline – 97

177 Wear_Leveling_Count 0x0000 000 000 000 Old_age Offline – 96

181 Program_Fail_Cnt_Total 0x000a 100 100 000 Old_age Always – 0

182 Erase_Fail_Count_Total 0x0032 100 100 000 Old_age Always – 0

187 Reported_Uncorrect 0x0012 100 100 000 Old_age Always – 0

189 High_Fly_Writes 0x0000 029 041 000 Old_age Offline – 77312098333

194 Temperature_Celsius 0x0022 029 041 000 Old_age Always – 29 (Min/Max 18/41)

195 Hardware_ECC_Recovered 0x001c 102 102 000 Old_age Offline – 8601004262

196 Reallocated_Event_Count 0x0033 099 099 003 Pre-fail Always – 0

201 Soft_Read_Error_Rate 0x001c 102 102 000 Old_age Offline – 8601004262

204 Soft_ECC_Correction 0x001c 102 102 000 Old_age Offline – 8601004262

230 Head_Amplitude 0x0013 100 100 000 Pre-fail Always – 100

231 Temperature_Celsius 0x0013 091 091 010 Pre-fail Always – 0

233 Media_Wearout_Indicator 0x0032 000 000 000 Old_age Always – 9261

234 Unknown_Attribute 0x0032 000 000 000 Old_age Always – 14820

241 Total_LBAs_Written 0x0032 000 000 000 Old_age Always – 14820

242 Total_LBAs_Read 0x0032 000 000 000 Old_age Always – 6033

SMART Error Log not supported

SMART Self-test log structure revision number 1

Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error

# 1 Short offline Completed without error 00% 13404 –

# 2 Selective offline Completed without error 00% 13404 –

# 3 Selective offline Completed without error 00% 13404 –

# 4 Selective offline Completed without error 00% 13404 –

# 5 Short offline Completed without error 00% 13403 –

SMART Selective self-test log data structure revision number 1

SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS

1 0 10 Not_testing

2 10 20 Not_testing

3 0 0 Not_testing

4 0 0 Not_testing

5 0 0 Not_testing

Selective self-test flags (0x0):

After scanning selected spans, do NOT read-scan remainder of disk.

If Selective self-test is pending on power-up, resume after 0 minute delay.

如果只显示测试结果,也可以使用以下命令:

# smartctl -l selftest /dev/sda

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, 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 Short offline Completed without error 00% 13404 –

# 2 Selective offline Completed without error 00% 13404 –

# 3 Selective offline Completed without error 00% 13404 –

# 4 Selective offline Completed without error 00% 13404 –

# 5 Short offline Completed without error 00% 13403 –

显示磁盘全部的健康状态

# smartctl -H /dev/sda

smartctl 5.42 2011-10-20 r3458 [x86_64-linux-2.6.32-358.el6.x86_64] (local build)

Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

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

SMART overall-health self-assessment test result: PASSED ##说明自检通过,磁盘健康

查看磁盘错误日志

# smartctl -l error /dev/sdb

Sample Output

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-32-generic] (local build)

Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

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

SMART Error Log Version: 1

ATA Error Count: 1

CR = Command Register [HEX]

FR = Features Register [HEX]

SC = Sector Count Register [HEX]

SN = Sector Number Register [HEX]

CL = Cylinder Low Register [HEX]

CH = Cylinder High Register [HEX]

DH = Device/Head Register [HEX]

DC = Device Command Register [HEX]

ER = Error register [HEX]

ST = Status register [HEX]

Powered_Up_Time is measured from power on, and printed as

DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes,

SS=sec, and sss=millisec. It “wraps” after 49.710 days.

Error 1 occurred at disk power-on lifetime: 10042 hours (418 days + 10 hours)

When the command that caused the error occurred, the device was active or idle.

After command completion occurred, registers were:

ER ST SC SN CL CH DH

— — — — — — —

84 51 00 00 00 00 a0

Commands leading to the command that caused the error were:

CR FR SC SN CL CH DH DC Powered_Up_Time Command/Feature_Name

— — — — — — — — —————- ——————–

ec 00 00 00 00 00 a0 08 35d+16:09:47.709 IDENTIFY DEVICE

ec 00 00 00 00 00 a0 08 35d+16:09:42.437 IDENTIFY DEVICE

ec 00 00 00 00 00 a0 08 35d+16:09:42.159 IDENTIFY DEVICE

ef 03 46 00 00 00 a0 08 35d+16:09:42.159 SET FEATURES [Set transfer mode]

ec 00 00 00 00 00 a0 08 35d+16:09:42.159 IDENTIFY DEVICE

处理过程

首先通过smartctl -H /dev/sda检查磁盘健康状态,然后smartctl -a /dev/sda查看磁盘详细情况,再对磁盘进行短期测试smartctl -t short /dev/sda,最后查看磁盘测试结果smartctl -l selftest /dev/sda,基本磁盘健康状态就可以定位出来,最后检查磁盘错误日志smartctl -l error /dev/sdb

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/149434.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • goland 激活3月最新在线激活

    goland 激活3月最新在线激活,https://javaforall.cn/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

  • 在 pycharm中安装pytorch

    在 pycharm中安装pytorch参考文章:在pycharm中安装pytorch:https://blog.csdn.net/weixin_43183872/article/details/83473009torch包在pycharm里面的导入问题:https://blog.csdn.net/qq_31187803/article/details/79601643…

  • 动态标题怎么写_网站主题

    动态标题怎么写_网站主题1.快并快乐着!2.共享世界,有你才精彩!3.你共享一小文件,对于你来说是一小文件,但对于世界上的骡友来说是一个大文件。4.分享互联网5.梦里寻她千百度,蓦然回首,那资源竟在VeryCD下载处。6.想象力比知识更重要。7.学历代表过去,学习力掌握将来。8.把自己当傻瓜,不懂就问,你会学的更多。9.学问和修持的力量,来使人受益,就等于欠了一份债。10.不是事业为了思想,而是思想为了事业。11.睡觉是为了踏实地工作,工作是为了踏实地睡觉。12.人生在世界是短暂的,对这短暂的人生,我们最好的报答就是工作。13.

  • 流量分析技术丨分享科来网络通讯协议图2022版本(附下载链接)「建议收藏」

    流量分析技术丨分享科来网络通讯协议图2022版本(附下载链接)「建议收藏」新版本科来协议图,含下载

  • mysql数据库同步工具_mysql同步工具_mysql数据库同步

    mysql数据库同步工具_mysql同步工具_mysql数据库同步 下载网站:www.SyncNavigator.CN  客服QQ1793040———————————————————-  关于HKROnlineSyncNavigator注册机价格的问题HKROnlineSyncNavigator 8.4.1企业版数据同步软件自2009年第一个版…

  • 今儿下午疲惫极了_形容疲惫至极的诗句

    今儿下午疲惫极了_形容疲惫至极的诗句回家的公车上人也特别的多,春天来了,气温渐温,街上的颜色也丰富起来,我一路的走,一路的观望,看着一张张的笑脸,我也一路的想,想我爱的人和爱我的人,不觉得走神了。下车没两步,我摔了一交,结结实实的。手中的电脑包抛了老远,我一下子倒在了路边,脑子嗡响了一下,暂时的记忆就没了。大约有那么两三秒,也许是我摔倒的动静太大了,感觉周围的目光都在朝我这边看,一时间的尴尬,没顾得上身上的土,站起来就往住的方向猛走

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号