Managing RAID on Linux - Derek Vadala [74]
In addition to Fail and FailSpare, mdadm reports the following events to the program specified on the command line using --program= or in /etc/mdadm.conf.
DeviceDisappeared mddevice
An array that was active during the last poll is no longer active.
NewArray mddevice
An array that was inactive during the last poll is now active.
RebuildStarted mddevice
The array has begun reconstruction.
Rebuild[20,40,60,80] mddevice
The percentage complete for an array that is undergoing resynchronization or reconstruction. The status is reported at 20, 40, 60, and 80 percent.
SpareActive mddevice spare-disk
A spare disk that was inserted to replace a failed disk has been activated, meaning that the rebuild process has completed.
MoveSpare mddevice mddevice
A spare disk has been moved from one array to another.
Event names and device information is passed to the receiving program as command-line options. So if you decide to develop your own monitoring utilities, parsing the command line passed to your script or program will provide you with the event, the md device name, and in some cases, the name of a spare disk or additional md device. To get an idea of how the events work, I suggest using echo as the program to execute:
# nohup mdadm --monitor --program=/bin/echo &
The previous example creates the file nohup.out in the current directory or in your home directory. Because we have set echo as the event program to execute, mdadm will print any event information to nohup.out.
The next example imports an email address and event program from /etc/mdadm.conf and polls all arrays listed in the configuration file every thirty seconds:
# nohup mdadm --monitor --scan --delay=30 &
Name
Manage and Miscellaneous modes
Synopsis
mdadm [options] mddevice memberdevices
mdadm mddevice [options] memberdevices
mdadm [options] memberdevices
mdadm [options]
The remaining options fall into the loosely defined categories of Manage and Miscellaneous modes. For the most part, these options work individually, but some of them can be combined to provide additional functionality. Many of these options are used on arrays, while some of them are used directly on member disks. See the Example usage section that follows for some common tasks.
Options
-Q, --query
Queries an array or member disk to determine array properties, member disk properties, or both in cases when an array is also a member disk (in a hybrid array, for example). --query displays very brief information: array size, RAID level, and status. For member disks, it displays the disk sequence instead of the array size.
-D, --detail
Prints verbose details about an active array.
-E, --examine
Prints the contents of the md superblock from a member disk. This is usually a single device, but in the case of hybrids, it can also be an array.
-b, --brief
When combined with either --detail or -examine, generates a configuration file entry for an array. When combined with --detail, an active array is queried and used to generate the configuration entry. When combined with --examine, the RAID superblock is read from a member disk and used to generate the configuration entry. In general, it's best to use the --detail form when possible because on-disk superblocks could occasionally contain incorrect information.
-s, --scan
When combined with --detail or --examine, provides results similar to --brief. The difference in this case is that --scan queries multiple arrays or member disks and generates /etc/mdadm.conf entries for each array it discovers. mdadm --detail --scan looks for active arrays in /proc/mdstat and generates configuration file entries for each array. mdadm --examine --scan looks for a list of potential member disks in /etc/mdadm.conf, reads the RAID superblock from each disk, and then generates a configuration line for each unique array. See the /etc/mdadm.conf section, later in this chapter, for more information.
-S, --stop
Stops a running array. Equivalent to the raidtools command raidstop.
-a, --add
Adds a disk to an