For Dedicated Server Linux
You can read the status of the software RAID in the shell with the command cat /proc/mdstat.
All commands are exemplary and must be adapted accordingly!
First, an example of a status message if both disks are present and correctly mounted:
Personalities : [raid1] read_ahead 1024 sectors md2 : active raid1 sda3 sdb3 262016 blocks [2/2] [UU] md1 : active raid1 sda2 sdb2 119684160 blocks [2/2] [UU] md0 : active raid1 sda1 sdb1 102208 blocks [2/2] [UU] unused devices: <none>
The example shows three RAID arrays (md0, md1, md2). In the second line, the state of each partition is shown in square brackets at the end. A U means that the respective device is in order (up).
If a disk is missing (here sdb), the output looks similar to the following:
Personalities : [raid1] read_ahead 1024 sectors md0 : active raid1 sda1 102208 blocks [2/1] [_U] md2 : active raid1 sda3 262016 blocks [2/1] [_U] md1 : active raid1 sda2 119684160 blocks [2/1] [_U] unused devices: <none>
By[_U] you can see that something is wrong here.
Show details about RAID device
The command mdadm -D /dev/md1 provides detailed information about a RAID device
Here is an example of a working RAID:
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
Mdadm can also be started as a demon. By adding the /etc/mdadm.conf file line
is configured, an error message is sent by email in the event of a disk failure.
The array should be checked every 300 seconds. If an event occurs, an email should be sent and the event noted in the system log file. The option --daemonise runs the monitoring program continuously in the background. So the command would look like this:
./mdadm --monitor --mail=root@localhost --syslog --delay=300 /dev/md0 --daemonise