Setting up Software RAID / MDADM status alert Emails for failed drives in Centos, Ubuntu, and Debian

email alerts photo

Photo by Jonathon Narvey Creative Commons Logo

Issues regarding software and hardware raid are no stranger to the IOFlood blog, with articles discussing the relative merits of each, articles discussing why raid is important (and so are backups), and so on. But RAID only provides protection against failed drives if you realize a drive has failed and replace it. Often times, a failed drive will go unnoticed until after the backup drive has also failed. Needless to say, this can lead to data loss, and so getting early notifications of failed drives is very important in RAID.In this article, we will give you a brief overview of how to configure email based alerts for software raid / MDADM under Centos, Ubuntu, and Debian. Setting this up is an important part of any data security strategy. The steps are relatively easy, but it’s always good to have a working reference to look at if you don’t do this every day. So without further ado…..

Easy instructions for setting up mdadm / software raid email alerts for failed drives in Centos, Ubuntu, and Debian:

First off, start by editing the following file.On Centos:
nano /etc/mdadm.conf
On Debian / Ubuntu:
nano /etc/mdadm/mdadm.conf
Make sure the configuration file it has the following line in it. If it doesn’t, copy and paste it in there:
DEVICE partitions
Also add to this file the email address you’d like to have receive notifications:
MAILADDR [email protected]
And then save the file and exit.Next we run the process and make sure it runs without error.
/sbin/mdadm --monitor --scan --daemonize
If this works correctly, we will want to make sure that this command runs at boot time. Edit the following file:
nano /etc/rc.local
And copy and paste the line near the end of the file:
/sbin/mdadm --monitor --scan --daemonize
WARNING: The last line in /etc/rc.local for Debian (and possibly Ubuntu installs) is “exit 0” so you need to make sure that the command above goes BEFORE that line otherwise it will never run.Finally, if you’d like to test that emails are being sent properly, you can run the following command:
/sbin/mdadm --monitor --scan --test
This will send you an email regarding the current status of your raid arrays. Be sure to whitelist these emails so that when a real raid alert comes in, your email provider doesn’t send it to your spam box!
That’s it! You’ve now set up your server to send you email alerts whenever a failure event occurs in MDADM / software raid. The above instructions should work equally well for Centos, Ubuntu, and Debian. This is an easy, but often overlooked, important first step in ensuring your data security.In a future article, we’ll be discussing how to set up raid alerts for LSI-9271 hardware raid (hint: it’s not as easy), so stay tuned if you use LSI hardware raid cards.

Do you love servers?

If you love servers like we do, we’d love to work together! IOFLOOD.com offers dedicated servers to people like you, and as part of that service, we configure alerts to notify us if there are any problems with your raid array, so that we can help you avoid an array failure. To get started today, click here to view our dedicated servers, or email us at sales[at]ioflood.com to ask for a custom quote.