ELS Howto: Disk Monitoring


Synopsis

This document explains how to monitor the health of your hard disks and RAID arrays using the smartd and mdadm utilities included in the Elemental Linux Server (ELS) distribution.


Prerequisites

Both disk monitoring utilities send email status messages. You should complete the ELS Howto: Local Mail before starting this document.


Installation

The tools smartd and mdadm are included in the ELS base packages. No installation is required.


Configuration

The following steps explain how to configure smartd and mdadm for your system. If you do not use disk mirroring, you may skip the steps for mdadm.

  1. Edit /etc/smartmontools/smartd.conf and append the line /dev/sdX -a -m root -M test (where /dev/sdX refers to the first hard disk in your system.)
  2. Append a similar line for any other hard disks in your system.
  3. If you use disk mirroring, edit /etc/mdadm.conf and make the following changes:
  4. Configure smartd for automatic start-up.
  5. If you use mirroring, configure mdadm for automatic start-up.

Example

The following example shows changes made to smartd.conf and mdadm.conf on a system with two hard disks, with three mirrored partitions each, as well as the commands needed to allow automatic starting at system boot-up.

vi /etc/smartmontools/smartd.conf

/dev/sda -a -m root -M test
/dev/sdb -a -m root -M test

vi /etc/mdadm.conf

ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1
ARRAY /dev/md1 devices=/dev/sda2,/dev/sdb2
ARRAY /dev/md2 devices=/dev/sda3,/dev/sdb3
MAILADDR root 

chmod +x /etc/init.d/smartd
chmod +x /etc/init.d/mdadm

Note

See the smartd.conf(5) and mdadm.conf(5) man pages for additional configuration assistance.


Testing

Test the setup by starting the daemons and checking for syslog and email messages. Remember that the email will not be sent to root, but rather the user defined in /etc/aliases. See the ELS Howto: Local Mail for details.

Below is an example of a successful test.

login: root
password:

# /etc/init.d/smartd start
Disk health monitor is starting.
# /etc/init.d/mdadm start
RAID status monitor is starting.

# tail /var/log/syslog
smartd: Device: /dev/sda, opened
smartd: Device: /dev/sda, found in smartd database.
smartd: Device: /dev/sda, is SMART capable. Adding to "monitor" list.
smartd: Device: /dev/sdb, opened
smartd: Device: /dev/sdb, found in smartd database.
smartd: Device: /dev/sdb, is SMART capable. Adding to "monitor" list.
smartd: Monitoring 0 ATA and 2 SCSI devices
smartd: Executing test of mail to root ...
smartd: Test of mail to root: successful
smartd: Executing test of mail to root ...
smartd: Test of mail to root: successful
smartd: smartd has fork()ed into background mode.
mdadm: NewArray event detected on md device /dev/md2
mdadm: TestMessage event detected on md device /dev/md2
mdadm: NewArray event detected on md device /dev/md1
mdadm: TestMessage event detected on md device /dev/md1
mdadm: NewArray event detected on md device /dev/md0
mdadm: TestMessage event detected on md device /dev/md0

# exit

login: joe
password:

$ mailx
Heirloom mailx version 12.3 7/15/07.  Type ? for help.
"/var/spool/mail/joe": 1 message 1 new
>N  1 Super User         Thu Aug 28 15:24   32/1171  SMART error (EmailTest)
 N  2 Super User         Thu Aug 28 15:24   32/1171  SMART error (EmailTest)
 N  3 mdadm monitoring   Thu Aug 28 15:25   26/1001  TestMessage event on /dev
 N  4 mdadm monitoring   Thu Aug 28 15:25   26/1001  TestMessage event on /dev
 N  5 mdadm monitoring   Thu Aug 28 15:25   26/1001  TestMessage event on /dev
?

If the tests are not successful, here are some troubleshooting steps to try.

  1. Check to see that the daemons are running using the command ps -ef.
  2. Review the ELS Howto: Local Mail and verify that mail delivery is successful.
  3. Verify that your disk drive is SMART capable.

Additional help may be found in the smartd(8) and mdadm(8) man pages.