Howtos - Setting up SMART Hard Drive Monitoring
[edit] Overview
Knowing the condition of your hard drive's is important - especially if you've lost data to a drive crash before. SMART is a self monitoring technology for hard drives that can warn of the drive's problems before complete failure.
Smartmontools is a utility that will run on Linux and allows you to have an emailed alert sent to you when the utility notices problematic drive conditions.
[edit] Installing Smartmontools
Smartmontools are in the default repositories for CC, but is not installed by default, so we need to do a bit of command line tinkering to get it to work.
Ok, ssh in as root and install the kernel-utils package (smartmontools is part of this, along with lmsensors and a few other bits). Mailx is the /bin/mail command so you can be warned of impending doom by email.
# apt-get install kernel-utils mailx
[edit] Testing Smartmontools
Now you can check the health of your hard drives by using smartctl like this:
smartctl -a /dev/hda
(Prints all SMART information)
smartctl --smart=on --offlineauto=on --saveauto=on /dev/hda
(Enables SMART on first disk)
smartctl -t long /dev/hda
(Executes extended disk self-test)
smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hda
(Prints Self-Test & Attribute errors)
You can learn more by reading the man page for smartctl Code:
# man smartctl
[edit] Automating Smartmontools
While it can be handy to manually check the status of the drives, I'm sure you want to enable automatic monitoring and testing of your hard drives.
 |
Warning! |
 |
| |
 |
|
You must have the mail server module installed and configured to send mail for the emails to be delivered. Setting up the email server is beyond the scope of this howto and can be found elsewhere in the help documentation.
|
|
Please start up the smtp mail server through the web interface (the server needs to be on for mailing to work).
To automate SmartMonTools we need to create a /etc/smartd.conf file with the following information in it:
# Sample configuration file for smartd. See man smartd.conf.
DEVICESCAN -S on -o on -a -I 194 -m email@domain.com -s (S/../.././02|L/../../6/03)
The options above automatically scan all hard drives fitted, switch on smart monitoring, ignore data bit 194 (which corresponds to the hard drive temperature, which changes a great deal, and you don't want to get an email every time), sends warning emails to the mail address specified, and schedules short selftests every morning after 0200 and long selftests Saturdays between 0300 and 0400.
Now start the smartd service as follows:
# service smartd start
Smartd should start automatically next time you reboot.
To make sure all is well go and check your messages log for smartd information:
# grep smartd /var/log/messages
You should see a bunch of initialisation information, followed by any changes to the smart parameters. Small changes are not a concern, but a trend in one or more parameters (especially moving towards the threshold seen in the list produced by smartctl -A /dev/hda) is of concern.
To test the mail feature of smartd change the smartd.conf line to:
# Sample configuration file for smartd. See man smartd.conf.
DEVICESCAN -S on -o on -a -I 194 -m email@domain.com -M test -s (S/../.././02|L/../../6/03)
Restart smartd like this
# service smartd restart
Check your email to make sure you received the email, remove the '-M test' from smartd.conf and restart the service to resume normal monitoring.
|