How to Check Hard Drive Health on Linux (SMART, smartctl and Early Warnings)

Drives rarely die without warning. They log reallocated sectors, read errors and temperature for months first, and that data — SMART — is a smartctl command away. Read it once now, and let smartd watch it and email you so a failing drive becomes a planned swap rather than a lost weekend.
Quick reference
| Task | Command |
|---|---|
| Install | sudo apt install smartmontools -y |
| Quick verdict | sudo smartctl -H /dev/sda |
| Full report | sudo smartctl -a /dev/sda |
| NVMe | sudo smartctl -a /dev/nvme0 |
| Short self-test | sudo smartctl -t short /dev/sda (2 minutes) |
| Long self-test | sudo smartctl -t long /dev/sda (hours) |
| Automatic monitoring | /etc/smartd.conf + sudo systemctl enable --now smartd |
1. Install and get the verdict
sudo apt install smartmontools -y
lsblk -d
sudo smartctl -H /dev/sda
"SMART overall-health self-assessment test result: PASSED" is the headline. FAILED means replace it today. But PASSED isn't a clean bill — drives only say FAILED when they're nearly dead. Read the details.
2. The attributes that matter (spinning drives)
sudo smartctl -a /dev/sda
Look at the RAW_VALUE column for these:
| ID | Attribute | Good value |
|---|---|---|
| 5 | Reallocated_Sector_Ct | 0 — any growth means the drive is wearing out |
| 187 | Reported_Uncorrect | 0 |
| 188 | Command_Timeout | 0 or small |
| 197 | Current_Pending_Sector | 0 — sectors waiting to be reallocated |
| 198 | Offline_Uncorrectable | 0 |
| 194 | Temperature_Celsius | under 45 |
| 9 | Power_On_Hours | just informational (43,800 = 5 years) |
A drive with 5 and 197 at zero after years of use is healthy. If either starts climbing, order a replacement.
3. SSDs and NVMe
sudo smartctl -a /dev/nvme0
NVMe reports differently: Percentage Used (wear, 100% = rated life consumed — they usually go well past it), Available Spare, Media and Data Integrity Errors (should be 0) and Critical Warning (should be 0x00). SATA SSDs show similar things as Wear_Leveling_Count or Percent_Lifetime_Remain.
4. Run a self-test
sudo smartctl -t short /dev/sda
Two minutes later, sudo smartctl -l selftest /dev/sda shows the result. A long test reads the whole surface and takes hours — run it on a new drive before trusting it, and monthly on drives that hold backups.
5. Let smartd watch and email you
With msmtp set up (tutorial 49):
sudo nano /etc/smartd.conf
Comment out the DEVICESCAN line that's there, and add:
DEVICESCAN -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -W 4,40,45 -m you@example.com -M exec /usr/share/smartmontools/smartd-runner
That means: monitor everything, short test nightly at 2 am, long test Saturdays at 3 am, warn if temperature rises 4° or passes 40°/45°, email on any problem.
sudo systemctl enable --now smartd
sudo smartctl -t short /dev/sda # and check an email arrives if you add -M test to the line temporarily
USB drives
External drives behind a USB adapter sometimes need -d sat: sudo smartctl -a -d sat /dev/sdb. Some cheap adapters don't pass SMART at all.
Troubleshooting
"Unable to detect device type". Try -d sat (USB) or -d nvme.
Attributes show but PASSED with Pending sectors > 0. Back up now, run a long test, and if the number doesn't drop to zero, replace the drive.
smartd emails every day about temperature. Raise the -W thresholds, or add a fan — a drive that lives at 48° will not live long.
Drive is "failing" but the data's fine. Good — that's the point. Copy it off while it still reads.
Wrapping up
smartctl -H for the verdict, -a for the attributes that actually predict failure, a long test on anything new, and smartd emailing you from then on. Replace drives when the numbers start moving, not when they stop.
