Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

Install smartmontools

SystemCommand
Debian, Ubuntusudo apt install smartmontools
AlmaLinux, Rocky Linuxsudo dnf install smartmontools

The package provides smartctl for manual checks and smartd for monitoring. List the drives it can see with sudo smartctl --scan.

Quick Health Check

sudo smartctl -H /dev/sda
sudo smartctl -H /dev/nvme0

The answer is the drive's own overall verdict, PASSED or FAILED. FAILED means replace the drive now. PASSED is weaker than it sounds: many drives that fail soon still pass, so read the attributes too.

The Full Report

sudo smartctl -a /dev/sda

It shows the model, serial number, and firmware, whether SMART is enabled, the attribute table, the error log, and past self-test results. -x prints even more, and the smartctl manual recommends it over -a for SATA drives. If SMART is reported as disabled, try turning it on with sudo smartctl -s on /dev/sda.

Attributes That Matter on SATA Drives

Each attribute has a normalized VALUE, a WORST, a THRESH, and a RAW_VALUE. For the first four below, read the raw value: on a healthy drive it is usually 0, and any number that grows is a warning. SAS drives print a different report without this table.

  • Reallocated sectors (ID 5): sectors the drive has replaced with spares.
  • Pending sectors (ID 197): sectors that could not be read and wait to be remapped.
  • Offline uncorrectable (ID 198): sectors the drive could not recover during its own scans.
  • UDMA CRC errors (ID 199): transfer errors, often a cable or backplane rather than the drive.
  • Power-on hours (ID 9): the drive's age in use, for context rather than as a warning.

Attribute names and meanings vary a little between makers; the IDs above are widely used.

NVMe Drives

sudo smartctl -a /dev/nvme0
FieldWatch for
Critical WarningAnything but 0
Available SpareNear its threshold
Percentage UsedClose to 100%
Media and Data Integrity ErrorsAbove 0, or rising

Percentage Used estimates how much of the rated write endurance is spent. It can pass 100%, and the drive may keep working, but plan its replacement well before.

Self-Tests

sudo smartctl -t short /dev/sda
sudo smartctl -t long /dev/sda
sudo smartctl -l selftest /dev/sda

The short test takes a few minutes, the long test reads the whole surface and can take hours on a large disk; smartctl prints an estimate. Both run inside the drive while the server keeps working. The last command shows the results. From smartmontools 7.4 on, smartctl also runs self-tests on NVMe drives that support them; older versions do not.

Continuous Monitoring with smartd

smartd checks the drives on a schedule and reports problems. Its file is /etc/smartd.conf on Debian and Ubuntu and /etc/smartmontools/smartd.conf on AlmaLinux and Rocky Linux. smartd ignores every line after a DEVICESCAN line, so replace the existing one with:

DEVICESCAN -a -o on -S on -s (S/../.././02|L/../../6/03) -m YOUR_EMAIL

watches every drive, runs a short test daily at 02:00 and a long test on Saturdays at 03:00, and mails warnings. Then enable the service and restart it so it reads the file:

sudo systemctl enable smartmontools   # Debian, Ubuntu
sudo systemctl restart smartmontools
sudo systemctl enable smartd          # AlmaLinux, Rocky Linux
sudo systemctl restart smartd

Mail needs a working setup, as in how to send email from the Linux command line.

Drives Behind a RAID Controller

A hardware RAID controller hides the drives. smartctl reaches many of them with -d, for example sudo smartctl -a -d megaraid,0 /dev/sda for the first drive on such a controller. Software RAID members are plain disks; see software RAID with mdadm.

Why a VPS Shows No SMART Data

A cloud server's disk is virtual: the physical drives belong to the host, and the virtual disk reports no SMART data, so smartctl says it is unavailable. The provider monitors the hardware. On a VPS, watch the kernel log with dmesg and disk performance with how to check disk I/O in Linux. When a physical drive shows warnings, back up first, then replace it.

Was this answer helpful?
Loading...