Software RAID Status & Monitoring (Linux)

For Linux Dedicated Servers with software RAID

You can check the status of a software RAID array with the command cat /proc/mdstat.

Below is an example of the output if both disks are present and correctly mounted:

cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md2 : active raid1 sda3[1] sdb3[0]
262016 blocks [2/2] [UU]

md1 : active raid1 sda2[1] sdb2[0]
119684160 blocks [2/2] [UU]

md0 : active raid1 sda1[1] sdb1[0]
102208 blocks [2/2] [UU]

unused devices: <none>

The example shows three RAID arrays (md0, md1, md2). On the second line for each device, the state of each partition is shown within square brackets at the end. A U means that the respective device is up, or functional.

If a disk is down (not functioning), the output looks similar to the following:

cat /proc/mdstat
Personalities : [raid1]
read_ahead 1024 sectors
md0 : active raid1 sda1[1]
102208 blocks [2/1] [_U]

md2 : active raid1 sda3[1]
262016 blocks [2/1] [_U]

md1 : active raid1 sda2[1]
119684160 blocks [2/1] [_U]

unused devices: <none>

With only one disk up for each array, you can see that something is wrong here. The sdb disk is not functioning.

RAID Array Details

The command mdadm -D /dev/md1 provides detailed information about the md1 array.

An example of the output for a working RAID array is below.

mdadm -D /dev/md1
/dev/md1:
Version : 0.90
Creation Time : Tue Sep 11 21:33:24 2012
Raid Level : raid1
Array Size : 4194240 (4.00 GiB 4.29 GB)
Used Dev Size : 4194240 (4.00 GiB 4.29 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 1
Persistence : Superblock is persistent

Update Time : Wed Jun 10 11:11:05 2015
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

UUID : 2db35cef:bde058e8:1f51fb89:78ee93fe
Events : 0.251

Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1

If there is a missing disk, the output is similar to the following:

mdadm -D /dev/md0
/dev/md0:
Version : 00.90.00
Creation Time : Thu Aug 21 12:22:43 2003
Raid Level : raid1
Array Size : 102208 (99.81 MiB 104.66 MB)
Device Size : 102208 (99.81 MiB 104.66 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Fri Oct 15 06:25:45 2004
State : dirty, no-errors
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0


Number Major Minor RaidDevice State
0 0 0 0 faulty removed
1 3 1 1 active sync /dev/sda1
UUID : f9401842:995dc86c:b4102b57:f2996278

RAID Monitoring

The mdadm utility can also be run as a demon. By adding an email address to the /etc/mdadm.conf file, error messages will be sent to the address if there is a disk failure.

MAILADDR account@example.com
Example:

In this example, the option --daemonise runs the monitoring program continuously in the background, checking the array every 300 seconds. If an event occurs, an email will be sent to the address specified in /etc/mdadm.conf. Errors will also be reported in the system log file.

 ./mdadm --monitor --mail=root@localhost --syslog --delay=300 /dev/md0 --daemonise