Introduction
Manual disk diagnostics is time-consuming and is often performed too late. SMART (Self-Monitoring, Analysis and Reporting Technology) allows drives to track wear parameters independently, but without automation, this data goes unnoticed until a critical failure occurs.
By configuring the smartd daemon, you will get continuous monitoring without system load. The utility will automatically run short and full tests, record attribute anomalies, and send alerts before the disk stops responding.
Prerequisites
Before you begin, ensure you have:
rootaccess orsudoprivileges on the server/workstation.- A system with the
systemdinit manager (modern Linux distributions). - A physical or virtual drive that supports SMART (in most hypervisors, SMART is passed through only with explicit configuration).
- The
mailutilspackage or an alternative MTA installed if you plan to receive email notifications.
Step 1: Installing the smartmontools Package
The utilities are included in the standard repositories of most distributions. Execute the installation command corresponding to your OS:
# Debian, Ubuntu, Linux Mint
sudo apt update && sudo apt install smartmontools
# RHEL, CentOS, AlmaLinux, Rocky Linux
sudo dnf install smartmontools
# Arch Linux, Manjaro
sudo pacman -S smartmontools
The package installs smartctl for manual diagnostics and smartd for background operation.
Step 2: Identifying Drives and Checking SMART Support
First, find the devices the daemon will work with. Request a list via the terminal:
sudo smartctl --scan
The output will contain paths to devices and their interface type. Example:
/dev/sda -d scsi # /dev/sda, SCSI device
Check if SMART is enabled on the target disk:
sudo smartctl -i /dev/sda | grep "SMART support"
If the output shows SMART support is: Enabled, proceed to configuration. If it shows Available but disabled, enable it: sudo smartctl -s on /dev/sda.
⚠️ Important: Virtual disks like
virtioorqcow2often do not pass SMART data to the host system. Use controller passthrough or check disks directly on the hypervisor.
Step 3: Configuring the Schedule in the Configuration File
The daemon reads parameters from /etc/smartd.conf. Open the file in an editor:
sudo nano /etc/smartd.conf
Find the line starting with DEVICESCAN, or add a new one for a specific disk. The recommended configuration includes a short daily test and a full weekly test:
/dev/sda -a -o on -S on -s (S/../.././02|L/../../6/03) -W 4,45,55 -m root -M exec /usr/share/smartmontools/smartd-runner
Parameter breakdown:
-a— monitor all key health attributes.-o on -S on— enable offline tests and log saving.-s (S/../.././02|L/../../6/03)— schedule:S(Short) daily at 02:00,L(Long) every Saturday at 03:00.-W 4,45,55— warn when temperature thresholds are exceeded.-m root— send alerts to the root user.
Step 4: Starting and Managing the Daemon
After saving the configuration, restart the service to apply the settings:
sudo systemctl daemon-reload
sudo systemctl enable --now smartd
Ensure the process is running without errors:
sudo systemctl status smartd
The line Active: active (running) confirms a successful start. The daemon will automatically calculate the time until the next test and run checks in the background without interfering with user activity.
Verifying the Result
To ensure the scheduler is working, check the service log:
sudo journalctl -u smartd --since "1 hour ago" -f
You should see entries about device scanning and schedule confirmation. To force-run a test without waiting for nighttime, execute:
sudo smartctl -t short /dev/sda
After 2-5 minutes, check the execution status:
sudo smartctl -l selftest /dev/sda
A record Completed without error or an error code requiring attention will appear in the table.
Potential Issues
Error Device does not support SMART
Common on old USB flash drives, RAID controllers without passthrough, or in virtual machines. Check your hypervisor's documentation or connect the disk directly to a SATA/NVMe port.
Daemon hangs on Opening device...
Often caused by conflicts with other software (e.g., hdparm or active I/O operations). Add the -n standby flag to the configuration to make smartd skip sleeping disks, or use -d sat for SATA devices connected via USB bridges.
Missing email notificationssmartd does not send emails itself but invokes the system mail. Ensure a local MTA is configured and accepting messages. For testing, run: echo "test" | mail -s "smartd test" root and check /var/mail/root or your mailbox.