S.M.A.R.T. Disk Monitoring

Incorporating S.M.A.R.T. allows most modern disks to be monitored during their operation. This article shows how to perform periodic tests, monitor parameters and report unusual events to an operator by e-mail.

Should work in all Ubuntu releases. Tested from 8.04 (Hardy Heron) to 10.10 (Maverick Meerkat) on Ubuntu Server & Desktop 32/64-bit.

sudo apt-get install smartmontools

Log on and become root:

sudo -s

Edit the file /etc/default/smartmontools and un-comment the following line:

start_smartd=yes

Next, edit /etc/smartd.conf and make the following changes:

#DEVICESCAN -m root -M exec /usr/share/smartmontools/smartd-runner

/dev/sda -d ata -a \
-W 2,35,40 \
-s (O/../../7/01|L/../../7/03|C/../../7/05) \
-m user@example.net -M diminishing -M test

/dev/sdb -d ata -a \
-W 2,35,40 \
-s (O/../../7/02|L/../../7/04|C/../../7/06) \
-m user@example.net -M diminishing -M test

The options for each drive are described below or in more detail on the smartd.conf man page:

Parameter Description
-d Specify the device type: 'ata', 'scsi', 'sat', 'marvell', 'cciss,N', 'areca,N', 'megaraid,N' or '3ware,N' where:
N is the controller number
-a Enable monitoring of the specified device
-W Monitor drive temperature in ÂșC as DIFF,INFO,CRIT where:
DIFF is the number of degrees change reported
INFO is a warning alarm level
CRIT is critical alarm temperature
-s Schedule one or more tests (separated by |) as T/MM/DD/d/HH where:
T is 'L' for Long, 'S' for Short, 'C' for Conveyance or 'O' for an Offline Immediate Self-Test
MM is the month of the year
DD is the day of the month
d is the day of the week, from 1 (Monday) to 7 (Sunday) inclusive
HH is the hour of the day, in 24 hour format
-m Specifies one or more (comma separated, without spaces) e-mail recipients
-M Specifies the type of warnings to be sent:
'once' send only one warning e-mail for each type of disk problem detected
'daily' send additional warning reminder e-mails, once per day, for each type of disk problem detected
'diminishing' send additional warning reminder e-mails, after a one-day interval, then a two-day interval, then a four-day interval, and so on for each type of disk problem detected
'test' send a single test e-mail immediately upon smartd startup
'exec PATH' run the executable PATH instead of the default mail command, when smartd needs to send e-mail

Start the monitoring daemon:

service smartmontools start

Check the test e-mail messages are received at the address specified, then edit /etc/smartd.conf to remove the -M test parameter and restart the daemon to run it normally:

service smartmontools restart