Monitor Hard Drive Health on Linux with SMART Tools
- Last updated: Sep 26, 2025
Introduction to SMART monitoring on Linux
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 13 trixie
- smartmontools: 7.4
How to Install smartmontools
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>
Configure Email Alerts for SMART Disk Failures
It’s a best practice to configure smartmontools to send email alerts when a disk shows warning signs. Below is a minimal setup using the lightweight msmtp
client.
Install msmtp
- Install
msmtp
:
root@host:~# apt update && apt install msmtp
Configure /etc/msmtprc
Edit the /etc/msmtprc
file and adapt it to your SMTP provider. Below is an example configuration for SMTP over TLS on port 465. Replace the placeholders with your real server details:
- Mail server:
mail.example.com
- Protocol: SMTP over TLS (port 465)
- Login:
smart@std.rocks
- Password: use an app-specific password or
passwordeval
(avoid plain text)
account STD
#Mail Server :
host mail.std.rocks
port 465
from smart@std.rocks
#LOGIN / PASSWORD
user smart@std.rocks
password MyWeakPassword
auth on
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
tls_certcheck off
logfile /var/log/msmtp
account default : STD
Create the notifier script
Create the file /usr/local/sbin/smartdnotify.sh
. This script will be executed by smartd
whenever a warning or error occurs, and it will send an email through msmtp
:
#!/bin/sh
# Send email
LANG=C
rm -f /tmp/mailsmart.header
echo "From: $SMARTD_ADDRESS" >> /tmp/mailsmart.header
echo "To: smart@std.rocks" >> /tmp/mailsmart.header
echo "Date: "`/bin/date -R` >> /tmp/mailsmart.header
echo "Subject: $SMARTD_FAILTYPE" >> /tmp/mailsmart.header
echo "Content-type: text/plain; charset=utf-8" >> /tmp/mailsmart.header
echo "Content-Disposition: inline" >> /tmp/mailsmart.header
echo "Content-Transfer-Encoding: 8bit" >> /tmp/mailsmart.header
echo "MIME-Version: 1.0" >> /tmp/mailsmart.header
echo "" >> /tmp/mailsmart.header
echo "$SMARTD_MESSAGE" >> /tmp/mailsmart.header
cat /tmp/mailsmart.header | /usr/bin/msmtp -f smart@std.rocks smart@std.rocks
rm -f /tmp/mailsmart.header
- Set the right permissions so that
smartd
can execute the notifier script:
root@host:~# chmod +x /usr/local/sbin/smartdnotify.sh
- Edit the
/etc/smartd.conf
file and add aDEVICESCAN
directive. This will scan all available drives and run the notifier on alerts:
# The word DEVICESCAN will cause any remaining lines in this
# configuration file to be ignored: it tells smartd to scan for all
# ATA and SCSI devices. DEVICESCAN may be followed by any of the
# Directives listed below, which will be applied to all devices that
# are found. Most users should comment out DEVICESCAN and explicitly
# list the devices that they wish to monitor.
DEVICESCAN -m smart@std.rocks -M exec /usr/local/sbin/smartdnotify.sh
- Restart the
smartd
service
root@host:~# systemctl restart smartd