Linux command – smartctl 測試

Loading

指令 #smartctl – https://benjr.tw/95984 是透過硬碟本身所提供的 S.M.A.R.T. (Self-Monitoring Analysis and Reporting Technology )技術 ,他可以根據檢測屬性的結果來決定該顆硬碟的使用是否快故障.

測試環境為 Ubuntu14.04 x86_64.

Online-Testing

-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

Offline-Testing

-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

Self-Testing

我們可以透過 #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

  • Short
    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:

    1. 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.
    2. Mechanical Properties: The exact sequence of the servos and the positioning mechanism to be tested is also specific to each manufacturer.
    3. 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.
  • Conveyance
    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
    
沒有解決問題,試試搜尋本站其他內容

One thought on “Linux command – smartctl 測試

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料