Configure smartd monitoring
To automate these alerts on Linux, you can use the smartd daemon (part of smartmontools). It runs in the background and can be configured to email you or run a script the moment an attribute like Current_Pending_Sector or Offline_Uncorrectable changes.
ArchWiki
ArchWiki
+4
1. Configure the smartd Daemon
The main configuration file is typically located at /etc/smartd.conf.
Die.net
Die.net
Open the file: sudo nano /etc/smartd.conf
Add a monitoring line: You can monitor all drives or a specific one (e.g., /dev/sda). A robust configuration looks like this:
text
/dev/sdX -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -m your-email@example.com -M test
Use code with caution.
-a: Monitors all SMART properties (including the error counts you’re watching).
-o on / -S on: Enables automatic offline data collection and attribute persistence.
-s ...: Schedules a Short self-test every day at 2 AM and a Long test every Saturday at 3 AM.
-m: Sends an email to the specified address if an error is detected.
-M test: Sends a test email immediately when the service starts to confirm your alerting works.
LinuxConfig
LinuxConfig
+4
2. Set Up Email (MTA)
For the -m flag to work, your system needs a way to send mail (a Mail Transfer Agent like msmtp, postfix, or ssmtp).
LinuxConfig
LinuxConfig
+1
If you don't want to set up a full mail server, msmtp is a popular lightweight choice for forwarding alerts to a Gmail or Outlook account.
LinuxConfig
LinuxConfig
3. Desktop Notifications (Alternative)
If this is a desktop machine and you'd prefer a popup over an email:
Install smart-notifier (on Debian/Ubuntu: sudo apt install smart-notifier).
Modify your smartd.conf line to include: -M exec /usr/share/smartmontools/smartd-runner.
Unix & Linux Stack Exchange
Unix & Linux Stack Exchange
4. Apply Changes
After saving your configuration, restart the service to begin monitoring:
bash
sudo systemctl enable smartd
sudo systemctl restart smartd
Use code with caution.
Check journalctl -u smartd to ensure the "test" alert was triggered successfully.
ArchWiki
ArchWiki
Would you like the msmtp configuration steps to link this to your personal email account?
undefined
undefined
undefined
13 sites
Configure smartd Email Notifications Easily - LinuxConfig
Oct 7, 2020 — Table_title: The smartd daemon Table_content: header: | Directive | Use | row: | Directive: -H | Use: Checks the SMART health stat...
LinuxConfig
S.M.A.R.T. - ArchWiki
Dec 3, 2025 — The smartd daemon monitors SMART statuses and emits notifications when something goes wrong. It can be managed with systemd and co...
ArchWiki
Best practices to enable SMART disk notifications on a Linux ...
Jul 30, 2021 — I installed smartmontools and smart-notifier. # apt-get install smartmontools smart-notifier. I then configured the smartd daemon ...
Unix & Linux Stack Exchange
Show all
yes
To link smartd to your personal email (using Gmail as an example), you must create a global configuration for msmtp and generate a dedicated app password for security.
LinuxConfig
LinuxConfig
+1
1. Generate a Gmail App Password
Standard passwords will not work due to security protocols.
Go to your Google Account Security settings.
Enable 2-Step Verification if it isn't already.
Select App passwords (usually at the bottom of the "Signing in to Google" section).
Choose "Other (Custom name)" and enter "smartd alerts".
Copy the 16-character code generated; you will need this for the configuration file.
arnaudr.io
arnaudr.io
+4
2. Configure msmtp
Install the package first if you haven't already: sudo apt install msmtp msmtp-mta.
Create/edit the global configuration file: sudo nano /etc/msmtprc.
Medium
Medium
+2
text
# Set default values for all following accounts.
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log
# Gmail configuration
account gmail
host smtp.gmail.com
port 587
from your-email@gmail.com
user your-email@gmail.com
password your-app-password-no-spaces
# Set a default account
account default : gmail
Use code with caution.
Note: Ensure the file has secure permissions so other users cannot read your password: sudo chmod 600 /etc/msmtprc.
Medium
Medium
+1
3. Link smartd to msmtp
By default, smartd looks for a generic mail command. Since you installed msmtp-mta, it should provide a compatible symlink. However, to be explicit, ensure your /etc/smartd.conf includes the -m flag with your email.
LinuxConfig
LinuxConfig
+2
4. Test the Connection
Verify your configuration manually before relying on it for drive failures:
bash
echo "Subject: SMART Test" | msmtp -a default your-email@gmail.com