Quick Hack: Smartctl tests in a nutshell

by on Nov.19, 2019, under Hardware, Miscellaneous, Quick Hacks

This quick hack is a quick “need to know” list of Linux’s smartctl commands for hard drive diagnosis. I highly recommend using a USB drive dock for analyzing suspect drives. These commands are OS agnostic provided you’re running the vendor provided smartctl for either Linux or BSD.

For the purposes of this article, /dev/sdb is the drive under test. Make sure you know which /dev entry corresponds with the desired drive.

smartctl -a /dev/sdb Shows all smart attributes of /dev/sdb including test results, and drive make, model, and serial number.

smartctl -t short /dev/sdb Performs a “short” online test of /dev/sdb. Does not print test results. Does not test disk surface readability.

smartctl -t long /dev/sdb Performs a “long” offline test of /dev/sdb. Does not print test results. Tests the entire disk surface for readability and reallocates bad sectors. If your system is under a lot of disk I/O to the disk under test, this will cause the test to take longer to complete (hence running it in a USB dock or other non-system location)

smartctl -c /dev/sdb Estimates how long the disk check will take in minutes (Usually is wrong though, I wouldn’t set my watch by it.)

smartctl -l selftest /dev/sdb Shows the SMART test results table (instead of smartctl -a which shows EVERYTHING).

smartctl -X /dev/sdb Cancels a test in progress.

NOTES: Re-running smartctl -t against a drive already testing will show an error message which includes how long the test will take to complete (unlike smartctl -l, this time is actually more closer to reality).

In some installations that support it, hdparm -S 0 /dev/sdb will prevent a disk from going to sleep, however in theory, the disk should never sleep if it’s under an active test. This will not stop an ACPI sleep or hibernate event from shutting down the disk.

Happy hacking!
FIRESTORM_v1

:,

Comments are closed.