rss logo

Monitor Hard Drive Health on Linux with SMART Tools

Intro

According to Wikipedia, S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) is a monitoring system built into most hard disk drives (HDDs) and solid-state drives (SSDs). It is designed to detect and report various indicators of drive reliability, helping to anticipate potential hardware failures.

In this guide, we’ll see how to read SMART attributes using the smartctl tool on GNU/Linux systems.

Configuration

  • OS: Debian 12 Bookworm
  • smartmontools: 7.3

Installing

Install smartmontools from the official Debian repositories:

root@host:~# apt update && apt install smartmontools

Commands

Basic Commands

  • Check if SMART is enabled:
root@host:~# smartctl -i /dev/<device>
  • Enable SMART support:
root@host:~# smartctl -s on /dev/<device>
  • Display all SMART attributes:
root@host:~# smartctl -a /dev/<device>
  • Check critical attributes. In the example below, a disk failure is imminent:
root@host:~# smartctl -a /dev/<device> | grep -Ei "Reallocated|Spin.*Retry|SATA*Downshift|End-to-End|Reported.*Uncorrectable|Timeout|Reallocation|Current.*Pending|Uncorrect|TA.*Counter|Drive.*Life.*Protection"
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       408
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0032   075   075   000    Old_age   Always       -       25
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0

Check with RAID Controller

Dell PERC Controller

  • Check disk number 8 behind the MegaRAID controller:
root@host:~# smartctl -a -d megaraid,8 /dev/sda

HP Smart Array Controller

  • Check disk number 1 behind the CCISS controller:
root@host:~# smartctl -a -d cciss,0 /dev/sda

Run SMART Tests

This section shows how to perform various SMART self-tests on a disk.

Short Test

  • Quick test with a high probability of detecting hardware problems:
root@host:~# smartctl -t short /dev/<device>

Long Test

  • Performs a full surface scan of the entire disk:
root@host:~# smartctl -t long /dev/<device>

Conveyance Test

  • Detects possible damage during transportation of the device:
root@host:~# smartctl -t conveyance /dev/<device>

Check Current Test Status

  • View progress or results of ongoing or completed self-tests:
root@host:~# smartctl -l selftest /dev/<device>

Print Health Summary

  • Display a quick health status of the disk:
root@host:~# smartctl -H /dev/<device>

Check for Errors

  • Review logs of previous tests and recorded errors:
root@host:~# smartctl -l selftest /dev/<device>
root@host:~# smartctl -l error /dev/<device>