SmartMonTools:我如何知道硬盘上是否正在运行任何smartctl测试?


40

我正在用SmartMonTools 测试硬盘

测试之前的硬盘状态(仅几天前执行的简短测试):

$ sudo smartctl -l selftest /dev/sda
smartctl 6.2 2013-07-26 r3841 [i686-linux-3.16.0-30-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== 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%      5167         -

所以我开始了漫长的测试

$ sudo smartctl -t long /dev/sda
smartctl 6.2 2013-07-26 r3841 [i686-linux-3.16.0-30-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== 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 130 minutes for test to complete.
Test will complete after Sat May  9 16:05:27 2015

Use smartctl -X to abort test.

该测试应该正在运行,但是,如果我尝试查看其进度:

$ sudo smartctl -l selftest /dev/sda
smartctl 6.2 2013-07-26 r3841 [i686-linux-3.16.0-30-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== 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%      5167         -

...我得到的都是相同的结果,就像现在没有运行/执行测试一样。
'-H'参数不提供更多信息:

$ sudo smartctl -H /dev/sda
smartctl 6.2 2013-07-26 r3841 [i686-linux-3.16.0-30-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

而且,只要没有进程在运行(此测试仅由硬盘控制器执行),某些ps -e样式搜索都将无济于事。

怎么知道现在是否正在运行一些SMART自检

Answers:


43

smartctl -a <device>Self-test execution status

没有运行测试的示例:

Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.

测试正在运行的示例:

Self-test execution status:      ( 249) Self-test routine in progress...
                                        90% of test remaining.

运行选择性自检(-t select)时,此处还会显示进度:

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA    MAX_LBA  CURRENT_TEST_STATUS
    1        0  125045423  Self_test_in_progress [90% left] (2881512-2947047)

2
一个好主意。我建议您添加此直线(通过grepping)作为一种可能性:smartctl -a /dev/sda | grep "progress" -i -A 1,以减少过多的信息打印输出。
Sopalajo de Arrierez,2015年

1
您需要过多的打印输出才能获得整个图像。在脚本grep的可能被罚款,但谁是用来人grep的一切命令行(上dmesg | grep somethingsmartctl -a | grep ...等等),他们将错过的东西。随着smartctl特别是有没有简单的命令,告诉你一切都没有问题...... smartctl -H是这方面的一个虚假的朋友。
弗罗斯特斯

@frostschutz“在这方面,smartctl -H是虚假的朋友。” 你可以再说一遍!我也曾经一次选择这个选项,以为它可能与自我测试有关……但是没有,完全不同的主题(和目的)。
语法错误

对于“设备不支持自检日志”,我该怎么办?
Mr.WorshipMe'7

13

尝试:

smartctl -c /dev/sda

如果/ dev / sda是​​您要检查的驱动器。


编辑:对不起。我错了。-c表示--capabilities,但它也显示当前的测试进度。喜欢60% of test remaining.
JPT
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.