Smartmontools and Smartctl Cheatsheet

Modern storage drives come with the Self-Monitoring, Analysis and Reporting Technology, or SMART for short. This is a monitoring system that detects and reports on various indicators of drive reliability, with the intent of enabling the anticipation of hardware failures. Smartmontools is the package that installs the smartctl command that you can use to take advantage of this functionality.

Installation (Ubuntu)

sudo apt-get install smartmontools -y

Fetch Information About A Device

sudo smartctl -i /dev/sd[x]

Example output:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.19.0-49-generic] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Red (AF)
Device Model:     WDC WD30EFRX-68EUZN0
Serial Number:    WD-WCC4N1TD13LC
LU WWN Device Id: 5 0014ee 26102d3aa
Firmware Version: 82.00A82
User Capacity:    3,000,592,982,016 bytes [3.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Sun Feb  7 10:39:16 2016 GMT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Check health

sudo smartctl -H /dev/sd[x]

SMART status is based on information that it has gathered from online and offline tests. Hence, I wouldn't rely on this alone, and would run one of the tests below and check it's output.

Example output:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.19.0-49-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

List Tests and Durations.

sudo smartctl -c /dev/sd[x]

The output of the command will contain within it the test details:

...
Short self-test routine 
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 410) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.
...

Run a small test

sudo smartctl -t short /dev/sd[x]

Example output:

smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.19.0-49-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 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 Sun Feb  7 10:46:37 2016

Use smartctl -X to abort test.

Run a Long Test

sudo smartctl -t long /dev/sd[x]

Check Test Progress

There is no check to see how much progress has been made, but if you try to execute the test again, you will see:

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Can't start self-test without aborting current test (10% remaining),
add '-t force' option to override, or run 'smartctl -X' to abort test.

Which does give you an indication of progress.

List test Results

sudo smartctl -l selftest /dev/sd[x]

Obviously if you see no results, you know that the test hasn't yet completed.

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus