Linux Blog


Section: File Formats (5)
Index Return to Main Contents


mdadm.conf - configuration for management of Software Raid with mdadm  




mdadm is a tool for creating, managing, and monitoring RAID devices using the md driver in Linux.

Some common tasks, such as assembling all arrays, can be simplified by describing the devices and arrays in this configuration file.



The file should be seen as a collection of words separated by white space (space, tab, or newline). Any word that beings with a hash sign (#) starts a comment and that word together with the remainder of the line is ignored.

Any line that starts with white space (space or tab) is treated as though it were a continuation of the previous line.

Empty lines are ignored, but otherwise each (non continuation) line must start with a keyword as listed below. The keywords are case insensitive and can be abbreviated to 3 characters.

The keywords are:

A device line lists the devices (whole devices or partitions) that might contain a component of an MD array. When looking for the components of an array, mdadm will scan these devices (or any devices listed on the command line).

The device line may contain a number of different devices (separated by spaces) and each device name can contain wild cards as defined by glob(7).


Alternatively, a device line can contain the word partitions. This will cause mdadm to read /proc/partitions and include all devices and partitions found there-in. mdadm does not use the names from /proc/partitions but only the major and minor device numbers. It scans /dev to find the name that matches the numbers.

If no DEVICE line is present, then "DEVICE partitions" is assumed.

For example:

DEVICE /dev/hda* /dev/hdc*
DEV /dev/sd*
DEVICE /dev/discs/disc*/disc
DEVICE partitions

The ARRAY lines identify actual arrays. The second word on the line should be the name of the device where the array is normally assembled, such as /dev/md1. Subsequent words identify the array, or identify the array as a member of a group. If multiple identities are given, then a component device must match ALL identities to be considered a match. Each identity word has a tag, and equals sign, and some value. The tags are:

The value should be a 128 bit uuid in hexadecimal, with punctuation interspersed if desired. This must match the uuid stored in the superblock.
The value should be a simple textual name as was given to mdadm when the array was created. This must match the name stored in the superblock on a device for that device to be included in the array. Not all superblock-formats support names.
The value is an integer which indicates the minor number that was stored in the superblock when the array was created. When an array is created as /dev/mdX, then the minor number X is stored.
The value is a comma separated list of device names or device name patterns. Only devices with names which match one entry in the list will be used to assemble the array. Note that the devices listed there must also be listed on a DEVICE line.
The value is a raid level. This is not normally used to identify an array, but is supported so that the output of

mdadm --examine --scan

can be use directly in the configuration file.

The value is the number of devices in a complete active array. As with level= this is mainly for compatibility with the output of

mdadm --examine --scan.

The value is a number of spare devices to expect the array to have. mdadm --monitor will report an array if it is found to have fewer than this number of spares when --monitor starts or when --oneshot is used.

The value is a textual name for a group of arrays. All arrays with the same spare-group name are considered to be part of the same group. The significance of a group of arrays is that mdadm will, when monitoring the arrays, move a spare drive from one array in a group to another array in that group if the first array had a failed or missing drive but no spare.

This option declares to mdadm that it should try to create the device file of the array if it doesn't already exist, or exists but with the wrong device number.

The value of this option can be "yes" or "md" to indicate that a traditional, non-partitionable md array should be created, or "mdp", "part" or "partition" to indicate that a partitionable md array (only available in linux 2.6 and later) should be used. This later set can also have a number appended to indicate how many partitions to create device files for, e.g. auto=mdp5. The default is 4.

The option specifies a file in which a write-intent bitmap should be found. When assembling the array, mdadm will provide this file to the md driver as the bitmap file. This has the same function as the --bitmap-file option to --assemble.

Specify the metadata format that the array has. This is mainly recognised for comparability with the output of mdadm -Es.

The mailaddr line gives an E-mail address that alerts should be sent to when is running in --monitor mode (and was given the --scan option). There should only be one MAILADDR line and it should have only one address.

The mailfrom line (which can only be abbreviate at leat 5 characters) gives an address to appear in the "From" address for alert mails. This can be useful if you want to explicitly set a domain, as the default from address is "root" with no domain. All words on this line are catenated with spaces to form the address.

Note that this value cannot be set via the mdadm commandline. It is only settable via the config file.

The program line gives the name of a program to be run when mdadm --monitor detects potentially interesting events on any of the arrays that it is monitoring. This program gets run with two or three arguments, they being the Event, the md device, and possibly the related component device.

There should only be one program line and it should be give only one program.

The create line gives default values to be used when creating arrays and device entries for arrays. These include:

These can give user/group ids or names to use instead of system defaults (root/wheel or root/disk).
An octal file mode such as 0660 can be given to override the default of 0600.
This corresponds to the --auto flag to mdadm. Give yes, md, mdp, part - possibly followed by a number of partitions - to indicate how missing device entries should be created.

The name of the metadata format to use if none is explicitly given. This can be useful to impose a system-wide default of version-1 superblocks.

Normally when creating devices in /dev/md/ mdadm will create a matching symlink from /dev/ with a name starting md or md_. Give symlinked=no to suppress this symlink creation.



DEVICE /dev/sd[bcdjkl]1
DEVICE /dev/hda1 /dev/hdb1

# /dev/md0 is known by it's UID.
# 1 in the superblock.
ARRAY /dev/md1 superminor=1
# /dev/md2 is made from precisey these two devices

# can be moved between them
ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df

ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977

# any spare device number is allocated.


MAILADDR root@mydomain.tld
PROGRAM /usr/sbin/handle-mdadm-events
CREATE group=system mode=0640 auto=part-8
HOMEHOST <system>



mdadm(8), md(4).




Random Man Pages: