Guides

smartctl: check disk health on a Linux server with smartmontools

How to use smartctl to check disk health on Linux: -H and -x, the SMART attributes that matter, NVMe health, self-tests, RAID controllers and smartd alerts.

Published ~8 min read
On this page

Short answer: install smartmontools, then sudo smartctl -H /dev/sda prints the drive's own PASSED or FAILED verdict and sudo smartctl -x /dev/sda (or /dev/nvme0) prints everything else: attributes, error logs and self-test results. Run it on every physical disk of a dedicated server; on a VPS the disk is virtual and has no SMART data.

Debian · Ubuntu (dnf install smartmontools on Rocky Linux)
sudo apt install smartmontools
sudo smartctl --scan              # the disks smartctl can see, with their type
sudo smartctl -i /dev/sda         # model, serial, firmware, SMART on or off
sudo smartctl -H /dev/sda         # overall health: PASSED or FAILED!
sudo smartctl -x /dev/sda         # everything the drive reports
sudo smartctl -x /dev/nvme0       # the same for an NVMe drive

Debian 12 ships smartmontools 7.3 (7.4 in bookworm-backports), Debian 13 ships 7.4, and the newest upstream release is 7.5 from May 2025. smartctl is not installed on the server this was written on, so this page shows no captured output: the options, field names and messages come from the smartctl(8), smartd(8) and smartd.conf(5) manuals of smartmontools 7.4 and from the smartmontools source.

smartctl -i: which drive is it, and is SMART on?

-i prints the model, serial number, firmware and capacity, and whether the drive supports SMART and has it enabled. It also says whether the model is in smartctl's drive database, which decides how vendor attributes are named; update-smart-drivedb refreshes it. If SMART is supported but disabled, sudo smartctl -s on /dev/sda turns it on. SATA and SAS disks are /dev/sda, /dev/sdb and so on; NVMe drives are /dev/nvme0 for the controller or /dev/nvme0n1 for a namespace. lsblk -o NAME,MODEL,SERIAL matches the names to the drives.

smartctl -H: PASSED does not mean healthy

For SATA drives -H reports the drive's answer to the SMART RETURN STATUS command. FAILED means the drive has failed or predicts its own failure within 24 hours: copy the data off now. For NVMe, smartctl prints PASSED exactly when the Critical Warning byte is zero. The catch is the other direction: PASSED only means the drive does not predict its failure within a day. The verdict is computed by the drive's firmware, and a disk with a rising count of bad sectors can still answer PASSED, so read the attributes as well.

In scripts, use the exit status, a bitmask documented in smartctl(8). Bits only report what the command actually read, so ask for the logs too. 8 means "DISK FAILING", 16 a pre-fail attribute at or below its threshold, 64 errors in the device error log and 128 errors in the self-test log.

bash
sudo smartctl -a /dev/sda > /dev/null    # -a reads the health, error and self-test logs
rc=$?
[ $((rc & 8)) -ne 0 ] && echo "sda: DISK FAILING"
[ $((rc & 128)) -ne 0 ] && echo "sda: self-test log has errors"

SATA hard disks and SSDs: the attributes that matter

ATA attribute table
sudo smartctl -A /dev/sda
sudo smartctl -A /dev/sda | grep -E '^ *(5|187|197|198|199) '

Each row has a normalized VALUE and WORST (vendor scaled, higher is better), the vendor's THRESH, a TYPE (Pre-fail or Old_age) and WHEN_FAILED, which reads FAILING_NOW or In_the_past once the value has reached the threshold. For the counters below, ignore the normalized columns and read RAW_VALUE, the actual count. The names are the ones smartctl prints by default:

IDName in smartctlA non-zero raw value meansWhat to do
5Reallocated_Sector_CtSectors the drive has already swapped for sparesA small, stable number can be watched; a rising one means the surface is failing
187Reported_UncorrectErrors the drive could not correct and reported to the hostCheck backups, plan a replacement
197Current_Pending_SectorSectors that could not be read and wait to be rewritten or remappedRun a long test; smartd warns about it by default
198Offline_UncorrectableSectors found unreadable during offline scansTreat like 197; smartd warns by default
199UDMA_CRC_Error_CountTransfer errors between drive and controllerPoints at the interface: reseat or replace the cable or backplane slot, then watch whether it still rises

Once a pending sector is written again, it either reads fine and simply drops out of 197, or the drive remaps it and attribute 5 goes up by one; the smartmontools Bad block HOWTO walks through both cases. SATA SSDs report wear under vendor specific IDs (smartctl calls ID 177 Wear_Leveling_Count by default), and some also report a Percentage Used Endurance Indicator in the device statistics that smartctl -x prints.

NVMe drives: the health log

NVMe
sudo smartctl -H -A /dev/nvme0
sudo nvme smart-log /dev/nvme0     # the same log through nvme-cli
FieldMeaningWorry when
Critical WarningBit field set by the drive; smartctl lists each bit that is set: spare below threshold, temperature, reliability degraded, media read-only, volatile memory backup failedAnything but 0x00
Available SpareSpare capacity left, in percent, next to the Available Spare ThresholdIt approaches the threshold
Percentage UsedThe vendor's estimate of how much of the rated endurance is usedIt approaches 100
Media and Data Integrity ErrorsUnrecovered data integrity errorsAny non-zero value
Unsafe ShutdownsPower losses without a clean shutdownIt rises without a known power cut

Temperature, power-on hours and data written are in the same log. The NVMe on Linux section shows the nvme-cli side of these fields.

Short and long self-tests

SATA and SAS
sudo smartctl -c /dev/sda              # estimated duration of each test
sudo smartctl -t short /dev/sda        # usually under ten minutes
sudo smartctl -t long /dev/sda         # tens of minutes to several hours
sudo smartctl -l selftest /dev/sda     # results, newest first
sudo smartctl -X /dev/sda              # abort a running test

The test runs inside the drive and the command returns at once; the server keeps working, although heavy I/O slows the test and the test can slow the disk a little. A shutdown during a test does no harm. In the log, the columns are Num, Test_Description, Status, Remaining, LifeTime(hours) and LBA_of_first_error. Completed without error is what you want; Completed: read failure with an LBA means the drive hit a sector it could not read.

Disks behind a RAID controller or a USB bridge

With software RAID (mdadm) or a controller in HBA mode, every disk is its own /dev/sdX: check each member, not just one. A hardware RAID controller shows the system one logical drive, and SMART data for the physical disks has to be requested through the controller with -d:

smartctl -d
sudo smartctl --scan                          # names and types smartctl detects
sudo smartctl -a -d megaraid,0 /dev/sda       # MegaRAID and Dell PERC, physical disk 0
sudo smartctl -a -d megaraid,1 /dev/sda       # physical disk 1, and so on
sudo smartctl -a -d cciss,0 /dev/sg2          # HP Smart Array (hpsa driver), disk 0
sudo smartctl -a -d sat /dev/sdb              # SATA disk behind a SCSI to ATA bridge, e.g. USB

For HP Smart Array the device is the controller's SCSI generic node, and lsscsi -g shows which /dev/sg number that is. SAS disks print a different report: there is no ATA attribute table, and the line to watch is Elements in grown defect list, the SAS counterpart of reallocated sectors.

smartd: an email before the disk dies

smartd, from the same package, checks the disks every 30 minutes by default and logs or mails what changes. On Debian its unit is smartmontools.service (Ubuntu 24.04 ships a smartd.service next to it), and Debian's /etc/smartd.conf has one active line:

/etc/smartd.conf · Debian default
DEVICESCAN -d removable -n standby -m root -M exec /usr/share/smartmontools/smartd-runner

That monitors every disk found, does not wake disks in standby and mails root, which only arrives if the server can send mail. For more control, list the disks yourself. -a turns on the health check, attribute tracking, the error and self-test logs and, on SATA drives, the warnings for attributes 197 and 198:

/etc/smartd.conf · one line per disk
/dev/sda   -a -s (S/../.././02|L/../../6/03) -W 4,45,55 -m admin@example.com
/dev/sdb   -a -s (S/../.././03|L/../../7/03) -W 4,45,55 -m admin@example.com
/dev/nvme0 -a -W 4,65,75 -m admin@example.com
# behind a MegaRAID controller:
# /dev/sda -d megaraid,0 -a -s L/../../6/04 -m admin@example.com
  • -s matches T/MM/DD/d/HH: S/../.././02 runs a short test every day at 02:00, L/../../6/03 a long test on Saturdays (1 is Monday, 7 is Sunday) at 03:00. Keep the hour at two digits, or it never matches.
  • -W 4,45,55 logs a change of 4 degrees, logs an info message at 45 °C and a critical one with mail at 55 °C. The numbers are examples; take the limits from the drive's data sheet.
  • Add -M test to one line to get a test mail when smartd starts, then remove it. Apply changes with sudo systemctl restart smartmontools.

Why SMART does not work on a VPS

Inside a VPS the disk is a virtual device that the hypervisor emulates. The physical drives belong to the host and are monitored there, so smartctl has nothing to query in the guest. What you can check on a VPS is space and speed: the disk usage guide and disk speed tests with fio cover both. A file system that suddenly turns read-only is the symptom to watch on either kind of server.

On a dedicated server the drives are yours, which makes smartctl part of the routine: check every disk when the server is handed over, as in the first hour checklist, save the -x output as a baseline, and leave smartd running so a rising counter reaches you by mail rather than as a failed array.

Frequently asked

How do I check if a hard drive is failing in Linux?

Install smartmontools and run sudo smartctl -H /dev/sda for the drive's own verdict, then sudo smartctl -A /dev/sda for the attributes. Rising raw values for Reallocated_Sector_Ct, Reported_Uncorrect, Current_Pending_Sector or Offline_Uncorrectable mean the disk is degrading even while the verdict still says PASSED. A long self-test with smartctl -t long confirms it.

What is the difference between smartctl -a and smartctl -x?

-a prints the SMART information: health, identity, capabilities, attributes and the error and self-test logs. -x prints all SMART and non-SMART information, and for SATA drives it adds the logs that need 48-bit commands, such as the extended error and self-test logs, device statistics and temperature history. The manual no longer recommends -a for ATA disks for that reason.

Can I use smartctl on a VPS?

No. A VPS disk is a virtual device emulated by the hypervisor, so the guest has no SMART data to read, and the physical drives are monitored on the host. smartctl is a tool for dedicated servers and other machines where the operating system sees the real drives.

How do I read SMART data for disks behind a hardware RAID controller?

Address each physical disk through the controller with -d: smartctl -a -d megaraid,N /dev/sda for MegaRAID and Dell PERC controllers, or -d cciss,N with the controller's /dev/sg device for HP Smart Array. With software RAID or an HBA, every disk is a normal /dev/sdX and needs no -d option.

Related articles

All guides