]> git.ipfire.org Git - thirdparty/mdadm.git/blob - mdadm.8
Man page update for containers etc.
[thirdparty/mdadm.git] / mdadm.8
1 .\" -*- nroff -*-
2 .\" Copyright Neil Brown and others.
3 .\" This program is free software; you can redistribute it and/or modify
4 .\" it under the terms of the GNU General Public License as published by
5 .\" the Free Software Foundation; either version 2 of the License, or
6 .\" (at your option) any later version.
7 .\" See file COPYING in distribution for details.
8 .TH MDADM 8 "" v3.0-devel1
9 .SH NAME
10 mdadm \- manage MD devices
11 .I aka
12 Linux Software RAID
13
14 .SH SYNOPSIS
15
16 .BI mdadm " [mode] <raiddevice> [options] <component-devices>"
17
18 .SH DESCRIPTION
19 RAID devices are virtual devices created from two or more
20 real block devices. This allows multiple devices (typically disk
21 drives or partitions thereof) to be combined into a single device to
22 hold (for example) a single filesystem.
23 Some RAID levels include redundancy and so can survive some degree of
24 device failure.
25
26 Linux Software RAID devices are implemented through the md (Multiple
27 Devices) device driver.
28
29 Currently, Linux supports
30 .B LINEAR
31 md devices,
32 .B RAID0
33 (striping),
34 .B RAID1
35 (mirroring),
36 .BR RAID4 ,
37 .BR RAID5 ,
38 .BR RAID6 ,
39 .BR RAID10 ,
40 .BR MULTIPATH ,
41 .BR FAULTY ,
42 and
43 .BR CONTAINER .
44
45 .B MULTIPATH
46 is not a Software RAID mechanism, but does involve
47 multiple devices:
48 each device is a path to one common physical storage device.
49
50 .B FAULTY
51 is also not true RAID, and it only involves one device. It
52 provides a layer over a true device that can be used to inject faults.
53
54 B CONTAINER
55 is different again. A CONTAINER is a collection of devices that are
56 managed as a set. This is similar to the set of devices connected to
57 a hardware RAID controller. The set of devices may contain a number
58 of different RAID arrays each utilising some (or all) blocks from a
59 number of the devices in the set. For example, two devices in a 5-device set
60 might form a RAID1 used the whole devices. The remaining three might
61 have a RAID5 over the first half of each device, and a RAID0 over the
62 second half.
63
64 With a CONTAINER, there is one set of metadata the describes
65
66
67 .\".I mdadm
68 .\"is a program that can be used to create, manage, and monitor
69 .\"MD devices. As
70 .\"such it provides a similar set of functionality to the
71 .\".B raidtools
72 .\"packages.
73 .\"The key differences between
74 .\".I mdadm
75 .\"and
76 .\".B raidtools
77 .\"are:
78 .\".IP \(bu 4
79 .\".I mdadm
80 .\"is a single program and not a collection of programs.
81 .\".IP \(bu 4
82 .\".I mdadm
83 .\"can perform (almost) all of its functions without having a
84 .\"configuration file and does not use one by default. Also
85 .\".I mdadm
86 .\"helps with management of the configuration
87 .\"file.
88 .\".IP \(bu 4
89 .\".I mdadm
90 .\"can provide information about your arrays (through Query, Detail, and Examine)
91 .\"that
92 .\".B raidtools
93 .\"cannot.
94 .\".P
95 .\".I mdadm
96 .\"does not use
97 .\".IR /etc/raidtab ,
98 .\"the
99 .\".B raidtools
100 .\"configuration file, at all. It has a different configuration file
101 .\"with a different format and a different purpose.
102
103 .SH MODES
104 mdadm has several major modes of operation:
105 .TP
106 .B Assemble
107 Assemble the components of a previously created
108 array into an active array. Components can be explicitly given
109 or can be searched for.
110 .I mdadm
111 checks that the components
112 do form a bona fide array, and can, on request, fiddle superblock
113 information so as to assemble a faulty array.
114
115 .TP
116 .B Build
117 Build an array that doesn't have per-device superblocks. For these
118 sorts of arrays,
119 .I mdadm
120 cannot differentiate between initial creation and subsequent assembly
121 of an array. It also cannot perform any checks that appropriate
122 components have been requested. Because of this, the
123 .B Build
124 mode should only be used together with a complete understanding of
125 what you are doing.
126
127 .TP
128 .B Create
129 Create a new array with per-device superblocks.
130 .\"It can progress
131 .\"in several step create-add-add-run or it can all happen with one command.
132
133 .TP
134 .B "Follow or Monitor"
135 Monitor one or more md devices and act on any state changes. This is
136 only meaningful for raid1, 4, 5, 6, 10 or multipath arrays, as
137 only these have interesting state. raid0 or linear never have
138 missing, spare, or failed drives, so there is nothing to monitor.
139
140 .TP
141 .B "Grow"
142 Grow (or shrink) an array, or otherwise reshape it in some way.
143 Currently supported growth options including changing the active size
144 of component devices and changing the number of active devices in RAID
145 levels 1/4/5/6, as well as adding or removing a write-intent bitmap.
146
147 .TP
148 .B "Incremental Assembly"
149 Add a single device to an appropriate array. If the addition of the
150 device makes the array runnable, the array will be started.
151 This provides a convenient interface to a
152 .I hot-plug
153 system. As each device is detected,
154 .I mdadm
155 has a chance to include it in some array as appropriate.
156
157 .TP
158 .B Manage
159 This is for doing things to specific components of an array such as
160 adding new spares and removing faulty devices.
161
162 .TP
163 .B Misc
164 This is an 'everything else' mode that supports operations on active
165 arrays, operations on component devices such as erasing old superblocks, and
166 information gathering operations.
167 .\"This mode allows operations on independent devices such as examine MD
168 .\"superblocks, erasing old superblocks and stopping active arrays.
169
170 .TP
171 .B Auto-detect
172 This mode does not act on a specific device or array, but rather it
173 requests the Linux Kernel to activate any auto-detected arrays.
174 .SH OPTIONS
175
176 .SH Options for selecting a mode are:
177
178 .TP
179 .BR \-A ", " \-\-assemble
180 Assemble a pre-existing array.
181
182 .TP
183 .BR \-B ", " \-\-build
184 Build a legacy array without superblocks.
185
186 .TP
187 .BR \-C ", " \-\-create
188 Create a new array.
189
190 .TP
191 .BR \-F ", " \-\-follow ", " \-\-monitor
192 Select
193 .B Monitor
194 mode.
195
196 .TP
197 .BR \-G ", " \-\-grow
198 Change the size or shape of an active array.
199
200 .TP
201 .BR \-I ", " \-\-incremental
202 Add a single device into an appropriate array, and possibly start the array.
203
204 .TP
205 .B \-\-auto-detect
206 Request that the kernel starts any auto-detected arrays. This can only
207 work if
208 .I md
209 is compiled into the kernel \(em not if it is a module.
210 Arrays can be auto-detected by the kernel if all the components are in
211 primary MS-DOS partitions with partition type
212 .BR FD .
213 In-kernel autodetect is not recommended for new installations. Using
214 .I mdadm
215 to detect and assemble arrays \(em possibly in an
216 .I initrd
217 \(em is substantially more flexible and should be preferred.
218
219 .P
220 If a device is given before any options, or if the first option is
221 .BR \-\-add ,
222 .BR \-\-fail ,
223 or
224 .BR \-\-remove ,
225 then the MANAGE mode is assume.
226 Anything other than these will cause the
227 .B Misc
228 mode to be assumed.
229
230 .SH Options that are not mode-specific are:
231
232 .TP
233 .BR \-h ", " \-\-help
234 Display general help message or, after one of the above options, a
235 mode-specific help message.
236
237 .TP
238 .B \-\-help\-options
239 Display more detailed help about command line parsing and some commonly
240 used options.
241
242 .TP
243 .BR \-V ", " \-\-version
244 Print version information for mdadm.
245
246 .TP
247 .BR \-v ", " \-\-verbose
248 Be more verbose about what is happening. This can be used twice to be
249 extra-verbose.
250 The extra verbosity currently only affects
251 .B \-\-detail \-\-scan
252 and
253 .BR "\-\-examine \-\-scan" .
254
255 .TP
256 .BR \-q ", " \-\-quiet
257 Avoid printing purely informative messages. With this,
258 .I mdadm
259 will be silent unless there is something really important to report.
260
261 .TP
262 .BR \-b ", " \-\-brief
263 Be less verbose. This is used with
264 .B \-\-detail
265 and
266 .BR \-\-examine .
267 Using
268 .B \-\-brief
269 with
270 .B \-\-verbose
271 gives an intermediate level of verbosity.
272
273 .TP
274 .BR \-f ", " \-\-force
275 Be more forceful about certain operations. See the various modes for
276 the exact meaning of this option in different contexts.
277
278 .TP
279 .BR \-c ", " \-\-config=
280 Specify the config file. Default is to use
281 .BR /etc/mdadm.conf ,
282 or if that is missing then
283 .BR /etc/mdadm/mdadm.conf .
284 If the config file given is
285 .B "partitions"
286 then nothing will be read, but
287 .I mdadm
288 will act as though the config file contained exactly
289 .B "DEVICE partitions"
290 and will read
291 .B /proc/partitions
292 to find a list of devices to scan.
293 If the word
294 .B "none"
295 is given for the config file, then
296 .I mdadm
297 will act as though the config file were empty.
298
299 .TP
300 .BR \-s ", " \-\-scan
301 Scan config file or
302 .B /proc/mdstat
303 for missing information.
304 In general, this option gives
305 .I mdadm
306 permission to get any missing information (like component devices,
307 array devices, array identities, and alert destination) from the
308 configuration file (see previous option);
309 one exception is MISC mode when using
310 .B \-\-detail
311 or
312 .B \-\-stop,
313 in which case
314 .B \-\-scan
315 says to get a list of array devices from
316 .BR /proc/mdstat .
317
318 .TP
319 .B \-e ", " \-\-metadata=
320 Declare the style of superblock (raid metadata) to be used. The
321 default is 0.90 for
322 .BR \-\-create ,
323 and to guess for other operations.
324 The default can be overridden by setting the
325 .B metadata
326 value for the
327 .B CREATE
328 keyword in
329 .BR mdadm.conf .
330
331 Options are:
332 .RS
333 .IP "0, 0.90, default"
334 Use the original 0.90 format superblock. This format limits arrays to
335 28 component devices and limits component devices of levels 1 and
336 greater to 2 terabytes.
337 .IP "1, 1.0, 1.1, 1.2"
338 Use the new version-1 format superblock. This has few restrictions.
339 The different sub-versions store the superblock at different locations
340 on the device, either at the end (for 1.0), at the start (for 1.1) or
341 4K from the start (for 1.2).
342 .RE
343
344 .TP
345 .B \-\-homehost=
346 This will override any
347 .B HOMEHOST
348 setting in the config file and provides the identity of the host which
349 should be considered the home for any arrays.
350
351 When creating an array, the
352 .B homehost
353 will be recorded in the superblock. For version-1 superblocks, it will
354 be prefixed to the array name. For version-0.90 superblocks, part of
355 the SHA1 hash of the hostname will be stored in the later half of the
356 UUID.
357
358 When reporting information about an array, any array which is tagged
359 for the given homehost will be reported as such.
360
361 When using Auto-Assemble, only arrays tagged for the given homehost
362 will be assembled.
363
364 .SH For create, build, or grow:
365
366 .TP
367 .BR \-n ", " \-\-raid\-devices=
368 Specify the number of active devices in the array. This, plus the
369 number of spare devices (see below) must equal the number of
370 .I component-devices
371 (including "\fBmissing\fP" devices)
372 that are listed on the command line for
373 .BR \-\-create .
374 Setting a value of 1 is probably
375 a mistake and so requires that
376 .B \-\-force
377 be specified first. A value of 1 will then be allowed for linear,
378 multipath, raid0 and raid1. It is never allowed for raid4 or raid5.
379 .br
380 This number can only be changed using
381 .B \-\-grow
382 for RAID1, RAID5 and RAID6 arrays, and only on kernels which provide
383 necessary support.
384
385 .TP
386 .BR \-x ", " \-\-spare\-devices=
387 Specify the number of spare (eXtra) devices in the initial array.
388 Spares can also be added
389 and removed later. The number of component devices listed
390 on the command line must equal the number of raid devices plus the
391 number of spare devices.
392
393
394 .TP
395 .BR \-z ", " \-\-size=
396 Amount (in Kibibytes) of space to use from each drive in RAID level 1/4/5/6.
397 This must be a multiple of the chunk size, and must leave about 128Kb
398 of space at the end of the drive for the RAID superblock.
399 If this is not specified
400 (as it normally is not) the smallest drive (or partition) sets the
401 size, though if there is a variance among the drives of greater than 1%, a warning is
402 issued.
403
404 This value can be set with
405 .B \-\-grow
406 for RAID level 1/4/5/6. If the array was created with a size smaller
407 than the currently active drives, the extra space can be accessed
408 using
409 .BR \-\-grow .
410 The size can be given as
411 .B max
412 which means to choose the largest size that fits on all current drives.
413
414 .TP
415 .BR \-c ", " \-\-chunk=
416 Specify chunk size of kibibytes. The default is 64.
417
418 .TP
419 .BR \-\-rounding=
420 Specify rounding factor for linear array (==chunk size)
421
422 .TP
423 .BR \-l ", " \-\-level=
424 Set raid level. When used with
425 .BR \-\-create ,
426 options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4,
427 raid5, 5, raid6, 6, raid10, 10, multipath, mp, faulty. Obviously some of these are synonymous.
428
429 When used with
430 .BR \-\-build ,
431 only linear, stripe, raid0, 0, raid1, multipath, mp, and faulty are valid.
432
433 Not yet supported with
434 .BR \-\-grow .
435
436 .TP
437 .BR \-p ", " \-\-layout=
438 This option configures the fine details of data layout for raid5,
439 and raid10 arrays, and controls the failure modes for
440 .IR faulty .
441
442 The layout of the raid5 parity block can be one of
443 .BR left\-asymmetric ,
444 .BR left\-symmetric ,
445 .BR right\-asymmetric ,
446 .BR right\-symmetric ,
447 .BR la ", " ra ", " ls ", " rs .
448 The default is
449 .BR left\-symmetric .
450
451 When setting the failure mode for level
452 .I faulty,
453 the options are:
454 .BR write\-transient ", " wt ,
455 .BR read\-transient ", " rt ,
456 .BR write\-persistent ", " wp ,
457 .BR read\-persistent ", " rp ,
458 .BR write\-all ,
459 .BR read\-fixable ", " rf ,
460 .BR clear ", " flush ", " none .
461
462 Each failure mode can be followed by a number, which is used as a period
463 between fault generation. Without a number, the fault is generated
464 once on the first relevant request. With a number, the fault will be
465 generated after that many requests, and will continue to be generated
466 every time the period elapses.
467
468 Multiple failure modes can be current simultaneously by using the
469 .B \-\-grow
470 option to set subsequent failure modes.
471
472 "clear" or "none" will remove any pending or periodic failure modes,
473 and "flush" will clear any persistent faults.
474
475 To set the parity with
476 .BR \-\-grow ,
477 the level of the array ("faulty")
478 must be specified before the fault mode is specified.
479
480 Finally, the layout options for RAID10 are one of 'n', 'o' or 'f' followed
481 by a small number. The default is 'n2'. The supported options are:
482
483 .I 'n'
484 signals 'near' copies. Multiple copies of one data block are at
485 similar offsets in different devices.
486
487 .I 'o'
488 signals 'offset' copies. Rather than the chunks being duplicated
489 within a stripe, whole stripes are duplicated but are rotated by one
490 device so duplicate blocks are on different devices. Thus subsequent
491 copies of a block are in the next drive, and are one chunk further
492 down.
493
494 .I 'f'
495 signals 'far' copies
496 (multiple copies have very different offsets).
497 See md(4) for more detail about 'near' and 'far'.
498
499 The number is the number of copies of each datablock. 2 is normal, 3
500 can be useful. This number can be at most equal to the number of
501 devices in the array. It does not need to divide evenly into that
502 number (e.g. it is perfectly legal to have an 'n2' layout for an array
503 with an odd number of devices).
504
505 .TP
506 .BR \-\-parity=
507 same as
508 .B \-\-layout
509 (thus explaining the p of
510 .BR \-p ).
511
512 .TP
513 .BR \-b ", " \-\-bitmap=
514 Specify a file to store a write-intent bitmap in. The file should not
515 exist unless
516 .B \-\-force
517 is also given. The same file should be provided
518 when assembling the array. If the word
519 .B "internal"
520 is given, then the bitmap is stored with the metadata on the array,
521 and so is replicated on all devices. If the word
522 .B "none"
523 is given with
524 .B \-\-grow
525 mode, then any bitmap that is present is removed.
526
527 To help catch typing errors, the filename must contain at least one
528 slash ('/') if it is a real file (not 'internal' or 'none').
529
530 Note: external bitmaps are only known to work on ext2 and ext3.
531 Storing bitmap files on other filesystems may result in serious problems.
532
533 .TP
534 .BR \-\-bitmap\-chunk=
535 Set the chunksize of the bitmap. Each bit corresponds to that many
536 Kilobytes of storage.
537 When using a file based bitmap, the default is to use the smallest
538 size that is at-least 4 and requires no more than 2^21 chunks.
539 When using an
540 .B internal
541 bitmap, the chunksize is automatically determined to make best use of
542 available space.
543
544
545 .TP
546 .BR \-W ", " \-\-write\-mostly
547 subsequent devices lists in a
548 .BR \-\-build ,
549 .BR \-\-create ,
550 or
551 .B \-\-add
552 command will be flagged as 'write-mostly'. This is valid for RAID1
553 only and means that the 'md' driver will avoid reading from these
554 devices if at all possible. This can be useful if mirroring over a
555 slow link.
556
557 .TP
558 .BR \-\-write\-behind=
559 Specify that write-behind mode should be enabled (valid for RAID1
560 only). If an argument is specified, it will set the maximum number
561 of outstanding writes allowed. The default value is 256.
562 A write-intent bitmap is required in order to use write-behind
563 mode, and write-behind is only attempted on drives marked as
564 .IR write-mostly .
565
566 .TP
567 .BR \-\-assume\-clean
568 Tell
569 .I mdadm
570 that the array pre-existed and is known to be clean. It can be useful
571 when trying to recover from a major failure as you can be sure that no
572 data will be affected unless you actually write to the array. It can
573 also be used when creating a RAID1 or RAID10 if you want to avoid the
574 initial resync, however this practice \(em while normally safe \(em is not
575 recommended. Use this only if you really know what you are doing.
576
577 .TP
578 .BR \-\-backup\-file=
579 This is needed when
580 .B \-\-grow
581 is used to increase the number of
582 raid-devices in a RAID5 if there are no spare devices available.
583 See the section below on RAID_DEVICE CHANGES. The file should be
584 stored on a separate device, not on the raid array being reshaped.
585
586 .TP
587 .BR \-N ", " \-\-name=
588 Set a
589 .B name
590 for the array. This is currently only effective when creating an
591 array with a version-1 superblock. The name is a simple textual
592 string that can be used to identify array components when assembling.
593
594 .TP
595 .BR \-R ", " \-\-run
596 Insist that
597 .I mdadm
598 run the array, even if some of the components
599 appear to be active in another array or filesystem. Normally
600 .I mdadm
601 will ask for confirmation before including such components in an
602 array. This option causes that question to be suppressed.
603
604 .TP
605 .BR \-f ", " \-\-force
606 Insist that
607 .I mdadm
608 accept the geometry and layout specified without question. Normally
609 .I mdadm
610 will not allow creation of an array with only one device, and will try
611 to create a raid5 array with one missing drive (as this makes the
612 initial resync work faster). With
613 .BR \-\-force ,
614 .I mdadm
615 will not try to be so clever.
616
617 .TP
618 .BR \-a ", " "\-\-auto{=no,yes,md,mdp,part,p}{NN}"
619 Instruct mdadm to create the device file if needed, possibly allocating
620 an unused minor number. "md" causes a non-partitionable array
621 to be used. "mdp", "part" or "p" causes a partitionable array (2.6 and
622 later) to be used. "yes" requires the named md device to have
623 a 'standard' format, and the type and minor number will be determined
624 from this. See DEVICE NAMES below.
625
626 The argument can also come immediately after
627 "\-a". e.g. "\-ap".
628
629 If
630 .B \-\-auto
631 is not given on the command line or in the config file, then
632 the default will be
633 .BR \-\-auto=yes .
634
635 If
636 .B \-\-scan
637 is also given, then any
638 .I auto=
639 entries in the config file will override the
640 .B \-\-auto
641 instruction given on the command line.
642
643 For partitionable arrays,
644 .I mdadm
645 will create the device file for the whole array and for the first 4
646 partitions. A different number of partitions can be specified at the
647 end of this option (e.g.
648 .BR \-\-auto=p7 ).
649 If the device name ends with a digit, the partition names add a 'p',
650 and a number, e.g. "/dev/home1p3". If there is no
651 trailing digit, then the partition names just have a number added,
652 e.g. "/dev/scratch3".
653
654 If the md device name is in a 'standard' format as described in DEVICE
655 NAMES, then it will be created, if necessary, with the appropriate
656 number based on that name. If the device name is not in one of these
657 formats, then a unused minor number will be allocated. The minor
658 number will be considered unused if there is no active array for that
659 number, and there is no entry in /dev for that number and with a
660 non-standard name.
661
662 .TP
663 .BR \-\-symlink = no
664 Normally when
665 .B \-\-auto
666 causes
667 .I mdadm
668 to create devices in
669 .B /dev/md/
670 it will also create symlinks from
671 .B /dev/
672 with names starting with
673 .B md
674 or
675 .BR md_ .
676 Use
677 .B \-\-symlink=no
678 to suppress this, or
679 .B \-\-symlink=yes
680 to enforce this even if it is suppressing
681 .IR mdadm.conf .
682
683
684 .SH For assemble:
685
686 .TP
687 .BR \-u ", " \-\-uuid=
688 uuid of array to assemble. Devices which don't have this uuid are
689 excluded
690
691 .TP
692 .BR \-m ", " \-\-super\-minor=
693 Minor number of device that array was created for. Devices which
694 don't have this minor number are excluded. If you create an array as
695 /dev/md1, then all superblocks will contain the minor number 1, even if
696 the array is later assembled as /dev/md2.
697
698 Giving the literal word "dev" for
699 .B \-\-super\-minor
700 will cause
701 .I mdadm
702 to use the minor number of the md device that is being assembled.
703 e.g. when assembling
704 .BR /dev/md0 ,
705 .B \-\-super\-minor=dev
706 will look for super blocks with a minor number of 0.
707
708 .TP
709 .BR \-N ", " \-\-name=
710 Specify the name of the array to assemble. This must be the name
711 that was specified when creating the array. It must either match
712 the name stored in the superblock exactly, or it must match
713 with the current
714 .I homehost
715 prefixed to the start of the given name.
716
717 .TP
718 .BR \-f ", " \-\-force
719 Assemble the array even if some superblocks appear out-of-date
720
721 .TP
722 .BR \-R ", " \-\-run
723 Attempt to start the array even if fewer drives were given than were
724 present last time the array was active. Normally if not all the
725 expected drives are found and
726 .B \-\-scan
727 is not used, then the array will be assembled but not started.
728 With
729 .B \-\-run
730 an attempt will be made to start it anyway.
731
732 .TP
733 .B \-\-no\-degraded
734 This is the reverse of
735 .B \-\-run
736 in that it inhibits the startup of array unless all expected drives
737 are present. This is only needed with
738 .B \-\-scan,
739 and can be used if the physical connections to devices are
740 not as reliable as you would like.
741
742 .TP
743 .BR \-a ", " "\-\-auto{=no,yes,md,mdp,part}"
744 See this option under Create and Build options.
745
746 .TP
747 .BR \-b ", " \-\-bitmap=
748 Specify the bitmap file that was given when the array was created. If
749 an array has an
750 .B internal
751 bitmap, there is no need to specify this when assembling the array.
752
753 .TP
754 .BR \-\-backup\-file=
755 If
756 .B \-\-backup\-file
757 was used to grow the number of raid-devices in a RAID5, and the system
758 crashed during the critical section, then the same
759 .B \-\-backup\-file
760 must be presented to
761 .B \-\-assemble
762 to allow possibly corrupted data to be restored.
763
764 .TP
765 .BR \-U ", " \-\-update=
766 Update the superblock on each device while assembling the array. The
767 argument given to this flag can be one of
768 .BR sparc2.2 ,
769 .BR summaries ,
770 .BR uuid ,
771 .BR name ,
772 .BR homehost ,
773 .BR resync ,
774 .BR byteorder ,
775 .BR devicesize ,
776 or
777 .BR super\-minor .
778
779 The
780 .B sparc2.2
781 option will adjust the superblock of an array what was created on a Sparc
782 machine running a patched 2.2 Linux kernel. This kernel got the
783 alignment of part of the superblock wrong. You can use the
784 .B "\-\-examine \-\-sparc2.2"
785 option to
786 .I mdadm
787 to see what effect this would have.
788
789 The
790 .B super\-minor
791 option will update the
792 .B "preferred minor"
793 field on each superblock to match the minor number of the array being
794 assembled.
795 This can be useful if
796 .B \-\-examine
797 reports a different "Preferred Minor" to
798 .BR \-\-detail .
799 In some cases this update will be performed automatically
800 by the kernel driver. In particular the update happens automatically
801 at the first write to an array with redundancy (RAID level 1 or
802 greater) on a 2.6 (or later) kernel.
803
804 The
805 .B uuid
806 option will change the uuid of the array. If a UUID is given with the
807 .B \-\-uuid
808 option that UUID will be used as a new UUID and will
809 .B NOT
810 be used to help identify the devices in the array.
811 If no
812 .B \-\-uuid
813 is given, a random UUID is chosen.
814
815 The
816 .B name
817 option will change the
818 .I name
819 of the array as stored in the superblock. This is only supported for
820 version-1 superblocks.
821
822 The
823 .B homehost
824 option will change the
825 .I homehost
826 as recorded in the superblock. For version-0 superblocks, this is the
827 same as updating the UUID.
828 For version-1 superblocks, this involves updating the name.
829
830 The
831 .B resync
832 option will cause the array to be marked
833 .I dirty
834 meaning that any redundancy in the array (e.g. parity for raid5,
835 copies for raid1) may be incorrect. This will cause the raid system
836 to perform a "resync" pass to make sure that all redundant information
837 is correct.
838
839 The
840 .B byteorder
841 option allows arrays to be moved between machines with different
842 byte-order.
843 When assembling such an array for the first time after a move, giving
844 .B "\-\-update=byteorder"
845 will cause
846 .I mdadm
847 to expect superblocks to have their byteorder reversed, and will
848 correct that order before assembling the array. This is only valid
849 with original (Version 0.90) superblocks.
850
851 The
852 .B summaries
853 option will correct the summaries in the superblock. That is the
854 counts of total, working, active, failed, and spare devices.
855
856 The
857 .B devicesize
858 will rarely be of use. It applies to version 1.1 and 1.2 metadata
859 only (where the metadata is at the start of the device) and is only
860 useful when the component device has changed size (typically become
861 larger). The version 1 metadata records the amount of the device that
862 can be used to store data, so if a device in a version 1.1 or 1.2
863 array becomes larger, the metadata will still be visible, but the
864 extra space will not. In this case it might be useful to assemble the
865 array with
866 .BR \-\-update=devicesize .
867 This will cause
868 .I mdadm
869 to determine the maximum usable amount of space on each device and
870 update the relevant field in the metadata.
871
872 .TP
873 .B \-\-auto\-update\-homehost
874 This flag is only meaningful with auto-assembly (see discussion below).
875 In that situation, if no suitable arrays are found for this homehost,
876 .I mdadm
877 will rescan for any arrays at all and will assemble them and update the
878 homehost to match the current host.
879
880 .SH For Manage mode:
881
882 .TP
883 .BR \-a ", " \-\-add
884 hot-add listed devices.
885
886 .TP
887 .BR \-\-re\-add
888 re-add a device that was recently removed from an array.
889
890 .TP
891 .BR \-r ", " \-\-remove
892 remove listed devices. They must not be active. i.e. they should
893 be failed or spare devices. As well as the name of a device file
894 (e.g.
895 .BR /dev/sda1 )
896 the words
897 .B failed
898 and
899 .B detached
900 can be given to
901 .BR \-\-remove .
902 The first causes all failed device to be removed. The second causes
903 any device which is no longer connected to the system (i.e an 'open'
904 returns
905 .BR ENXIO )
906 to be removed. This will only succeed for devices that are spares or
907 have already been marked as failed.
908
909 .TP
910 .BR \-f ", " \-\-fail
911 mark listed devices as faulty.
912 As well as the name of a device file, the word
913 .B detached
914 can be given. This will cause any device that has been detached from
915 the system to be marked as failed. It can then be removed.
916
917 .TP
918 .BR \-\-set\-faulty
919 same as
920 .BR \-\-fail .
921
922 .TP
923 .BR \-\-write\-mostly
924 Subsequent devices that are added or re-added will have the 'write-mostly'
925 flag set. This is only valid for RAID! and means that the 'md' driver
926 will avoid reading from these devices if possible.
927 .TP
928 .BR \-\-readwrite
929 Subsequent devices that are added or re-added will have the 'write-mostly'
930 flag cleared.
931
932
933 .P
934 Each of these options require that the first device listed is the array
935 to be acted upon, and the remainder are component devices to be added,
936 removed, or marked as faulty. Several different operations can be
937 specified for different devices, e.g.
938 .in +5
939 mdadm /dev/md0 \-\-add /dev/sda1 \-\-fail /dev/sdb1 \-\-remove /dev/sdb1
940 .in -5
941 Each operation applies to all devices listed until the next
942 operation.
943
944 If an array is using a write-intent bitmap, then devices which have
945 been removed can be re-added in a way that avoids a full
946 reconstruction but instead just updates the blocks that have changed
947 since the device was removed. For arrays with persistent metadata
948 (superblocks) this is done automatically. For arrays created with
949 .B \-\-build
950 mdadm needs to be told that this device we removed recently with
951 .BR \-\-re\-add .
952
953 Devices can only be removed from an array if they are not in active
954 use, i.e. that must be spares or failed devices. To remove an active
955 device, it must first be marked as
956 .B faulty.
957
958 .SH For Misc mode:
959
960 .TP
961 .BR \-Q ", " \-\-query
962 Examine a device to see
963 (1) if it is an md device and (2) if it is a component of an md
964 array.
965 Information about what is discovered is presented.
966
967 .TP
968 .BR \-D ", " \-\-detail
969 Print detail of one or more md devices.
970
971 .TP
972 .BR \-Y ", " \-\-export
973 When used with
974 .B \-\-detail
975 or
976 .BR \-\-examine ,
977 output will be formatted as
978 .B key=value
979 pairs for easy import into the environment.
980
981 .TP
982 .BR \-E ", " \-\-examine
983 Print content of md superblock on device(s).
984 .TP
985 .B \-\-sparc2.2
986 If an array was created on a 2.2 Linux kernel patched with RAID
987 support, the superblock will have been created incorrectly, or at
988 least incompatibly with 2.4 and later kernels. Using the
989 .B \-\-sparc2.2
990 flag with
991 .B \-\-examine
992 will fix the superblock before displaying it. If this appears to do
993 the right thing, then the array can be successfully assembled using
994 .BR "\-\-assemble \-\-update=sparc2.2" .
995
996 .TP
997 .BR \-X ", " \-\-examine\-bitmap
998 Report information about a bitmap file.
999 The argument is either an external bitmap file or an array component
1000 in case of an internal bitmap.
1001
1002 .TP
1003 .BR \-R ", " \-\-run
1004 start a partially built array.
1005
1006 .TP
1007 .BR \-S ", " \-\-stop
1008 deactivate array, releasing all resources.
1009
1010 .TP
1011 .BR \-o ", " \-\-readonly
1012 mark array as readonly.
1013
1014 .TP
1015 .BR \-w ", " \-\-readwrite
1016 mark array as readwrite.
1017
1018 .TP
1019 .B \-\-zero\-superblock
1020 If the device contains a valid md superblock, the block is
1021 overwritten with zeros. With
1022 .B \-\-force
1023 the block where the superblock would be is overwritten even if it
1024 doesn't appear to be valid.
1025
1026 .TP
1027 .BR \-t ", " \-\-test
1028 When used with
1029 .BR \-\-detail ,
1030 the exit status of
1031 .I mdadm
1032 is set to reflect the status of the device.
1033
1034 .TP
1035 .BR \-W ", " \-\-wait
1036 For each md device given, wait for any resync, recovery, or reshape
1037 activity to finish before returning.
1038 .I mdadm
1039 will return with success if it actually waited for every device
1040 listed, otherwise it will return failure.
1041
1042 .TP
1043 .BR \-\-wait\-clean
1044 For each md device given, arrange for the array to be marked clean as
1045 soon as possible. Also, quiesce resync so that the monitor for external
1046 metadata arrays (mdmon) has an opportunity to checkpoint the resync
1047 position.
1048 .I mdadm
1049 will return with success if the array uses external metadata and we
1050 successfully waited. For native arrays this returns immediately as the
1051 kernel handles both dirty-clean transitions and resync checkpointing in
1052 the kernel at shutdown. No action is taken if safe-mode handling is
1053 disabled.
1054
1055 .SH For Incremental Assembly mode:
1056 .TP
1057 .BR \-\-rebuild\-map ", " \-r
1058 Rebuild the map file
1059 .RB ( /var/run/mdadm/map )
1060 that
1061 .I mdadm
1062 uses to help track which arrays are currently being assembled.
1063
1064 .TP
1065 .BR \-\-run ", " \-R
1066 Run any array assembled as soon as a minimal number of devices are
1067 available, rather than waiting until all expected devices are present.
1068
1069 .TP
1070 .BR \-\-scan ", " \-s
1071 Only meaningful with
1072 .B \-R
1073 this will scan the
1074 .B map
1075 file for arrays that are being incrementally assembled and will try to
1076 start any that are not already started. If any such array is listed
1077 in
1078 .B mdadm.conf
1079 as requiring an external bitmap, that bitmap will be attached first.
1080
1081 .SH For Monitor mode:
1082 .TP
1083 .BR \-m ", " \-\-mail
1084 Give a mail address to send alerts to.
1085
1086 .TP
1087 .BR \-p ", " \-\-program ", " \-\-alert
1088 Give a program to be run whenever an event is detected.
1089
1090 .TP
1091 .BR \-y ", " \-\-syslog
1092 Cause all events to be reported through 'syslog'. The messages have
1093 facility of 'daemon' and varying priorities.
1094
1095 .TP
1096 .BR \-d ", " \-\-delay
1097 Give a delay in seconds.
1098 .I mdadm
1099 polls the md arrays and then waits this many seconds before polling
1100 again. The default is 60 seconds.
1101
1102 .TP
1103 .BR \-f ", " \-\-daemonise
1104 Tell
1105 .I mdadm
1106 to run as a background daemon if it decides to monitor anything. This
1107 causes it to fork and run in the child, and to disconnect form the
1108 terminal. The process id of the child is written to stdout.
1109 This is useful with
1110 .B \-\-scan
1111 which will only continue monitoring if a mail address or alert program
1112 is found in the config file.
1113
1114 .TP
1115 .BR \-i ", " \-\-pid\-file
1116 When
1117 .I mdadm
1118 is running in daemon mode, write the pid of the daemon process to
1119 the specified file, instead of printing it on standard output.
1120
1121 .TP
1122 .BR \-1 ", " \-\-oneshot
1123 Check arrays only once. This will generate
1124 .B NewArray
1125 events and more significantly
1126 .B DegradedArray
1127 and
1128 .B SparesMissing
1129 events. Running
1130 .in +5
1131 .B " mdadm \-\-monitor \-\-scan \-1"
1132 .in -5
1133 from a cron script will ensure regular notification of any degraded arrays.
1134
1135 .TP
1136 .BR \-t ", " \-\-test
1137 Generate a
1138 .B TestMessage
1139 alert for every array found at startup. This alert gets mailed and
1140 passed to the alert program. This can be used for testing that alert
1141 message do get through successfully.
1142
1143 .SH ASSEMBLE MODE
1144
1145 .HP 12
1146 Usage:
1147 .B mdadm \-\-assemble
1148 .I md-device options-and-component-devices...
1149 .HP 12
1150 Usage:
1151 .B mdadm \-\-assemble \-\-scan
1152 .I md-devices-and-options...
1153 .HP 12
1154 Usage:
1155 .B mdadm \-\-assemble \-\-scan
1156 .I options...
1157
1158 .PP
1159 This usage assembles one or more raid arrays from pre-existing components.
1160 For each array, mdadm needs to know the md device, the identity of the
1161 array, and a number of component-devices. These can be found in a number of ways.
1162
1163 In the first usage example (without the
1164 .BR \-\-scan )
1165 the first device given is the md device.
1166 In the second usage example, all devices listed are treated as md
1167 devices and assembly is attempted.
1168 In the third (where no devices are listed) all md devices that are
1169 listed in the configuration file are assembled.
1170
1171 If precisely one device is listed, but
1172 .B \-\-scan
1173 is not given, then
1174 .I mdadm
1175 acts as though
1176 .B \-\-scan
1177 was given and identity information is extracted from the configuration file.
1178
1179 The identity can be given with the
1180 .B \-\-uuid
1181 option, with the
1182 .B \-\-super\-minor
1183 option, will be taken from the md-device record in the config file, or
1184 will be taken from the super block of the first component-device
1185 listed on the command line.
1186
1187 Devices can be given on the
1188 .B \-\-assemble
1189 command line or in the config file. Only devices which have an md
1190 superblock which contains the right identity will be considered for
1191 any array.
1192
1193 The config file is only used if explicitly named with
1194 .B \-\-config
1195 or requested with (a possibly implicit)
1196 .BR \-\-scan .
1197 In the later case,
1198 .B /etc/mdadm.conf
1199 is used.
1200
1201 If
1202 .B \-\-scan
1203 is not given, then the config file will only be used to find the
1204 identity of md arrays.
1205
1206 Normally the array will be started after it is assembled. However if
1207 .B \-\-scan
1208 is not given and insufficient drives were listed to start a complete
1209 (non-degraded) array, then the array is not started (to guard against
1210 usage errors). To insist that the array be started in this case (as
1211 may work for RAID1, 4, 5, 6, or 10), give the
1212 .B \-\-run
1213 flag.
1214
1215 If the md device does not exist, then it will be created providing the
1216 intent is clear. i.e. the name must be in a standard form, or the
1217 .B \-\-auto
1218 option must be given to clarify how and whether the device should be
1219 created.
1220 This can be useful for handling partitioned devices (which don't have
1221 a stable device number \(em it can change after a reboot) and when using
1222 "udev" to manage your
1223 .B /dev
1224 tree (udev cannot handle md devices because of the unusual device
1225 initialisation conventions).
1226
1227 If the option to "auto" is "mdp" or "part" or (on the command line
1228 only) "p", then mdadm will create a partitionable array, using the
1229 first free one that is not in use and does not already have an entry
1230 in /dev (apart from numeric /dev/md* entries).
1231
1232 If the option to "auto" is "yes" or "md" or (on the command line)
1233 nothing, then mdadm will create a traditional, non-partitionable md
1234 array.
1235
1236 It is expected that the "auto" functionality will be used to create
1237 device entries with meaningful names such as "/dev/md/home" or
1238 "/dev/md/root", rather than names based on the numerical array number.
1239
1240 When using option "auto" to create a partitionable array, the device
1241 files for the first 4 partitions are also created. If a different
1242 number is required it can be simply appended to the auto option.
1243 e.g. "auto=part8". Partition names are created by appending a digit
1244 string to the device name, with an intervening "p" if the device name
1245 ends with a digit.
1246
1247 The
1248 .B \-\-auto
1249 option is also available in Build and Create modes. As those modes do
1250 not use a config file, the "auto=" config option does not apply to
1251 these modes.
1252
1253 .SS Auto Assembly
1254 When
1255 .B \-\-assemble
1256 is used with
1257 .B \-\-scan
1258 and no devices are listed,
1259 .I mdadm
1260 will first attempt to assemble all the arrays listed in the config
1261 file.
1262
1263 If a
1264 .B homehost
1265 has been specified (either in the config file or on the command line),
1266 .I mdadm
1267 will look further for possible arrays and will try to assemble
1268 anything that it finds which is tagged as belonging to the given
1269 homehost. This is the only situation where
1270 .I mdadm
1271 will assemble arrays without being given specific device name or
1272 identity information for the array.
1273
1274 If
1275 .I mdadm
1276 finds a consistent set of devices that look like they should comprise
1277 an array, and if the superblock is tagged as belonging to the given
1278 home host, it will automatically choose a device name and try to
1279 assemble the array. If the array uses version-0.90 metadata, then the
1280 .B minor
1281 number as recorded in the superblock is used to create a name in
1282 .B /dev/md/
1283 so for example
1284 .BR /dev/md/3 .
1285 If the array uses version-1 metadata, then the
1286 .B name
1287 from the superblock is used to similarly create a name in
1288 .BR /dev/md
1289 (the name will have any 'host' prefix stripped first).
1290
1291 If
1292 .I mdadm
1293 cannot find any array for the given host at all, and if
1294 .B \-\-auto\-update\-homehost
1295 is given, then
1296 .I mdadm
1297 will search again for any array (not just an array created for this
1298 host) and will assemble each assuming
1299 .BR \-\-update=homehost .
1300 This will change the host tag in the superblock so that on the next run,
1301 these arrays will be found without the second pass. The intention of
1302 this feature is to support transitioning a set of md arrays to using
1303 homehost tagging.
1304
1305 The reason for requiring arrays to be tagged with the homehost for
1306 auto assembly is to guard against problems that can arise when moving
1307 devices from one host to another.
1308
1309 .SH BUILD MODE
1310
1311 .HP 12
1312 Usage:
1313 .B mdadm \-\-build
1314 .I md-device
1315 .BI \-\-chunk= X
1316 .BI \-\-level= Y
1317 .BI \-\-raid\-devices= Z
1318 .I devices
1319
1320 .PP
1321 This usage is similar to
1322 .BR \-\-create .
1323 The difference is that it creates an array without a superblock. With
1324 these arrays there is no difference between initially creating the array and
1325 subsequently assembling the array, except that hopefully there is useful
1326 data there in the second case.
1327
1328 The level may raid0, linear, multipath, or faulty, or one of their
1329 synonyms. All devices must be listed and the array will be started
1330 once complete.
1331
1332 .SH CREATE MODE
1333
1334 .HP 12
1335 Usage:
1336 .B mdadm \-\-create
1337 .I md-device
1338 .BI \-\-chunk= X
1339 .BI \-\-level= Y
1340 .br
1341 .BI \-\-raid\-devices= Z
1342 .I devices
1343
1344 .PP
1345 This usage will initialise a new md array, associate some devices with
1346 it, and activate the array.
1347
1348 If the
1349 .B \-\-auto
1350 option is given (as described in more detail in the section on
1351 Assemble mode), then the md device will be created with a suitable
1352 device number if necessary.
1353
1354 As devices are added, they are checked to see if they contain raid
1355 superblocks or filesystems. They are also checked to see if the variance in
1356 device size exceeds 1%.
1357
1358 If any discrepancy is found, the array will not automatically be run, though
1359 the presence of a
1360 .B \-\-run
1361 can override this caution.
1362
1363 To create a "degraded" array in which some devices are missing, simply
1364 give the word "\fBmissing\fP"
1365 in place of a device name. This will cause
1366 .I mdadm
1367 to leave the corresponding slot in the array empty.
1368 For a RAID4 or RAID5 array at most one slot can be
1369 "\fBmissing\fP"; for a RAID6 array at most two slots.
1370 For a RAID1 array, only one real device needs to be given. All of the
1371 others can be
1372 "\fBmissing\fP".
1373
1374 When creating a RAID5 array,
1375 .I mdadm
1376 will automatically create a degraded array with an extra spare drive.
1377 This is because building the spare into a degraded array is in general faster than resyncing
1378 the parity on a non-degraded, but not clean, array. This feature can
1379 be overridden with the
1380 .B \-\-force
1381 option.
1382
1383 When creating an array with version-1 metadata a name for the array is
1384 required.
1385 If this is not given with the
1386 .B \-\-name
1387 option,
1388 .I mdadm
1389 will choose a name based on the last component of the name of the
1390 device being created. So if
1391 .B /dev/md3
1392 is being created, then the name
1393 .B 3
1394 will be chosen.
1395 If
1396 .B /dev/md/home
1397 is being created, then the name
1398 .B home
1399 will be used.
1400
1401 When creating a partition based array, using
1402 .I mdadm
1403 with version-1.x metadata, the partition type should be set to
1404 .B 0xDA
1405 (non fs-data). This type selection allows for greater precision since
1406 using any other [RAID auto-detect (0xFD) or a GNU/Linux partition (0x83)],
1407 might create problems in the event of array recovery through a live cdrom.
1408
1409 A new array will normally get a randomly assigned 128bit UUID which is
1410 very likely to be unique. If you have a specific need, you can choose
1411 a UUID for the array by giving the
1412 .B \-\-uuid=
1413 option. Be warned that creating two arrays with the same UUID is a
1414 recipe for disaster. Also, using
1415 .B \-\-uuid=
1416 when creating a v0.90 array will silently override any
1417 .B \-\-homehost=
1418 setting.
1419 .\"If the
1420 .\".B \-\-size
1421 .\"option is given, it is not necessary to list any component-devices in this command.
1422 .\"They can be added later, before a
1423 .\".B \-\-run.
1424 .\"If no
1425 .\".B \-\-size
1426 .\"is given, the apparent size of the smallest drive given is used.
1427
1428 The General Management options that are valid with
1429 .B \-\-create
1430 are:
1431 .TP
1432 .B \-\-run
1433 insist on running the array even if some devices look like they might
1434 be in use.
1435
1436 .TP
1437 .B \-\-readonly
1438 start the array readonly \(em not supported yet.
1439
1440
1441 .SH MANAGE MODE
1442 .HP 12
1443 Usage:
1444 .B mdadm
1445 .I device
1446 .I options... devices...
1447 .PP
1448
1449 This usage will allow individual devices in an array to be failed,
1450 removed or added. It is possible to perform multiple operations with
1451 on command. For example:
1452 .br
1453 .B " mdadm /dev/md0 \-f /dev/hda1 \-r /dev/hda1 \-a /dev/hda1"
1454 .br
1455 will firstly mark
1456 .B /dev/hda1
1457 as faulty in
1458 .B /dev/md0
1459 and will then remove it from the array and finally add it back
1460 in as a spare. However only one md array can be affected by a single
1461 command.
1462
1463 .SH MISC MODE
1464 .HP 12
1465 Usage:
1466 .B mdadm
1467 .I options ...
1468 .I devices ...
1469 .PP
1470
1471 MISC mode includes a number of distinct operations that
1472 operate on distinct devices. The operations are:
1473 .TP
1474 .B \-\-query
1475 The device is examined to see if it is
1476 (1) an active md array, or
1477 (2) a component of an md array.
1478 The information discovered is reported.
1479
1480 .TP
1481 .B \-\-detail
1482 The device should be an active md device.
1483 .B mdadm
1484 will display a detailed description of the array.
1485 .B \-\-brief
1486 or
1487 .B \-\-scan
1488 will cause the output to be less detailed and the format to be
1489 suitable for inclusion in
1490 .BR /etc/mdadm.conf .
1491 The exit status of
1492 .I mdadm
1493 will normally be 0 unless
1494 .I mdadm
1495 failed to get useful information about the device(s); however, if the
1496 .B \-\-test
1497 option is given, then the exit status will be:
1498 .RS
1499 .TP
1500 0
1501 The array is functioning normally.
1502 .TP
1503 1
1504 The array has at least one failed device.
1505 .TP
1506 2
1507 The array has multiple failed devices such that it is unusable.
1508 .TP
1509 4
1510 There was an error while trying to get information about the device.
1511 .RE
1512
1513 .TP
1514 .B \-\-examine
1515 The device should be a component of an md array.
1516 .I mdadm
1517 will read the md superblock of the device and display the contents.
1518 If
1519 .B \-\-brief
1520 or
1521 .B \-\-scan
1522 is given, then multiple devices that are components of the one array
1523 are grouped together and reported in a single entry suitable
1524 for inclusion in
1525 .BR /etc/mdadm.conf .
1526
1527 Having
1528 .B \-\-scan
1529 without listing any devices will cause all devices listed in the
1530 config file to be examined.
1531
1532 .TP
1533 .B \-\-stop
1534 The devices should be active md arrays which will be deactivated, as
1535 long as they are not currently in use.
1536
1537 .TP
1538 .B \-\-run
1539 This will fully activate a partially assembled md array.
1540
1541 .TP
1542 .B \-\-readonly
1543 This will mark an active array as read-only, providing that it is
1544 not currently being used.
1545
1546 .TP
1547 .B \-\-readwrite
1548 This will change a
1549 .B readonly
1550 array back to being read/write.
1551
1552 .TP
1553 .B \-\-scan
1554 For all operations except
1555 .BR \-\-examine ,
1556 .B \-\-scan
1557 will cause the operation to be applied to all arrays listed in
1558 .BR /proc/mdstat .
1559 For
1560 .BR \-\-examine,
1561 .B \-\-scan
1562 causes all devices listed in the config file to be examined.
1563
1564
1565 .SH MONITOR MODE
1566
1567 .HP 12
1568 Usage:
1569 .B mdadm \-\-monitor
1570 .I options... devices...
1571
1572 .PP
1573 This usage causes
1574 .I mdadm
1575 to periodically poll a number of md arrays and to report on any events
1576 noticed.
1577 .I mdadm
1578 will never exit once it decides that there are arrays to be checked,
1579 so it should normally be run in the background.
1580
1581 As well as reporting events,
1582 .I mdadm
1583 may move a spare drive from one array to another if they are in the
1584 same
1585 .B spare-group
1586 and if the destination array has a failed drive but no spares.
1587
1588 If any devices are listed on the command line,
1589 .I mdadm
1590 will only monitor those devices. Otherwise all arrays listed in the
1591 configuration file will be monitored. Further, if
1592 .B \-\-scan
1593 is given, then any other md devices that appear in
1594 .B /proc/mdstat
1595 will also be monitored.
1596
1597 The result of monitoring the arrays is the generation of events.
1598 These events are passed to a separate program (if specified) and may
1599 be mailed to a given E-mail address.
1600
1601 When passing events to a program, the program is run once for each event,
1602 and is given 2 or 3 command-line arguments: the first is the
1603 name of the event (see below), the second is the name of the
1604 md device which is affected, and the third is the name of a related
1605 device if relevant (such as a component device that has failed).
1606
1607 If
1608 .B \-\-scan
1609 is given, then a program or an E-mail address must be specified on the
1610 command line or in the config file. If neither are available, then
1611 .I mdadm
1612 will not monitor anything.
1613 Without
1614 .B \-\-scan,
1615 .I mdadm
1616 will continue monitoring as long as something was found to monitor. If
1617 no program or email is given, then each event is reported to
1618 .BR stdout .
1619
1620 The different events are:
1621
1622 .RS 4
1623 .TP
1624 .B DeviceDisappeared
1625 An md array which previously was configured appears to no longer be
1626 configured. (syslog priority: Critical)
1627
1628 If
1629 .I mdadm
1630 was told to monitor an array which is RAID0 or Linear, then it will
1631 report
1632 .B DeviceDisappeared
1633 with the extra information
1634 .BR Wrong-Level .
1635 This is because RAID0 and Linear do not support the device-failed,
1636 hot-spare and resync operations which are monitored.
1637
1638 .TP
1639 .B RebuildStarted
1640 An md array started reconstruction. (syslog priority: Warning)
1641
1642 .TP
1643 .BI Rebuild NN
1644 Where
1645 .I NN
1646 is 20, 40, 60, or 80, this indicates that rebuild has passed that many
1647 percentage of the total. (syslog priority: Warning)
1648
1649 .TP
1650 .B RebuildFinished
1651 An md array that was rebuilding, isn't any more, either because it
1652 finished normally or was aborted. (syslog priority: Warning)
1653
1654 .TP
1655 .B Fail
1656 An active component device of an array has been marked as
1657 faulty. (syslog priority: Critical)
1658
1659 .TP
1660 .B FailSpare
1661 A spare component device which was being rebuilt to replace a faulty
1662 device has failed. (syslog priority: Critical)
1663
1664 .TP
1665 .B SpareActive
1666 A spare component device which was being rebuilt to replace a faulty
1667 device has been successfully rebuilt and has been made active.
1668 (syslog priority: Info)
1669
1670 .TP
1671 .B NewArray
1672 A new md array has been detected in the
1673 .B /proc/mdstat
1674 file. (syslog priority: Info)
1675
1676 .TP
1677 .B DegradedArray
1678 A newly noticed array appears to be degraded. This message is not
1679 generated when
1680 .I mdadm
1681 notices a drive failure which causes degradation, but only when
1682 .I mdadm
1683 notices that an array is degraded when it first sees the array.
1684 (syslog priority: Critical)
1685
1686 .TP
1687 .B MoveSpare
1688 A spare drive has been moved from one array in a
1689 .B spare-group
1690 to another to allow a failed drive to be replaced.
1691 (syslog priority: Info)
1692
1693 .TP
1694 .B SparesMissing
1695 If
1696 .I mdadm
1697 has been told, via the config file, that an array should have a certain
1698 number of spare devices, and
1699 .I mdadm
1700 detects that it has fewer than this number when it first sees the
1701 array, it will report a
1702 .B SparesMissing
1703 message.
1704 (syslog priority: Warning)
1705
1706 .TP
1707 .B TestMessage
1708 An array was found at startup, and the
1709 .B \-\-test
1710 flag was given.
1711 (syslog priority: Info)
1712 .RE
1713
1714 Only
1715 .B Fail,
1716 .B FailSpare,
1717 .B DegradedArray,
1718 .B SparesMissing
1719 and
1720 .B TestMessage
1721 cause Email to be sent. All events cause the program to be run.
1722 The program is run with two or three arguments: the event
1723 name, the array device and possibly a second device.
1724
1725 Each event has an associated array device (e.g.
1726 .BR /dev/md1 )
1727 and possibly a second device. For
1728 .BR Fail ,
1729 .BR FailSpare ,
1730 and
1731 .B SpareActive
1732 the second device is the relevant component device.
1733 For
1734 .B MoveSpare
1735 the second device is the array that the spare was moved from.
1736
1737 For
1738 .I mdadm
1739 to move spares from one array to another, the different arrays need to
1740 be labeled with the same
1741 .B spare-group
1742 in the configuration file. The
1743 .B spare-group
1744 name can be any string; it is only necessary that different spare
1745 groups use different names.
1746
1747 When
1748 .I mdadm
1749 detects that an array in a spare group has fewer active
1750 devices than necessary for the complete array, and has no spare
1751 devices, it will look for another array in the same spare group that
1752 has a full complement of working drive and a spare. It will then
1753 attempt to remove the spare from the second drive and add it to the
1754 first.
1755 If the removal succeeds but the adding fails, then it is added back to
1756 the original array.
1757
1758 .SH GROW MODE
1759 The GROW mode is used for changing the size or shape of an active
1760 array.
1761 For this to work, the kernel must support the necessary change.
1762 Various types of growth are being added during 2.6 development,
1763 including restructuring a raid5 array to have more active devices.
1764
1765 Currently the only support available is to
1766 .IP \(bu 4
1767 change the "size" attribute
1768 for RAID1, RAID5 and RAID6.
1769 .IP \(bu 4
1770 increase the "raid\-devices" attribute of RAID1, RAID5, and RAID6.
1771 .IP \(bu 4
1772 add a write-intent bitmap to any array which supports these bitmaps, or
1773 remove a write-intent bitmap from such an array.
1774 .PP
1775
1776 .SS SIZE CHANGES
1777 Normally when an array is built the "size" it taken from the smallest
1778 of the drives. If all the small drives in an arrays are, one at a
1779 time, removed and replaced with larger drives, then you could have an
1780 array of large drives with only a small amount used. In this
1781 situation, changing the "size" with "GROW" mode will allow the extra
1782 space to start being used. If the size is increased in this way, a
1783 "resync" process will start to make sure the new parts of the array
1784 are synchronised.
1785
1786 Note that when an array changes size, any filesystem that may be
1787 stored in the array will not automatically grow to use the space. The
1788 filesystem will need to be explicitly told to use the extra space.
1789
1790 .SS RAID-DEVICES CHANGES
1791
1792 A RAID1 array can work with any number of devices from 1 upwards
1793 (though 1 is not very useful). There may be times which you want to
1794 increase or decrease the number of active devices. Note that this is
1795 different to hot-add or hot-remove which changes the number of
1796 inactive devices.
1797
1798 When reducing the number of devices in a RAID1 array, the slots which
1799 are to be removed from the array must already be vacant. That is, the
1800 devices which were in those slots must be failed and removed.
1801
1802 When the number of devices is increased, any hot spares that are
1803 present will be activated immediately.
1804
1805 Increasing the number of active devices in a RAID5 is much more
1806 effort. Every block in the array will need to be read and written
1807 back to a new location. From 2.6.17, the Linux Kernel is able to do
1808 this safely, including restart and interrupted "reshape".
1809
1810 When relocating the first few stripes on a raid5, it is not possible
1811 to keep the data on disk completely consistent and crash-proof. To
1812 provide the required safety, mdadm disables writes to the array while
1813 this "critical section" is reshaped, and takes a backup of the data
1814 that is in that section. This backup is normally stored in any spare
1815 devices that the array has, however it can also be stored in a
1816 separate file specified with the
1817 .B \-\-backup\-file
1818 option. If this option is used, and the system does crash during the
1819 critical period, the same file must be passed to
1820 .B \-\-assemble
1821 to restore the backup and reassemble the array.
1822
1823 .SS BITMAP CHANGES
1824
1825 A write-intent bitmap can be added to, or removed from, an active
1826 array. Either internal bitmaps, or bitmaps stored in a separate file,
1827 can be added. Note that if you add a bitmap stored in a file which is
1828 in a filesystem that is on the raid array being affected, the system
1829 will deadlock. The bitmap must be on a separate filesystem.
1830
1831 .SH INCREMENTAL MODE
1832
1833 .HP 12
1834 Usage:
1835 .B mdadm \-\-incremental
1836 .RB [ \-\-run ]
1837 .RB [ \-\-quiet ]
1838 .I component-device
1839 .HP 12
1840 Usage:
1841 .B mdadm \-\-incremental \-\-rebuild
1842 .HP 12
1843 Usage:
1844 .B mdadm \-\-incremental \-\-run \-\-scan
1845
1846
1847 .PP
1848 This mode is designed to be used in conjunction with a device
1849 discovery system. As devices are found in a system, they can be
1850 passed to
1851 .B "mdadm \-\-incremental"
1852 to be conditionally added to an appropriate array.
1853
1854 .I mdadm
1855 performs a number of tests to determine if the device is part of an
1856 array, and which array it should be part of. If an appropriate array
1857 is found, or can be created,
1858 .I mdadm
1859 adds the device to the array and conditionally starts the array.
1860
1861 Note that
1862 .I mdadm
1863 will only add devices to an array which were previously working
1864 (active or spare) parts of that array. It does not currently support
1865 automatic inclusion of a new drive as a spare in some array.
1866
1867 .B "mdadm \-\-incremental"
1868 requires a bug-fix in all kernels through 2.6.19.
1869 Hopefully, this will be fixed in 2.6.20; alternately, apply the patch
1870 which is included with the mdadm source distribution. If
1871 .I mdadm
1872 detects that this bug is present, it will abort any attempt to use
1873 .BR \-\-incremental .
1874
1875 The tests that
1876 .I mdadm
1877 makes are as follow:
1878 .IP +
1879 Is the device permitted by
1880 .BR mdadm.conf ?
1881 That is, is it listed in a
1882 .B DEVICES
1883 line in that file. If
1884 .B DEVICES
1885 is absent then the default it to allow any device. Similar if
1886 .B DEVICES
1887 contains the special word
1888 .B partitions
1889 then any device is allowed. Otherwise the device name given to
1890 .I mdadm
1891 must match one of the names or patterns in a
1892 .B DEVICES
1893 line.
1894
1895 .IP +
1896 Does the device have a valid md superblock. If a specific metadata
1897 version is request with
1898 .B \-\-metadata
1899 or
1900 .B \-e
1901 then only that style of metadata is accepted, otherwise
1902 .I mdadm
1903 finds any known version of metadata. If no
1904 .I md
1905 metadata is found, the device is rejected.
1906
1907 .IP +
1908 Does the metadata match an expected array?
1909 The metadata can match in two ways. Either there is an array listed
1910 in
1911 .B mdadm.conf
1912 which identifies the array (either by UUID, by name, by device list,
1913 or by minor-number), or the array was created with a
1914 .B homehost
1915 specified and that
1916 .B homehost
1917 matches the one in
1918 .B mdadm.conf
1919 or on the command line.
1920 If
1921 .I mdadm
1922 is not able to positively identify the array as belonging to the
1923 current host, the device will be rejected.
1924
1925 .IP +
1926 .I mdadm
1927 keeps a list of arrays that it has partially assembled in
1928 .B /var/run/mdadm/map
1929 (or
1930 .B /var/run/mdadm.map
1931 if the directory doesn't exist). If no array exists which matches
1932 the metadata on the new device,
1933 .I mdadm
1934 must choose a device name and unit number. It does this based on any
1935 name given in
1936 .B mdadm.conf
1937 or any name information stored in the metadata. If this name
1938 suggests a unit number, that number will be used, otherwise a free
1939 unit number will be chosen. Normally
1940 .I mdadm
1941 will prefer to create a partitionable array, however if the
1942 .B CREATE
1943 line in
1944 .B mdadm.conf
1945 suggests that a non-partitionable array is preferred, that will be
1946 honoured.
1947
1948 .IP +
1949 Once an appropriate array is found or created and the device is added,
1950 .I mdadm
1951 must decide if the array is ready to be started. It will
1952 normally compare the number of available (non-spare) devices to the
1953 number of devices that the metadata suggests need to be active. If
1954 there are at least that many, the array will be started. This means
1955 that if any devices are missing the array will not be restarted.
1956
1957 As an alternative,
1958 .B \-\-run
1959 may be passed to
1960 .I mdadm
1961 in which case the array will be run as soon as there are enough
1962 devices present for the data to be accessible. For a raid1, that
1963 means one device will start the array. For a clean raid5, the array
1964 will be started as soon as all but one drive is present.
1965
1966 Note that neither of these approaches is really ideal. If it can
1967 be known that all device discovery has completed, then
1968 .br
1969 .B " mdadm \-IRs"
1970 .br
1971 can be run which will try to start all arrays that are being
1972 incrementally assembled. They are started in "read-auto" mode in
1973 which they are read-only until the first write request. This means
1974 that no metadata updates are made and no attempt at resync or recovery
1975 happens. Further devices that are found before the first write can
1976 still be added safely.
1977
1978
1979 .SH ENVIRONMENT
1980 This section describes environment variables that affect how mdadm
1981 operates.
1982
1983 .TP
1984 .B MDADM_NO_MDMON
1985 Setting this value to 1 will prevent mdadm from automatically launching
1986 mdmon. This variable is intended primarily for debugging mdadm/mdmon.
1987
1988 .SH EXAMPLES
1989
1990 .B " mdadm \-\-query /dev/name-of-device"
1991 .br
1992 This will find out if a given device is a raid array, or is part of
1993 one, and will provide brief information about the device.
1994
1995 .B " mdadm \-\-assemble \-\-scan"
1996 .br
1997 This will assemble and start all arrays listed in the standard config
1998 file. This command will typically go in a system startup file.
1999
2000 .B " mdadm \-\-stop \-\-scan"
2001 .br
2002 This will shut down all arrays that can be shut down (i.e. are not
2003 currently in use). This will typically go in a system shutdown script.
2004
2005 .B " mdadm \-\-follow \-\-scan \-\-delay=120"
2006 .br
2007 If (and only if) there is an Email address or program given in the
2008 standard config file, then
2009 monitor the status of all arrays listed in that file by
2010 polling them ever 2 minutes.
2011
2012 .B " mdadm \-\-create /dev/md0 \-\-level=1 \-\-raid\-devices=2 /dev/hd[ac]1"
2013 .br
2014 Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1.
2015
2016 .br
2017 .B " echo 'DEVICE /dev/hd*[0\-9] /dev/sd*[0\-9]' > mdadm.conf"
2018 .br
2019 .B " mdadm \-\-detail \-\-scan >> mdadm.conf"
2020 .br
2021 This will create a prototype config file that describes currently
2022 active arrays that are known to be made from partitions of IDE or SCSI drives.
2023 This file should be reviewed before being used as it may
2024 contain unwanted detail.
2025
2026 .B " echo 'DEVICE /dev/hd[a\-z] /dev/sd*[a\-z]' > mdadm.conf"
2027 .br
2028 .B " mdadm \-\-examine \-\-scan \-\-config=mdadm.conf >> mdadm.conf"
2029 .br
2030 This will find arrays which could be assembled from existing IDE and
2031 SCSI whole drives (not partitions), and store the information in the
2032 format of a config file.
2033 This file is very likely to contain unwanted detail, particularly
2034 the
2035 .B devices=
2036 entries. It should be reviewed and edited before being used as an
2037 actual config file.
2038
2039 .B " mdadm \-\-examine \-\-brief \-\-scan \-\-config=partitions"
2040 .br
2041 .B " mdadm \-Ebsc partitions"
2042 .br
2043 Create a list of devices by reading
2044 .BR /proc/partitions ,
2045 scan these for RAID superblocks, and printout a brief listing of all
2046 that were found.
2047
2048 .B " mdadm \-Ac partitions \-m 0 /dev/md0"
2049 .br
2050 Scan all partitions and devices listed in
2051 .BR /proc/partitions
2052 and assemble
2053 .B /dev/md0
2054 out of all such devices with a RAID superblock with a minor number of 0.
2055
2056 .B " mdadm \-\-monitor \-\-scan \-\-daemonise > /var/run/mdadm"
2057 .br
2058 If config file contains a mail address or alert program, run mdadm in
2059 the background in monitor mode monitoring all md devices. Also write
2060 pid of mdadm daemon to
2061 .BR /var/run/mdadm .
2062
2063 .B " mdadm \-Iq /dev/somedevice"
2064 .br
2065 Try to incorporate newly discovered device into some array as
2066 appropriate.
2067
2068 .B " mdadm \-\-incremental \-\-rebuild \-\-run \-\-scan"
2069 .br
2070 Rebuild the array map from any current arrays, and then start any that
2071 can be started.
2072
2073 .B " mdadm /dev/md4 --fail detached --remove detached"
2074 .br
2075 Any devices which are components of /dev/md4 will be marked as faulty
2076 and then remove from the array.
2077
2078 .B " mdadm \-\-create \-\-help"
2079 .br
2080 Provide help about the Create mode.
2081
2082 .B " mdadm \-\-config \-\-help"
2083 .br
2084 Provide help about the format of the config file.
2085
2086 .B " mdadm \-\-help"
2087 .br
2088 Provide general help.
2089
2090
2091 .SH FILES
2092
2093 .SS /proc/mdstat
2094
2095 If you're using the
2096 .B /proc
2097 filesystem,
2098 .B /proc/mdstat
2099 lists all active md devices with information about them.
2100 .I mdadm
2101 uses this to find arrays when
2102 .B \-\-scan
2103 is given in Misc mode, and to monitor array reconstruction
2104 on Monitor mode.
2105
2106
2107 .SS /etc/mdadm.conf
2108
2109 The config file lists which devices may be scanned to see if
2110 they contain MD super block, and gives identifying information
2111 (e.g. UUID) about known MD arrays. See
2112 .BR mdadm.conf (5)
2113 for more details.
2114
2115 .SS /var/run/mdadm/map
2116 When
2117 .B \-\-incremental
2118 mode is used, this file gets a list of arrays currently being created.
2119 If
2120 .B /var/run/mdadm
2121 does not exist as a directory, then
2122 .B /var/run/mdadm.map
2123 is used instead.
2124
2125 .SH DEVICE NAMES
2126
2127 While entries in the /dev directory can have any format you like,
2128 .I mdadm
2129 has an understanding of 'standard' formats which it uses to guide its
2130 behaviour when creating device files via the
2131 .B \-\-auto
2132 option.
2133
2134 The standard names for non-partitioned arrays (the only sort of md
2135 array available in 2.4 and earlier) are either of
2136 .IP
2137 /dev/mdNN
2138 .br
2139 /dev/md/NN
2140 .PP
2141 where NN is a number.
2142 The standard names for partitionable arrays (as available from 2.6
2143 onwards) are either of
2144 .IP
2145 /dev/md/dNN
2146 .br
2147 /dev/md_dNN
2148 .PP
2149 Partition numbers should be indicated by added "pMM" to these, thus "/dev/md/d1p2".
2150
2151 .SH NOTE
2152 .I mdadm
2153 was previously known as
2154 .IR mdctl .
2155 .P
2156 .I mdadm
2157 is completely separate from the
2158 .I raidtools
2159 package, and does not use the
2160 .I /etc/raidtab
2161 configuration file at all.
2162
2163 .SH SEE ALSO
2164 For further information on mdadm usage, MD and the various levels of
2165 RAID, see:
2166 .IP
2167 .B http://linux\-raid.osdl.org/
2168 .PP
2169 (based upon Jakob \(/Ostergaard's Software\-RAID.HOWTO)
2170 .\".PP
2171 .\"for new releases of the RAID driver check out:
2172 .\"
2173 .\".IP
2174 .\".UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
2175 .\"ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
2176 .\".UE
2177 .\".PP
2178 .\"or
2179 .\".IP
2180 .\".UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
2181 .\"http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
2182 .\".UE
2183 .PP
2184 The latest version of
2185 .I mdadm
2186 should always be available from
2187 .IP
2188 .B http://www.kernel.org/pub/linux/utils/raid/mdadm/
2189 .PP
2190 Related man pages:
2191 .PP
2192 .IR mdadm.conf (5),
2193 .IR md (4).
2194 .PP
2195 .IR raidtab (5),
2196 .IR raid0run (8),
2197 .IR raidstop (8),
2198 .IR mkraid (8).