]> git.ipfire.org Git - thirdparty/mdadm.git/blob - mdadm.8
Release 1.8.1 after some man page updates and other fixes.
[thirdparty/mdadm.git] / mdadm.8
1 .\" -*- nroff -*-
2 .TH MDADM 8 "" v1.11.1
3 .SH NAME
4 mdadm \- manage MD devices
5 .I aka
6 Linux Software Raid.
7
8 .SH SYNOPSIS
9
10 .BI mdadm " [mode] <raiddevice> [options] <component-devices>"
11
12 .SH DESCRIPTION
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
18 device failure.
19
20 Linux Software RAID devices are implemented through the md (Multiple
21 Devices) device driver.
22
23 Currently, Linux supports
24 .B LINEAR
25 md devices,
26 .B RAID0
27 (striping),
28 .B RAID1
29 (mirroring),
30 .BR RAID4 ,
31 .BR RAID5 ,
32 .BR RAID6 ,
33 .BR MULTIPATH ,
34 and
35 .BR FAULTY .
36
37 .B MULTIPATH is not a Software RAID mechanism, but does involve
38 multiple devices. For
39 .B MULTIPATH
40 each device is a path to one common physical storage device.
41
42 .B FAULTY is also no true RAID, and it only involves one device. It
43 provides a layer over a true device that can be used to inject faults.
44
45 .B mdadm
46 is a program that can be used to create, manage, and monitor
47 MD devices. As
48 such it provides a similar set of functionality to the
49 .B raidtools
50 packages.
51 The key differences between
52 .B mdadm
53 and
54 .B raidtools
55 are:
56 .IP \(bu 4
57 .B mdadm
58 is a single program and not a collection of programs.
59 .IP \(bu 4
60 .B mdadm
61 can perform (almost) all of its functions without having a
62 configuration file and does not use one by default. Also
63 .B mdadm
64 helps with management of the configuration
65 file.
66 .IP \(bu 4
67 .B mdadm
68 can provide information about your arrays (through Query, Detail, and Examine)
69 that
70 .B raidtools
71 cannot.
72 .P
73 .I mdadm
74 does not use
75 .IR /etc/raidtab ,
76 the
77 .B raidtools
78 configuration file, at all. It has a different configuration file
79 with a different format and an different purpose.
80
81 .SH MODES
82 mdadm has 7 major modes of operation:
83 .TP
84 .B Assemble
85 Assemble the parts of a previously created
86 array into an active array. Components can be explicitly given
87 or can be searched for.
88 .B mdadm
89 checks that the components
90 do form a bona fide array, and can, on request, fiddle superblock
91 information so as to assemble a faulty array.
92
93 .TP
94 .B Build
95 Build an array without per-device superblocks.
96
97 .TP
98 .B Create
99 Create a new array with per-device superblocks.
100 '''It can progress
101 '''in several step create-add-add-run or it can all happen with one command.
102
103 .TP
104 .B Manage
105 This is for doing things to specific components of an array such as
106 adding new spares and removing faulty devices.
107
108 .TP
109 .B Misc
110 This mode allows operations on independent devices such as examine MD
111 superblocks, erasing old superblocks and stopping active arrays.
112
113 .TP
114 .B "Follow or Monitor"
115 Monitor one or more md devices and act on any state changes. This is
116 only meaningful for raid1, 4, 5, 6 or multipath arrays as
117 only these have interesting state. raid0 or linear never have
118 missing, spare, or failed drives, so there is nothing to monitor.
119
120 .TP
121 .B "Grow"
122 Grow (or shrink) an array, or otherwise reshape it in some way.
123 Currently supported growth options including changing the active size
124 of componenet devices in RAID level 1/4/5/6 and changing the number of
125 active devices in RAID1.
126
127 .SH OPTIONS
128
129 Available options are:
130
131 .TP
132 .BR -A ", " --assemble
133 Assemble a pre-existing array.
134
135 .TP
136 .BR -B ", " --build
137 Build a legacy array without superblocks.
138
139 .TP
140 .BR -C ", " --create
141 Create a new array.
142
143 .TP
144 .BR -Q ", " --query
145 Examine a device to see
146 (1) if it is an md device and (2) if it is a component of an md
147 array.
148 Information about what is discovered is presented.
149
150 .TP
151 .BR -D ", " --detail
152 Print detail of one or more md devices.
153
154 .TP
155 .BR -E ", " --examine
156 Print content of md superblock on device(s).
157
158 .TP
159 .BR -F ", " --follow ", " --monitor
160 Select
161 .B Monitor
162 mode.
163
164 .TP
165 .BR -G ", " --grow
166 Change the size or shape of an active array.
167
168 .TP
169 .BR -h ", " --help
170 Display help message or, after above option, mode specific help
171 message.
172
173 .TP
174 .B --help-options
175 Display more detailed help about command line parsing and some commonly
176 used options.
177
178 .TP
179 .BR -V ", " --version
180 Print version information for mdadm.
181
182 .TP
183 .BR -v ", " --verbose
184 Be more verbose about what is happening.
185
186 .TP
187 .BR -b ", " --brief
188 Be less verbose. This is used with
189 .B --detail
190 and
191 .BR --examine .
192
193 .TP
194 .BR -f ", " --force
195 Be more forceful about certain operations. See the various modes of
196 the exact meaning of this option in different contexts.
197
198 .TP
199 .BR -c ", " --config=
200 Specify the config file. Default is
201 .BR /etc/mdadm.conf .
202 If the config file given is
203 .B partitions
204 then nothing will be read, but
205 .I mdadm
206 will act as though the config file contained exactly
207 .B "DEVICE partitions"
208 and will read
209 .B /proc/partitions
210 to find a list of devices to scan.
211 If the word
212 .B none
213 is given for the config file, then
214 .I mdadm
215 will act as though the config file were empty.
216
217 .TP
218 .BR -s ", " --scan
219 scan config file or
220 .B /proc/mdstat
221 for missing information.
222 In general, this option gives
223 .B mdadm
224 permission to get any missing information, like component devices,
225 array devices, array identities, and alert destination from the
226 configuration file:
227 .BR /etc/mdadm.conf .
228 One exception is MISC mode when using
229 .B --detail
230 or
231 .B --stop
232 in which case
233 .B --scan
234 says to get a list of array devices from
235 .BR /proc/mdstat .
236
237 .TP
238 .B -e ", " --metadata=
239 Declare the style of superblock (raid metadata) to be used. The
240 default is 0.90 for --create, and to guess for other operations.
241
242 Options are:
243 .RS
244 .IP "0, 0.90, default"
245 Use the original 0.90 format superblock. This format limits arrays to
246 28 componenet devices and limits component devices of levels 1 and
247 greater to 2 terabytes.
248 .IP "1, 1.0, 1.1, 1.2"
249 Use the new version-1 format superblock. This has few restrictions.
250 The different subversion store the superblock at different locations
251 on the device, either at the end (for 1.0), at the start (for 1.1) or
252 4K from the start (for 1.2).
253 .RE
254
255 .SH For create or build:
256
257 .TP
258 .BR -c ", " --chunk=
259 Specify chunk size of kibibytes. The default is 64.
260
261 .TP
262 .BR --rounding=
263 Specify rounding factor for linear array (==chunk size)
264
265 .TP
266 .BR -l ", " --level=
267 Set raid level. When used with
268 .IR --create ,
269 options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4,
270 raid5, 5, raid6, 6, multipath, mp, fautly. Obviously some of these are synonymous.
271
272 When used with
273 .IR --build ,
274 only linear, raid0, 0, stripe are valid.
275
276 .TP
277 .BR -p ", " --parity=
278 Set raid5 parity algorithm. Options are:
279 left-asymmetric,
280 left-symmetric,
281 right-asymmetric,
282 right-symmetric,
283 la, ra, ls, rs. The default is left-symmetric.
284
285 This option is also used to set the failure mode for
286 .IR faulty .
287 The options are:
288 write-transient,
289 wt,
290 read-transient,
291 rt,
292 write-presistent,
293 wp,
294 read-persistent,
295 rp,
296 write-all,
297 read-fixable,
298 rf,
299 clear,
300 flush,
301 none.
302
303 Each mode can be followed by a number which is used as a period
304 between fault generation. Without a number, the fault is generated
305 once on the first relevant request. With a number, the fault will be
306 generated after that many request, and will continue to be generated
307 every time the period elapses.
308
309 Multiple failure modes can be current simultaneously by using the
310 "--grow" option to set subsequent failure modes.
311
312 "clear" or "none" will remove any pending or periodic failure modes,
313 and "flush" will clear any persistant faults.
314
315 To set the parity with "--grow", the level of the array ("faulty")
316 must be specified before the fault mode is specified.
317
318 .TP
319 .BR --layout=
320 same as --parity
321
322 .TP
323 .BR -n ", " --raid-devices=
324 Specify the number of active devices in the array. This, plus the
325 number of spare devices (see below) must equal the number of
326 .I component-devices
327 (including "\fBmissing\fP" devices)
328 that are listed on the command line for
329 .BR --create .
330 Setting a value of 1 is probably
331 a mistake and so requires that
332 .B --force
333 be specified first. A value of 1 will then be allowed for linear,
334 multipath, raid0 and raid1. It is never allowed for raid4 or raid5.
335 .br
336 This number can only be changed using
337 .B --grow
338 for RAID1 arrays, and only on kernels which provide necessary support.
339
340 .TP
341 .BR -x ", " --spare-devices=
342 Specify the number of spare (eXtra) devices in the initial array.
343 Spares can also be added
344 and removed later. The number of component devices listed
345 on the command line must equal the number of raid devices plus the
346 number of spare devices.
347
348
349 .TP
350 .BR -z ", " --size=
351 Amount (in Kibibytes) of space to use from each drive in RAID1/4/5/6.
352 This must be a multiple of the chunk size, and must leave about 128Kb
353 of space at the end of the drive for the RAID superblock.
354 If this is not specified
355 (as it normally is not) the smallest drive (or partition) sets the
356 size, though if there is a variance among the drives of greater than 1%, a warning is
357 issued.
358
359 This value can be set with
360 .B --grow
361 for RAID level 1/4/5/6. If the array was created with a size smaller
362 than the currently active drives, the extra space can be accessed
363 using
364 .BR --grow .
365
366 .TP
367 .BR --assume-clean
368 Tell
369 .I mdadm
370 that the array pre-existed and is known to be clean. This is only
371 really useful for Building RAID1 array. Only use this if you really
372 know what you are doing. This is currently only supported for --build.
373
374 .TP
375 .BR -R ", " --run
376 Insist that
377 .I mdadm
378 run the array, even if some of the components
379 appear to be active in another array or filesystem. Normally
380 .I mdadm
381 will ask for confirmation before including such components in an
382 array. This option causes that question to be suppressed.
383
384 .TP
385 .BR -f ", " --force
386 Insist that
387 .I mdadm
388 accept the geometry and layout specified without question. Normally
389 .I mdadm
390 will not allow creation of an array with only one device, and will try
391 to create a raid5 array with one missing drive (as this makes the
392 initial resync work faster). With
393 .BR --force ,
394 .I mdadm
395 will not try to be so clever.
396
397 .TP
398 .BR -a ", " "--auto{=no,yes,md,mdp,part,p}{NN}"
399 Instruct mdadm to create the device file if needed, possibly allocating
400 an unused minor number. "md" causes a non-partitionable array
401 to be used. "mdp", "part" or "p" causes a partitionable array (2.6 and
402 later) to be used. "yes" requires the named md device to have a
403 'standard' format, and the type and minor number will be determined
404 from this. See DEVICE NAMES below.
405
406 The argumentment can also come immediately after
407 "-a". e.g. "-ap".
408
409 For partitionable arrays,
410 .I mdadm
411 will create the device file for the whole array and for the first 4
412 partitions. A different number of partitions can be specified at the
413 end of this option (e.g.
414 .BR --auto=p7 ).
415 If the device name ends with a digit, the partition names add a'p',
416 and a number, e.g. "/dev/home1p3". If there is no
417 trailing digit, then the partition names just have a number added,
418 e.g. "/dev/scratch3".
419
420 If the md device name is in a 'standard' format as described in DEVICE
421 NAMES, then it will be created, if necessary, with the appropriate
422 number based on that name. If the device name is not in one of these
423 formats, then a unused minor number will be allocted. The minor
424 number will be considered unused if there is no active array for that
425 number, and there is no entry in /dev for that number and with a
426 non-standard name.
427
428 .SH For assemble:
429
430 .TP
431 .BR -u ", " --uuid=
432 uuid of array to assemble. Devices which don't have this uuid are
433 excluded
434
435 .TP
436 .BR -m ", " --super-minor=
437 Minor number of device that array was created for. Devices which
438 don't have this minor number are excluded. If you create an array as
439 /dev/md1, then all superblocks will contain the minor number 1, even if
440 the array is later assembled as /dev/md2.
441
442 Giving the literal word "dev" for
443 .B --super-minor
444 will cause
445 .I mdadm
446 to use the minor number of the md device that is being assembled.
447 e.g. when assembling
448 .BR /dev/md0 ,
449 .M --super-minor=dev
450 will look for super blocks with a minor number of 0.
451
452 .TP
453 .BR -f ", " --force
454 Assemble the array even if some superblocks appear out-of-date
455
456 .TP
457 .BR -R ", " --run
458 Attempt to start the array even if fewer drives were given than are
459 needed for a full array. Normally if not all drives are found and
460 .B --scan
461 is not used, then the array will be assembled but not started.
462 With
463 .B --run
464 an attempt will be made to start it anyway.
465
466 .TP
467 .BR -a ", " "--auto{=no,yes,md,mdp,part}"
468 See this option under Create and Build options.
469
470 .TP
471 .BR -U ", " --update=
472 Update the superblock on each device while assembling the array. The
473 argument given to this flag can be one of
474 .BR sparc2.2 ,
475 .BR summaries ,
476 .BR resync ,
477 or
478 .BR super-minor .
479
480 The
481 .B sparc2.2
482 option will adjust the superblock of an array what was created on a Sparc
483 machine running a patched 2.2 Linux kernel. This kernel got the
484 alignment of part of the superblock wrong. You can use the
485 .B "--examine --sparc2.2"
486 option to
487 .I mdadm
488 to see what effect this would have.
489
490 The
491 .B super-minor
492 option will update the
493 .B "prefered minor"
494 field on each superblock to match the minor number of the array being
495 assembled. This is not needed on 2.6 and later kernels as they make
496 this adjustment automatically.
497
498 The
499 .B resync
500 option will cause the array to be marked
501 .I dirty
502 meaning that any redundancy in the array (e.g. parity for raid5,
503 copies for raid1) may be incorrect. This will cause the raid system
504 to perform a "resync" pass to make sure that all redundant information
505 is correct.
506
507 The
508 .B summaries
509 option will correct the summaries in the superblock. That is the
510 counts of total, working, active, failed, and spare devices.
511
512 .SH For Manage mode:
513
514 .TP
515 .BR -a ", " --add
516 '''add, or
517 hotadd listed devices.
518
519 .TP
520 .BR -r ", " --remove
521 remove listed devices. They must not be active. i.e. they should
522 be failed or spare devices.
523
524 .TP
525 .BR -f ", " --fail
526 mark listed devices as faulty.
527
528 .TP
529 .BR --set-faulty
530 same as --fail.
531
532 .SH For Examine mode:
533
534 .TP
535 .B --sparc2.2
536 In an array was created on a 2.2 Linux kernel patched with RAID
537 support, the superblock will have been created incorrectly, or at
538 least incompatibly with 2.4 and later kernels. Using the
539 .B --sparc2.2
540 flag with
541 .B --examine
542 will fix the superblock before displaying it. If this appears to do
543 the right thing, then the array can be successfully assembled using
544 .BR "--assemble --update=sparc2.2" .
545
546 .SH For Misc mode:
547
548 .TP
549 .BR -R ", " --run
550 start a partially built array.
551
552 .TP
553 .BR -S ", " --stop
554 deactivate array, releasing all resources.
555
556 .TP
557 .BR -o ", " --readonly
558 mark array as readonly.
559
560 .TP
561 .BR -w ", " --readwrite
562 mark array as readwrite.
563
564 .TP
565 .B --zero-superblock
566 If the device contains a valid md superblock, the block is
567 over-written with zeros. With
568 --force
569 the block where the superblock would be is over-written even if it
570 doesn't appear to be valid.
571
572 .TP
573 .BR -t ", " --test
574 When used with
575 .BR --detail ,
576 the exit status of
577 .I mdadm
578 is set to reflect the status of the device.
579
580 .SH For Monitor mode:
581 .TP
582 .BR -m ", " --mail
583 Give a mail address to send alerts to.
584
585 .TP
586 .BR -p ", " --program ", " --alert
587 Give a program to be run whenever an event is detected.
588
589 .TP
590 .BR -d ", " --delay
591 Give a delay in seconds.
592 .B mdadm
593 polls the md arrays and then waits this many seconds before polling
594 again. The default is 60 seconds.
595
596 .TP
597 .BR -f ", " --daemonise
598 Tell
599 .B mdadm
600 to run as a background daemon if it decides to monitor anything. This
601 causes it to fork and run in the child, and to disconnect form the
602 terminal. The process id of the child is written to stdout.
603 This is useful with
604 .B --scan
605 which will only continue monitoring if a mail address or alert program
606 is found in the config file.
607
608 .TP
609 .BR -i ", " --pid-file
610 When
611 .B mdadm
612 is running in daemon mode, write the pid of the daemon process to
613 the specified file, instead of printing it on standard output.
614
615 .TP
616 .BR -1 ", " --oneshot
617 Check arrays only once. This will generate
618 .B NewArray
619 events and more significantly
620 .B DegradedArray
621 events. Running
622 .in +5
623 .B " mdadm --monitor --scan -1"
624 .in -5
625 from a cron script will ensure regular notification of any degraded arrays.
626
627 .TP
628 .BR -t ", " --test
629 Generate a
630 .B TestMessage
631 alert for every array found at startup. This alert gets mailed and
632 passed to the alert program. This can be used for testing that alert
633 message to get through successfully.
634
635 .SH ASSEMBLE MODE
636
637 .HP 12
638 Usage:
639 .B mdadm --assemble
640 .I md-device options-and-component-devices...
641 .HP 12
642 Usage:
643 .B mdadm --assemble --scan
644 .I md-devices-and-options...
645 .HP 12
646 Usage:
647 .B mdadm --assemble --scan
648 .I options...
649
650 .PP
651 This usage assembles one or more raid arrays from pre-existing components.
652 For each array, mdadm needs to know the md device, the identity of the
653 array, and a number of component-devices. These can be found in a number of ways.
654
655 In the first usage example (without the
656 .BR --scan )
657 the first device given is the md device.
658 In the second usage example, all devices listed are treated as md
659 devices and assembly is attempted.
660 In the third (where no devices are listed) all md devices that are
661 listed in the configuration file are assembled.
662
663 If precisely one device is listed, but
664 .B --scan
665 is not given, then
666 .I mdadm
667 acts as though
668 .B --scan
669 was given and identify information is extracted from the configuration file.
670
671 The identity can be given with the
672 .B --uuid
673 option, with the
674 .B --super-minor
675 option, can be found in the config file, or will be taken from the
676 super block on the first component-device listed on the command line.
677
678 Devices can be given on the
679 .B --assemble
680 command line or in the config file. Only devices which have an md
681 superblock which contains the right identity will be considered for
682 any array.
683
684 The config file is only used if explicitly named with
685 .B --config
686 or requested with (a possibly implicit)
687 .B --scan.
688 In the later case,
689 .B /etc/mdadm.conf
690 is used.
691
692 If
693 .B --scan
694 is not given, then the config file will only be used to find the
695 identity of md arrays.
696
697 Normally the array will be started after it is assembled. However if
698 .B --scan
699 is not given and insufficient drives were listed to start a complete
700 (non-degraded) array, then the array is not started (to guard against
701 usage errors). To insist that the array be started in this case (as
702 may work for RAID1, 4, 5 or 6), give the
703 .B --run
704 flag.
705
706 If an
707 .B auto
708 option is given, either on the command line (--auto) or in the
709 configuration file (e.g. auto=part), then
710 .I mdadm
711 will create the md device if necessary or will re-create it if it
712 doesn't look usable as it is.
713
714 This can be useful for handling partitioned devices (which don't have
715 a stable device number - it can change after a reboot) and when using
716 "udev" to manage your
717 .B /dev
718 tree (udev cannot handle md devices because of the unusual device
719 initialisation conventions).
720
721 If the option to "auto" is "mdp" or "part" or (on the command line
722 only) "p", then mdadm will create a partitionable array, using the
723 first free one that is not inuse, and does not already have an entry
724 in /dev (apart from numeric /dev/md* entries).
725
726 If the option to "auto" is "yes" or "md" or (on the command line)
727 nothing, then mdadm will create a traditional, non-partitionable md
728 array.
729
730 It is expected that the "auto" functionality will be used to create
731 device entries with meaningful names such as "/dev/md/home" or
732 "/dev/md/root", rather than names based on the numerical array number.
733
734 When using this option to create a partitionable array, the device
735 files for the first 4 partitions are also created. If a different
736 number is required it can be simply appended to the auto option.
737 e.g. "auto=part8". Partition names are created by appending a digit
738 string to the device name, with an intervening "_p" if the device name
739 ends with a digit.
740
741 The
742 .B --auto
743 option is also available in Build and Create modes. As those modes do
744 not use a config file, the "auto=" config option does not apply to
745 these modes.
746
747 .SH BUILD MODE
748
749 .HP 12
750 Usage:
751 .B mdadm --build
752 .I device
753 .BI --chunk= X
754 .BI --level= Y
755 .BI --raid-devices= Z
756 .I devices
757
758 .PP
759 This usage is similar to
760 .BR --create .
761 The difference is that it creates a legacy array without a superblock. With
762 these arrays there is no difference between initially creating the array and
763 subsequently assembling the array, except that hopefully there is useful
764 data there in the second case.
765
766 The level may only be 0, raid0, or linear. All devices must be listed
767 and the array will be started once complete.
768
769 .SH CREATE MODE
770
771 .HP 12
772 Usage:
773 .B mdadm --create
774 .I device
775 .BI --chunk= X
776 .BI --level= Y
777 .br
778 .BI --raid-devices= Z
779 .I devices
780
781 .PP
782 This usage will initialise a new md array, associate some devices with
783 it, and activate the array.
784
785 This the
786 .B --auto
787 option is given (as described in more detail in the section on
788 Assemble mode), then the md device will be created with a suitable
789 device number if necessary.
790
791 As devices are added, they are checked to see if they contain raid
792 superblocks or filesystems. They are also checked to see if the variance in
793 device size exceeds 1%.
794
795 If any discrepancy is found, the array will not automatically be run, though
796 the presence of a
797 .B --run
798 can override this caution.
799
800 To create a "degraded" array in which some devices are missing, simply
801 give the word "\fBmissing\fP"
802 in place of a device name. This will cause
803 .B mdadm
804 to leave the corresponding slot in the array empty.
805 For a RAID4 or RAID5 array at most one slot can be
806 "\fBmissing\fP"; for a RAID6 array at most two slots.
807 For a RAID1 array, only one real device needs to be given. All of the
808 others can be
809 "\fBmissing\fP".
810
811 When creating a RAID5 array,
812 .B mdadm
813 will automatically create a degraded array with an extra spare drive.
814 This is because building the spare into a degraded array is in general faster than resyncing
815 the parity on a non-degraded, but not clean, array. This feature can
816 be over-ridden with the
817 .I --force
818 option.
819
820 '''If the
821 '''.B --size
822 '''option is given, it is not necessary to list any component-devices in this command.
823 '''They can be added later, before a
824 '''.B --run.
825 '''If no
826 '''.B --size
827 '''is given, the apparent size of the smallest drive given is used.
828
829 The General Management options that are valid with --create are:
830 .TP
831 .B --run
832 insist on running the array even if some devices look like they might
833 be in use.
834
835 .TP
836 .B --readonly
837 start the array readonly - not supported yet.
838
839 .SH MANAGE MODE
840 .HP 12
841 Usage:
842 .B mdadm
843 .I device
844 .I options... devices...
845 .PP
846
847 This usage will allow individual devices in an array to be failed,
848 removed or added. It is possible to perform multiple operations with
849 on command. For example:
850 .br
851 .B " mdadm /dev/md0 -f /dev/hda1 -r /dev/hda1 -a /dev/hda1"
852 .br
853 will firstly mark
854 .B /dev/hda1
855 as faulty in
856 .B /dev/md0
857 and will then remove it from the array and finally add it back
858 in as a spare. However only one md array can be affected by a single
859 command.
860
861 .SH MISC MODE
862 .HP 12
863 Usage:
864 .B mdadm
865 .I options ...
866 .I devices ...
867 .PP
868
869 MISC mode includes a number of distinct operations that
870 operate on distinct devices. The operations are:
871 .TP
872 --query
873 The device is examined to see if it is
874 (1) an active md array, or
875 (2) a component of an md array.
876 The information discovered is reported.
877
878 .TP
879 --detail
880 The device should be an active md device.
881 .B mdadm
882 will display a detailed description of the array.
883 .B --brief
884 or
885 .B --scan
886 will cause the output to be less detailed and the format to be
887 suitable for inclusion in
888 .BR /etc/mdadm.conf .
889 The exit status of
890 .I mdadm
891 will normally be 0 unless
892 .I mdadm
893 failed to get useful information about the device(s). However if the
894 .B --test
895 option is given, then the exit status will be:
896 .RS
897 .TP
898 0
899 The array is functioning normally.
900 .TP
901 1
902 The array has at least one failed device.
903 .TP
904 2
905 The array has multiple failed devices and hence is unusable (raid4 or
906 raid5).
907 .TP
908 4
909 There was an error while trying to get information about the device.
910 .RE
911
912 .TP
913 --examine
914 The device should be a component of an md array.
915 .B mdadm
916 will read the md superblock of the device and display the contents.
917 If
918 .B --brief
919 is given, or
920 .B --scan
921 then multiple devices that are components of the one array
922 are grouped together and reported in a single entry suitable
923 for inclusion in
924 .BR /etc/mdadm.conf .
925
926 Having
927 .B --scan
928 without listing any devices will cause all devices listed in the
929 config file to be examined.
930
931 .TP
932 --stop
933 The devices should be active md arrays which will be deactivated, as
934 long as they are not currently in use.
935
936 .TP
937 --run
938 This will fully activate a partially assembled md array.
939
940 .TP
941 --readonly
942 This will mark an active array as read-only, providing that it is
943 not currently being used.
944
945 .TP
946 --readwrite
947 This will change a
948 .B readonly
949 array back to being read/write.
950
951 .TP
952 --scan
953 For all operations except
954 .BR --examine ,
955 .B --scan
956 will cause the operation to be applied to all arrays listed in
957 .BR /proc/mdstat .
958 For
959 .BR --examine,
960 .B --scan
961 causes all devices listed in the config file to be examined.
962
963
964 .SH MONITOR MODE
965
966 .HP 12
967 Usage:
968 .B mdadm --monitor
969 .I options... devices...
970
971 .PP
972 This usage causes
973 .B mdadm
974 to periodically poll a number of md arrays and to report on any events
975 noticed.
976 .B mdadm
977 will never exit once it decides that there are arrays to be checked,
978 so it should normally be run in the background.
979
980 As well as reporting events,
981 .B mdadm
982 may move a spare drive from one array to another if they are in the
983 same
984 .B spare-group
985 and if the destination array has a failed drive but not spares.
986
987 If any devices are listed on the command line,
988 .B mdadm
989 will only monitor those devices. Otherwise all arrays listed in the
990 configuration file will be monitored. Further, if
991 .B --scan
992 is given, then any other md devices that appear in
993 .B /proc/mdstat
994 will also be monitored.
995
996 The result of monitoring the arrays is the generation of events.
997 These events are passed to a separate program (if specified) and may
998 be mailed to a given E-mail address.
999
1000 When passing event to program, the program is run once for each event
1001 and is given 2 or 3 command-line arguements. The first is the
1002 name of the event (see below). The second is the name of the
1003 md device which is affected, and the third is the name of a related
1004 device if relevant, such as a component device that has failed.
1005
1006 If
1007 .B --scan
1008 is given, then a program or an E-mail address must be specified on the
1009 command line or in the config file. If neither are available, then
1010 .B mdadm
1011 will not monitor anything.
1012 Without
1013 .B --scan
1014 .B mdadm
1015 will continue monitoring as long as something was found to monitor. If
1016 no program or email is given, then each event is reported to
1017 .BR stdout .
1018
1019 The different events are:
1020
1021 .RS 4
1022 .TP
1023 .B DeviceDisappeared
1024 An md array which previously was configured appears to no longer be
1025 configured.
1026
1027 .TP
1028 .B RebuildStarted
1029 An md array started reconstruction.
1030
1031 .TP
1032 .BI Rebuild NN
1033 Where
1034 .I NN
1035 is 20, 40, 60, or 80, this indicates that rebuild has passed that many
1036 percentage of the total.
1037
1038 .TP
1039 .B RebuildFinished
1040 An md array that was rebuilding, isn't any more, either because it
1041 finished normally or was aborted.
1042
1043 .TP
1044 .B Fail
1045 An active component device of an array has been marked as faulty.
1046
1047 .TP
1048 .B FailSpare
1049 A spare component device which was being rebuilt to replace a faulty
1050 device has failed.
1051
1052 .TP
1053 .B SpareActive
1054 A spare component device which was being rebuilt to replace a faulty
1055 device as been successfully rebuild and has been made active.
1056
1057 .TP
1058 .B NewArray
1059 A new md array has been detected in the
1060 .B /proc/mdstat
1061 file.
1062
1063 .TP
1064 .B DegradedArray
1065 A newly noticed array appears to be degraded. This message is not
1066 generated when
1067 .I mdadm
1068 notices a drive failure which causes degradation, but only when
1069 .I mdadm
1070 notices that an array is degraded when it first sees the array.
1071
1072 .TP
1073 .B MoveSpare
1074 A spare drive has been moved from one array in a
1075 .B spare-group
1076 to another to allow a failed drive to be replaced.
1077
1078 .TP
1079 .B TestMessage
1080 An array was found at startup, and the
1081 .B --test
1082 flag was given.
1083 .RE
1084
1085 Only
1086 .B Fail ,
1087 .B FailSpare ,
1088 .B DegradedArray ,
1089 and
1090 .B TestMessage
1091 cause Email to be sent. All events cause the program to be run.
1092 The program is run with two or three arguments, they being the event
1093 name, the array device and possibly a second device.
1094
1095 Each event has an associated array device (e.g.
1096 .BR /dev/md1 )
1097 and possibly a second device. For
1098 .BR Fail ,
1099 .BR FailSpare ,
1100 and
1101 .B SpareActive
1102 the second device is the relevant component device.
1103 For
1104 .B MoveSpare
1105 the second device is the array that the spare was moved from.
1106
1107 For
1108 .B mdadm
1109 to move spares from one array to another, the different arrays need to
1110 be labelled with the same
1111 .B spare-group
1112 in the configuration file. The
1113 .B spare-group
1114 name can be any string. It is only necessary that different spare
1115 groups use different names.
1116
1117 When
1118 .B mdadm
1119 detects that an array which is in a spare group has fewer active
1120 devices than necessary for the complete array, and has no spare
1121 devices, it will look for another array in the same spare group that
1122 has a full complement of working drive and a spare. It will then
1123 attempt to remove the spare from the second drive and add it to the
1124 first.
1125 If the removal succeeds but the adding fails, then it is added back to
1126 the original array.
1127
1128 .SH GROW MODE
1129 The GROW mode is used for changing the size or shape of an active
1130 array.
1131 For this to work, the kernel must support the necessary change.
1132 Various types of growth may be added during 2.6 development, possibly
1133 including restructuring a raid5 array to have more active devices.
1134
1135 Currently the only support available is to change the "size" attribute
1136 for arrays with redundancy, and the raid-disks attribute of RAID1
1137 arrays.
1138
1139 Normally when an array is build the "size" it taken from the smallest
1140 of the drives. If all the small drives in an arrays are, one at a
1141 time, removed and replaced with larger drives, then you could have an
1142 array of large drives with only a small amount used. In this
1143 situation, changing the "size" with "GROW" mode will allow the extra
1144 space to start being used. If the size is increased in this way, a
1145 "resync" process will start to make sure the new parts of the array
1146 are synchronised.
1147
1148 Note that when an array changes size, any filesystem that may be
1149 stored in the array will not automatically grow to use the space. The
1150 filesystem will need to be explicitly told to use the extra space.
1151
1152 A RAID1 array can work with any number of devices from 1 upwards
1153 (though 1 is not very useful). There may be times which you want to
1154 increase or decrease the number of active devices. Note that this is
1155 different to hot-add or hot-remove which changes the number of
1156 inactive devices.
1157
1158 When reducing the number of devices in a RAID1 array, the slots which
1159 are to be removed from the array must already be vacant. That is, the
1160 devices that which were in those slots must be failed and removed.
1161
1162 When the number of devices is increased, any hot spares that are
1163 present may be activated immediately.
1164
1165 .SH EXAMPLES
1166
1167 .B " mdadm --query /dev/name-of-device"
1168 .br
1169 This will find out if a given device is a raid array, or is part of
1170 one, and will provide brief information about the device.
1171
1172 .B " mdadm --assemble --scan"
1173 .br
1174 This will assemble and start all arrays listed in the standard confile
1175 file. This command will typically go in a system startup file.
1176
1177 .B " mdadm --stop --scan"
1178 .br
1179 This will shut down all array that can be shut down (i.e. are not
1180 currently in use). This will typically go in a system shutdown script.
1181
1182 .B " mdadm --follow --scan --delay=120"
1183 .br
1184 If (and only if) there is an Email address or program given in the
1185 standard config file, then
1186 monitor the status of all arrays listed in that file by
1187 polling them ever 2 minutes.
1188
1189 .B " mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[ac]1"
1190 .br
1191 Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1.
1192
1193 .br
1194 .B " echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > mdadm.conf"
1195 .br
1196 .B " mdadm --detail --scan >> mdadm.conf"
1197 .br
1198 This will create a prototype config file that describes currently
1199 active arrays that are known to be made from partitions of IDE or SCSI drives.
1200 This file should be reviewed before being used as it may
1201 contain unwanted detail.
1202
1203 .B " echo 'DEVICE /dev/hd[a-z] /dev/sd*[a-z]' > mdadm.conf"
1204 .br
1205 .B " mdadm --examine --scan --config=mdadm.conf >> mdadm.conf"
1206 .ber
1207 This will find what arrays could be assembled from existign IDE and
1208 SCSI whole drives (not partitions) and store the information is the
1209 format of a config file.
1210 This file is very likely to contain unwanted detail, particularly
1211 the
1212 .B devices=
1213 entries. It should be reviewed and edited before being used as an
1214 actual config file.
1215
1216 .B " mdadm --examine --brief --scan --config=partitions"
1217 .br
1218 .B " mdadm -Ebsc partitions"
1219 .br
1220 Create a list of devices by reading
1221 .BR /proc/partitions ,
1222 scan these for RAID superblocks, and printout a brief listing of all
1223 that was found.
1224
1225 .B " mdadm -Ac partitions -m 0 /dev/md0"
1226 .br
1227 Scan all partitions and devices listed in
1228 .BR /proc/partitions
1229 and assemble
1230 .B /dev/md0
1231 out of all such devices with a RAID superblock with a minor number of 0.
1232
1233 .B " mdadm --monitor --scan --daemonise > /var/run/mdadm"
1234 .br
1235 If config file contains a mail address or alert program, run mdadm in
1236 the background in monitor mode monitoring all md devices. Also write
1237 pid of mdadm daemon to
1238 .BR /var/run/mdadm .
1239
1240 .B " mdadm --create --help"
1241 .br
1242 Providew help about the Create mode.
1243
1244 .B " mdadm --config --help"
1245 .br
1246 Provide help about the format of the config file.
1247
1248 .B " mdadm --help"
1249 .br
1250 Provide general help.
1251
1252
1253 .SH FILES
1254
1255 .SS /proc/mdstat
1256
1257 If you're using the
1258 .B /proc
1259 filesystem,
1260 .B /proc/mdstat
1261 lists all active md devices with information about them.
1262 .B mdadm
1263 uses this to find arrays when
1264 .B --scan
1265 is given in Misc mode, and to monitor array reconstruction
1266 on Monitor mode.
1267
1268
1269 .SS /etc/mdadm.conf
1270
1271 The config file lists which devices may be scanned to see if
1272 they contain MD super block, and gives identifying information
1273 (e.g. UUID) about known MD arrays. See
1274 .BR mdadm.conf (5)
1275 for more details.
1276
1277 .SH DEVICE NAMES
1278
1279 While entries in the /dev directory can have any format you like,
1280 .I mdadm
1281 has an understanding of 'standard' formats which it uses to guide its
1282 behaviour when creating device files via the
1283 .I --auto
1284 option.
1285
1286 The standard names for non-partitioned arrays (the only sort of md
1287 array available in 2.4 and earlier) either of
1288 .IP
1289 /dev/mdNN
1290 .br
1291 /dev/md/NN
1292 .PP
1293 where NN is a number.
1294 The standard names for partitionable arrays (as available from 2.6
1295 onwards) is one of
1296 .IP
1297 /dev/md/dNN
1298 .br
1299 /dev/md_dNN
1300 .PP
1301 Partition numbers should be indicated by added "pMM" to these, thus "/dev/md/d1p2".
1302
1303 .SH NOTE
1304 .B mdadm
1305 was previously known as
1306 .BR mdctl .
1307
1308 .SH SEE ALSO
1309 For information on the various levels of
1310 RAID, check out:
1311
1312 .IP
1313 .UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
1314 http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
1315 .UE
1316 .PP
1317 for new releases of the RAID driver check out:
1318
1319 .IP
1320 .UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
1321 ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
1322 .UE
1323 .PP
1324 or
1325 .IP
1326 .UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
1327 http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
1328 .URk
1329 .PP
1330 .BR mdadm.conf (5),
1331 .BR md (4).
1332 .PP
1333 .IR raidtab (5),
1334 .IR raid0run (8),
1335 .IR raidstop (8),
1336 .IR mkraid (8)