4 mdadm \- manage MD devices
10 .BI mdadm " [mode] <raiddevice> [options] <component-devices>"
13 RAID devices are virtual devices created from two or more
14 real block devices. This allows multiple devices (typically disk
15 drives or partitions there-of) to be combined into a single device to
16 hold (for example) a single filesystem.
17 Some RAID levels include redundancy and so can survive some degree of
20 Linux Software RAID devices are implemented through the md (Multiple
21 Devices) device driver.
23 Currently, Linux supports
36 .B MULTIPATH is not a Software RAID mechanism, but does involve
39 each device is a path to one common physical storage device.
43 is a program that can be used to create, manage, and monitor
45 such it provides a similar set of functionality to the
48 The key differences between
55 is a single program and not a collection of programs.
58 can perform (almost) all of its functions without having a
59 configuration file and does not use one by default. Also
61 helps with management of the configuration
65 can provide information about your arrays (through Query, Detail, and Examine)
75 configuration file, at all. It has a different configuration file
76 with a different format and an different purpose.
79 mdadm has 6 major modes of operation:
82 Assemble the parts of a previously created
83 array into an active array. Components can be explicitly given
84 or can be searched for.
86 checks that the components
87 do form a bona fide array, and can, on request, fiddle superblock
88 information so as to assemble a faulty array.
92 Build a legacy array without per-device superblocks.
96 Create a new array with per-device superblocks.
98 '''in several step create-add-add-run or it can all happen with one command.
102 This is for doing things to specific components of an array such as
103 adding new spares and removing faulty devices.
107 This mode allows operations on independent devices such as examine MD
108 superblocks, erasing old superblocks and stopping active arrays.
111 .B "Follow or Monitor"
112 Monitor one or more md devices and act on any state changes. This is
113 only meaningful for raid1, 4, 5, 6 or multipath arrays as
114 only these have interesting state. raid0 or linear never have
115 missing, spare, or failed drives, so there is nothing to monitor.
120 Available options are:
123 .BR -A ", " --assemble
124 Assemble a pre-existing array.
128 Build a legacy array without superblocks.
136 Examine a device to see
137 (1) if it is an md device and (2) if it is a component of an md
139 Information about what is discovered is presented.
143 Print detail of one or more md devices.
146 .BR -E ", " --examine
147 Print content of md superblock on device(s).
150 .BR -F ", " --follow ", " --monitor
157 Display help message or, after above option, mode specific help
162 Display more detailed help about command line parsing and some commonly
166 .BR -V ", " --version
167 Print version information for mdadm.
170 .BR -v ", " --verbose
171 Be more verbose about what is happening.
175 Be less verbose. This is used with
182 Be more forceful about certain operations. See the various modes of
183 the exact meaning of this option in different contexts.
186 .BR -c ", " --config=
187 Specify the config file. Default is
188 .BR /etc/mdadm.conf .
189 If the config file given is
191 then nothing will be read, but
193 will act as though the config file contained exactly
194 .B "DEVICE partitions"
197 to find a list of devices to scan.
200 is given for the config file, then
202 will act as though the config file were empty.
208 for missing information.
209 In general, this option gives
211 permission to get any missing information, like component devices,
212 array devices, array identities, and alert destination from the
214 .BR /etc/mdadm.conf .
215 One exception is MISC mode when using
221 says to get a list of array devices from
224 .SH For create or build:
228 Specify chunk size of kibibytes. The default is 64.
232 Specify rounding factor for linear array (==chunk size)
236 Set raid level. When used with
238 options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4,
239 raid5, 5, raid6, 6, multipath, mp. Obviously some of these are synonymous.
243 only linear, raid0, 0, stripe are valid.
246 .BR -p ", " --parity=
247 Set raid5 parity algorithm. Options are:
252 la, ra, ls, rs. The default is left-symmetric.
259 .BR -n ", " --raid-devices=
260 Specify the number of active devices in the array. This, plus the
261 number of spare devices (see below) must equal the number of
263 (including "\fBmissing\fP" devices)
264 that are listed on the command line. Setting a value of 1 is probably
265 a mistake and so requires that
267 be specified first. A value of 1 will then be allowed for linear,
268 multipath, raid0 and raid1. It is never allowed for raid4 or raid5.
270 Note that this number cannot be changed once the array has been created.
273 .BR -x ", " --spare-devices=
274 Specify the number of spare (eXtra) devices in the initial array.
275 Spares can also be added
276 and removed later. The number of component devices listed
277 on the command line must equal the number of raid devices plus the
278 number of spare devices.
283 Amount (in Kibibytes) of space to use from each drive in RAID1/4/5/6.
284 This must be a multiple of the chunk size, and must leave about 128Kb
285 of space at the end of the drive for the RAID superblock.
286 If this is not specified
287 (as it normally is not) the smallest drive (or partition) sets the
288 size, though if there is a variance among the drives of greater than 1%, a warning is
295 uuid of array to assemble. Devices which don't have this uuid are
299 .BR -m ", " --super-minor=
300 Minor number of device that array was created for. Devices which
301 don't have this minor number are excluded. If you create an array as
302 /dev/md1, then all superblocks will contain the minor number 1, even if
303 the array is later assembled as /dev/md2.
305 Giving the literal word "dev" for
309 to use the minor number of the md device that is being assembled.
313 will look for super blocks with a minor number of 0.
317 Assemble the array even if some superblocks appear out-of-date
321 Attempt to start the array even if fewer drives were given than are
322 needed for a full array. Normally if not all drives are found and
324 is not used, then the array will be assembled but not started.
327 an attempt will be made to start it anyway.
330 .BR -U ", " --update=
331 Update the superblock on each device while assembling the array. The
332 argument given to this flag can be one of
340 option will adjust the superblock of an array what was created on a Sparc
341 machine running a patched 2.2 Linux kernel. This kernel got the
342 alignment of part of the superblock wrong. You can use the
343 .B "--examine --sparc2.2"
346 to see what effect this would have.
350 option will update the
352 field on each superblock to match the minor number of the array being
353 assembled. This is not needed on 2.6 and later kernels as they make
354 this adjustment automatically.
358 option will correct the summaries in the superblock. That is the
359 counts of total, working, active, failed, and spare devices.
366 hotadd listed devices.
370 remove listed devices. They must not be active. i.e. they should
371 be failed or spare devices.
375 mark listed devices as faulty.
381 .SH For Examine mode:
385 In an array was created on a 2.2 Linux kernel patched with RAID
386 support, the superblock will have been created incorrectly, or at
387 least incompatibly with 2.4 and later kernels. Using the
391 will fix the superblock before displaying it. If this appears to do
392 the right thing, then the array can be successfully assembled using
393 .BR "--assemble --update=sparc2.2" .
399 start a partially built array.
403 deactivate array, releasing all resources.
406 .BR -o ", " --readonly
407 mark array as readonly.
410 .BR -w ", " --readwrite
411 mark array as readwrite.
415 If the device contains a valid md superblock, the block is
416 over-written with zeros. With
418 the block where the superblock would be is over-written even if it
419 doesn't appear to be valid.
427 is set to reflect the status of the device.
429 .SH For Monitor mode:
432 Give a mail address to send alerts to.
435 .BR -p ", " --program ", " --alert
436 Give a program to be run whenever an event is detected.
440 Give a delay in seconds.
442 polls the md arrays and then waits this many seconds before polling
443 again. The default is 60 seconds.
446 .BR -f ", " --daemonise
449 to run as a background daemon if it decides to monitor anything. This
450 causes it to fork and run in the child, and to disconnect form the
451 terminal. The process id of the child is written to stdout.
454 which will only continue monitoring if a mail address or alert program
455 is found in the config file.
458 .BR -1 ", " --oneshot
459 Check arrays only once. This will generate
461 events and more significantly
465 .B " mdadm --monitor --scan -1"
467 from a cron script will ensure regular notification of any degraded arrays.
473 alert for every array found at startup. This alert gets mailed and
474 passed to the alert program. This can be used for testing that alert
475 message to get through successfully.
482 .I md-device options-and-component-devices...
485 .B mdadm --assemble --scan
486 .I md-devices-and-options...
489 .B mdadm --assemble --scan
493 This usage assembles one or more raid arrays from pre-existing components.
494 For each array, mdadm needs to know the md device, the identity of the
495 array, and a number of component-devices. These can be found in a number of ways.
497 In the first usage example (without the
499 the first device given is the md device.
500 In the second usage example, all devices listed are treated as md
501 devices and assembly is attempted.
502 In the third (where no devices are listed) all md devices that are
503 listed in the configuration file are assembled.
505 If precisely one device is listed, but
511 was given and identify information is extracted from the configuration file.
513 The identity can be given with the
517 option, can be found in the config file, or will be taken from the
518 super block on the first component-device listed on the command line.
520 Devices can be given on the
522 command line or in the config file. Only devices which have an md
523 superblock which contains the right identity will be considered for
526 The config file is only used if explicitly named with
528 or requested with (a possibly implicit)
536 is not given, then the config file will only be used to find the
537 identity of md arrays.
539 Normally the array will be started after it is assembled. However if
541 is not given and insufficient drives were listed to start a complete
542 (non-degraded) array, then the array is not started (to guard against
543 usage errors). To insist that the array be started in this case (as
544 may work for RAID1, 4, 5 or 6), give the
557 .BI --raid-devices= Z
561 This usage is similar to
563 The difference is that it creates a legacy array without a superblock. With
564 these arrays there is no difference between initially creating the array and
565 subsequently assembling the array, except that hopefully there is useful
566 data there in the second case.
568 The level may only be 0, raid0, or linear. All devices must be listed
569 and the array will be started once complete.
580 .BI --raid-devices= Z
584 This usage will initialise a new md array, associate some devices with
585 it, and activate the array.
587 As devices are added, they are checked to see if they contain raid
588 superblocks or filesystems. They are also checked to see if the variance in
589 device size exceeds 1%.
591 If any discrepancy is found, the array will not automatically be run, though
594 can override this caution.
596 To create a "degraded" array in which some devices are missing, simply
597 give the word "\fBmissing\fP"
598 in place of a device name. This will cause
600 to leave the corresponding slot in the array empty.
601 For a RAID4 or RAID5 array at most one slot can be
602 "\fBmissing\fP"; for a RAID6 array at most two slots.
603 For a RAID1 array, only one real device needs to be given. All of the
607 When creating a RAID5 array,
609 will automatically create a degraded array with an extra spare drive.
610 This is because building the spare into a degraded array is in general faster than resyncing
611 the parity on a non-degraded, but not clean, array. This feature can
612 be over-ridden with the
618 '''option is given, it is not necessary to list any component-devices in this command.
619 '''They can be added later, before a
623 '''is given, the apparent size of the smallest drive given is used.
625 The General Management options that are valid with --create are:
628 insist of running the array even if some devices look like they might
633 start the array readonly - not supported yet.
640 .I options... devices...
643 This usage will allow individual devices in an array to be failed,
644 removed or added. It is possible to perform multiple operations with
645 on command. For example:
647 .B " mdadm /dev/md0 -f /dev/hda1 -r /dev/hda1 -a /dev/hda1"
653 and will then remove it from the array and finally add it back
654 in as a spare. However only one md array can be affected by a single
665 MISC mode includes a number if distinct operations that
666 operate on distinct devices. The operations are:
669 The device is examined to see if it is
670 (1) an active md array, or
671 (2) a component of an md array.
672 The information discovered is reported.
676 The device should be an active md device.
678 will display a detailed description of the array.
682 will cause the output to be less detailed and the format to be
683 suitable for inclusion in
684 .BR /etc/mdadm.conf .
687 will normally be 0 unless
689 failed to get useful information about the device(s). However if the
691 option is given, then the exit status will be:
695 The array is functioning normally.
698 The array has at least one failed device.
701 The array has multiple failed devices and hence is unusable (raid4 or
705 There was an error while trying to get information about the device.
710 The device should be a component of an md array.
712 will read the md superblock of the device and display the contents.
717 then multiple devices that are components of the one array
718 are grouped together and reported in a single entry suitable
720 .BR /etc/mdadm.conf .
724 without listing any devices will cause all devices listed in the
725 config file to be examined.
729 The devices should be active md arrays which will be deactivated, as
730 long as they are not currently in use.
734 This will fully activate a partially assembled md array.
738 This will mark an active array as read-only, providing that it is
739 not currently being used.
745 array back to being read/write.
749 For all operations except
752 will cause the operation to be applied to all arrays listed in
757 causes all devices listed in the config file to be examined.
765 .I options... devices...
770 to periodically poll a number of md arrays and to report on any events
773 will never exit once it decides that there are arrays to be checked,
774 so it should normally be run in the background.
776 As well as reporting events,
778 may move a spare drive from one array to another if they are in the
781 and if the destination array has a failed drive but not spares.
783 If any devices are listed on the command line,
785 will only monitor those devices. Otherwise all arrays listed in the
786 configuration file will be monitored. Further, if
788 is given, then any other md devices that appear in
790 will also be monitored.
792 The result of monitoring the arrays is the generation of events.
793 These events are passed to a separate program (if specified) and may
794 be mailed to a given E-mail address.
796 When passing event to program, the program is run once for each event
797 and is given 2 or 3 command-line arguements. The first is the
798 name of the event (see below). The second is the name of the
799 md device which is affected, and the third is the name of a related
800 device if relevant, such as a component device that has failed.
804 is given, then a program or an E-mail address must be specified on the
805 command line or in the config file. If neither are available, then
807 will not monitor anything.
811 will continue monitoring as long as something was found to monitor. If
812 no program or email is given, then each event is reported to
815 The different events are:
820 An md array which previously was configured appears to no longer be
825 An md array started reconstruction.
831 is 20, 40, 60, or 80, this indicates that rebuild has passed that many
832 percentage of the total.
836 An md array that was rebuilding, isn't any more, either because it
837 finished normally or was aborted.
841 An active component device of an array has been marked as faulty.
845 A spare component device which was being rebuilt to replace a faulty
850 A spare component device which was being rebuilt to replace a faulty
851 device as been successfully rebuild and has been made active.
855 A new md array has been detected in the
861 A newly noticed array appears to be degraded. This message is not
864 notices a drive failure which causes degradation, but only when
866 notices that an array is degraded when it first sees the array.
870 A spare drive has been moved from one array in a
872 to another to allow a failed drive to be replaced.
876 An array was found at startup, and the
887 cause Email to be sent. All events cause the program to be run.
888 The program is run with two or three arguments, they being the event
889 name, the array device and possibly a second device.
891 Each event has an associated array device (e.g.
893 and possibly a second device. For
898 the second device is the relevant component device.
901 the second device is the array that the spare was moved from.
905 to move spares from one array to another, the different arrays need to
906 be labelled with the same
908 in the configuration file. The
910 name can be any string. It is only necessary that different spare
911 groups use different names.
915 detects that an array which is in a spare group has fewer active
916 devices than necessary for the complete array, and has no spare
917 devices, it will look for another array in the same spare group that
918 has a full complement of working drive and a spare. It will then
919 attempt to remove the spare from the second drive and add it to the
921 If the removal succeeds but the adding fails, then it is added back to
926 .B " mdadm --query /dev/name-of-device"
928 This will find out if a given device is a raid array, or is part of
929 one, and will provide brief information about the device.
931 .B " mdadm --assemble --scan"
933 This will assemble and start all arrays listed in the standard confile
934 file. This command will typically go in a system startup file.
936 .B " mdadm --stop --scan"
938 This will shut down all array that can be shut down (i.e. are not
939 currently in used). This will typically going in a system shutdown script.
941 .B " mdadm --follow --scan --delay=120"
943 If (and only if) there is an Email address or program given in the
944 standard config file, then
945 monitor the status of all arrays listed in that file by
946 polling them ever 2 minutes.
948 .B " mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[ac]1"
950 Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1.
953 .B " echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > mdadm.conf"
955 .B " mdadm --detail --scan >> mdadm.conf"
957 This will create a prototype config file that describes currently
958 active arrays that are known to be made from partitions of IDE or SCSI drives.
959 This file should be reviewed before being used as it may
960 contain unwanted detail.
962 .B " echo 'DEVICE /dev/hd[a-z] /dev/sd*[a-z]' > mdadm.conf"
964 .B " mdadm --examine --scan --config=mdadm.conf >> mdadm.conf"
966 This will find what arrays could be assembled from existign IDE and
967 SCSI whole drives (not partitions) and store the information is the
968 format of a config file.
969 This file is very likely to contain unwanted detail, particularly
972 entries. It should be reviewed and edited before being used as an
975 .B " mdadm --examine --brief --scan --config=partitions"
977 .B " mdadm -Ebsc partitions"
979 Create a list of devices by reading
980 .BR /proc/partitions ,
981 scan these for RAID superblocks, and printout a brief listing of all
984 .B " mdadm -Ac partitions -m 0 /dev/md0"
986 Scan all partitions and devices listed in
990 out of all such devices with a RAID superblock with a minor number of 0.
992 .B " mdadm --monitor --scan --daemonise > /var/run/mdadm"
994 If config file contains a mail address or alert program, run mdadm in
995 the background in monitor mode monitoring all md devices. Also write
996 pid of mdadm daemon to
999 .B " mdadm --create --help"
1001 Providew help about the Create mode.
1003 .B " mdadm --config --help"
1005 Provide help about the format of the config file.
1009 Provide general help.
1020 lists all active md devices with information about them.
1022 uses this to find arrays when
1024 is given in Misc mode, and to monitor array reconstruction
1030 The config file lists which devices may be scanned to see if
1031 they contain MD super block, and gives identifying information
1032 (e.g. UUID) about known MD arrays. See
1039 was previously known as
1043 For information on the various levels of
1047 .UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
1048 http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
1051 for new releases of the RAID driver check out:
1054 .UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
1055 ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
1060 .UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
1061 http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/