How to setup a RAID5 software (mdadm) array w/ email notifications via Gmail – the easy way

December 7, 2008

Long title I know…
So I finally setup a NAS using Ubuntu Intrepid (8.10) Desktop, at first I was looking into using a pre-built solution such as FreeNAS or Openfiler but that limited the boxes ability to do other things (like serving up webpages using LAMP, etc.) besides I like having a Desktop GUI that I can play with if things go wrong.  So after figuring out what version of Ubuntu to use (Hardy for it’s LTS or Intrepid for latest and greatest) I decided on Intrepid.

My setup:
MoBo: Intel D865GBF Desktop Board
CPU: P4 3.0Ghz
RAM: 4x1GB G.Skill Sticks
VIDEO: FX5200 AGP card
IDE1: Seagate 250GB (ST380013A)
IDE2: Maxtor 250GB (Diamond Max Plus9)
SATA1: Western Digital 320GB (WD3200JD-22KLB0)
SATA2: Seagate 200GB (ST300822AS) – ***UBUNTU INSTALLED ON THIS ONE***

So I will be using IDE1,IDE2, & SATA1 for my RAID5 Array.

After a quick shout to the Ubuntu Community I found this wonderfully simple guide on setting up a RAID5 array using mdadm: http://bfish.xaedalus.net/?p=188

I did however run into one problem with the guide:

sudo mdadm –detail –scan >> /etc/mdadm/mdadm.conf

Which adds the following to my mdadm.conf file:

ARRAY /dev/md0 level=raid5 num-devices=3 metadata=00.90 UUID=13f95aef:9c364189:75b10d3a:87a53e2f

but after I’ve added that to the mdadm.conf and when I run the following:

sudo mdadm –examine –scan
mdadm: metadata format 00.90 unknown, ignored.
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=13f95aef:9c364189:75b10d3a:87a53e2f

Notice: mdadm: metadata format 00.90 unknown, ignored.
So I had to remove “metadata=00.90” from my mdadm.conf file and I no longer get that message.
Anyone know why the metadata entry isn’t working?

And now on to setting up email notifications via Gmail – The easy way…

After spending literally hours trying to get postfix working and running into problems getting the SSL CA certificates working I gave up on postfix all together and started looking for an alternative, and after a few google searches I found one: http://www.manu-j.com/blog/wordpress-exim4-ubuntu-gmail-smtp/75/

This guide walks you thru setting up exim4 to work with Gmail, and it works perfectly, the only problem I ran into with this guide was that you need to comment out the whole “login:” section of /etc/exim4/exim4.conf.template like so:

#Commented out so that Gmail’s Public_name can equal “LOGIN”
#login:
# driver = plaintext
# public_name = LOGIN
#.ifndef AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS
# Return empty string if not non-TLS AND looking up $host in passwd-file
# yields a non-empty string; fail otherwise.
# client_send = “<; ${if and{\
# {!eq{$tls_cipher}{}}\
# {!eq{PASSWDLINE}{}}\
# }\
# {}fail}\
# ; ${extract{1}{::}{PASSWDLINE}}\
# ; ${sg{PASSWDLINE}{\\N([^:]+:)(.*)\\N}{\\$2}}”
#.else
# Return empty string if looking up $host in passwd-file yields a
# non-empty string; fail otherwise.
# client_send = “<; ${if !eq{PASSWDLINE}{}\
# {}fail}\
# ; ${extract{1}{::}{PASSWDLINE}}\
# ; ${sg{PASSWDLINE}{\\N([^:]+:)(.*)\\N}{\\$2}}”
#.endif
#####################################################
### end auth/30_exim4-config_examples
#####################################################

Now simply edit your /etc/mdadm/mdadm.conf file to read:

# instruct the monitoring daemon where to send mail alerts
MAILADDR {YourEmailAddress_Where-you-want-mdadm-notifications-sent@email.com}

Now you should be all set give it a test by running:

sudo mdadm –monitor –scan –test

And you should have an email within minutes 😀

Advertisements