指令 #smartctl – http://benjr.tw/95984 是透過硬碟本身所提供的 S.M.A.R.T. (Self-Monitoring Analysis and Reporting Technology )技術 ,他可以根據檢測屬性的結果來決定該顆硬碟的使用是否快故障.
測試環境為 Ubuntu14.04 x86_64.
-s VALUE, –smart=VALUE
Enables or disables SMART on device. The valid arguments to this option are on and off.
當開啟磁碟的 SMART 功能時就會進行線上測試,不會對效能有影響
root@ubuntu:~# smartctl -s on /dev/sda
-o VALUE, –offlineauto=VALUE
[ATA only] Enables or disables SMART automatic offline test
自動離線測試可以利用參數 -o 來開啟,系統會以不影響效能的前提下進行測試.
單次的離線測試可以利用 -t offline 立即執行離線測試.
root@ubuntu:~# smartctl -o on /dev/sda
root@ubuntu:~# smartctl --t offline /dev/sda
我們可以透過 #smartctl 提供的參數 -t 來進行self-testing 自我測試.
-t TEST, –test=TEST
root@ubuntu:~# smartctl -t /dev/sdb smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-24-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org =======> INVALID ARGUMENT TO -t: /dev/sdb =======> VALID ARGUMENTS ARE: offline, short, long, conveyance, force, vendor,N, select,M-N, pending,N, afterselect,[on|off] ======= Use smartctl -h to get a usage summary
來試試看 short , long 測試,測試會在背景執行,需要透過 -l selftest 來觀看目前的測試進度與結果.
root@ubuntu:~# smartctl -t short /dev/sdb smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-24-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org Short Background Self Test has begun Use smartctl -X to abort test
root@ubuntu:~# smartctl -t long /dev/sdb smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-24-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org Extended Background Self Test has begun Please wait 34 minutes for test to complete. Estimated completion time: Tue Nov 1 16:15:59 2016 Use smartctl -X to abort test
root@ubuntu:~# smartctl -l selftest /dev/sdb smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-24-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === Self-test execution status: 96% of test remaining SMART Self-test log Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ] Description number (hours) # 1 Background long Self test in progress ... - NOW - [- - -] # 2 Background short Completed - 19184 - [- - -] Long (extended) Self Test duration: 2040 seconds [34.0 minutes]
這些測試到底測了什麼? 參考文章 https://www.thomas-krenn.com/en/wiki/SMART_tests_with_smartctl#Short_Test
The goal of the short test is the rapid identification of a defective hard drive. Therefore, a maximum run time for the short test is 2 min. The test checks the disk by dividing it into three different segments. The following areas are tested:
- Electrical Properties: The controller tests its own electronics, and since this is specific to each manufacturer, it cannot be explained exactly what is being tested. It is conceivable, for example, to test the internal RAM, the read/write circuits or the head electronics.
- Mechanical Properties: The exact sequence of the servos and the positioning mechanism to be tested is also specific to each manufacturer.
- Read/Verify: It will read a certain area of the disk and verify certain data, the size and position of the region that is read is also specific to each manufacturer.
- Extended (or Long; a short check with complete disk surface examination)
The long test was designed as the final test in production and is the same as the short test with two differences. The first: there is no time restriction and in the Read/Verify segment the entire disk is checked and not just a section. The Long test can, for example, be used to confirm the results of the short tests.
This test can be performed to determine damage during transport of the hard disk within just a few minutes.
- Select Tests
During selected tests the specified range of LBAs is checked. The LBAs to be scanned are specified in the following formats:
# sudo smartctl -t select,10-20 /dev/sdc # sudo smartctl -t select,10+11 /dev/sdc
It is also possible to have multiple ranges, (up to 5), to scan:
# sudo smartctl -t select,0-10 -t select,5-15 -t select,10-20 /dev/sdc