]> git.ipfire.org Git - thirdparty/mdadm.git/blob - mdadm.8.in
Create: add error checking for 'write_init_super'.
[thirdparty/mdadm.git] / mdadm.8.in
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.2.1
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 New installations should not use md/multipath as it is not well
50 supported and has no ongoing development. Use the Device Mapper based
51 multipath-tools instead.
52
53 .B FAULTY
54 is also not true RAID, and it only involves one device. It
55 provides a layer over a true device that can be used to inject faults.
56
57 .B CONTAINER
58 is different again. A
59 .B CONTAINER
60 is a collection of devices that are
61 managed as a set. This is similar to the set of devices connected to
62 a hardware RAID controller. The set of devices may contain a number
63 of different RAID arrays each utilising some (or all) of the blocks from a
64 number of the devices in the set. For example, two devices in a 5-device set
65 might form a RAID1 using the whole devices. The remaining three might
66 have a RAID5 over the first half of each device, and a RAID0 over the
67 second half.
68
69 With a
70 .BR CONTAINER ,
71 there is one set of metadata that describes all of
72 the arrays in the container. So when
73 .I mdadm
74 creates a
75 .B CONTAINER
76 device, the device just represents the metadata. Other normal arrays (RAID1
77 etc) can be created inside the container.
78
79 .SH MODES
80 mdadm has several major modes of operation:
81 .TP
82 .B Assemble
83 Assemble the components of a previously created
84 array into an active array. Components can be explicitly given
85 or can be searched for.
86 .I mdadm
87 checks that the components
88 do form a bona fide array, and can, on request, fiddle superblock
89 information so as to assemble a faulty array.
90
91 .TP
92 .B Build
93 Build an array that doesn't have per-device metadata (superblocks). For these
94 sorts of arrays,
95 .I mdadm
96 cannot differentiate between initial creation and subsequent assembly
97 of an array. It also cannot perform any checks that appropriate
98 components have been requested. Because of this, the
99 .B Build
100 mode should only be used together with a complete understanding of
101 what you are doing.
102
103 .TP
104 .B Create
105 Create a new array with per-device metadata (superblocks).
106 Appropriate metadata is written to each device, and then the array
107 comprising those devices is activated. A 'resync' process is started
108 to make sure that the array is consistent (e.g. both sides of a mirror
109 contain the same data) but the content of the device is left otherwise
110 untouched.
111 The array can be used as soon as it has been created. There is no
112 need to wait for the initial resync to finish.
113
114 .TP
115 .B "Follow or Monitor"
116 Monitor one or more md devices and act on any state changes. This is
117 only meaningful for RAID1, 4, 5, 6, 10 or multipath arrays, as
118 only these have interesting state. RAID0 or Linear never have
119 missing, spare, or failed drives, so there is nothing to monitor.
120
121 .TP
122 .B "Grow"
123 Grow (or shrink) an array, or otherwise reshape it in some way.
124 Currently supported growth options including changing the active size
125 of component devices and changing the number of active devices in
126 Linear and RAID levels 0/1/4/5/6,
127 changing the RAID level between 0, 1, 5, and 6, and between 0 and 10,
128 changing the chunk size and layout for RAID 0,4,5,6, as well as adding or
129 removing a write-intent bitmap.
130
131 .TP
132 .B "Incremental Assembly"
133 Add a single device to an appropriate array. If the addition of the
134 device makes the array runnable, the array will be started.
135 This provides a convenient interface to a
136 .I hot-plug
137 system. As each device is detected,
138 .I mdadm
139 has a chance to include it in some array as appropriate.
140 Optionally, when the
141 .I \-\-fail
142 flag is passed in we will remove the device from any active array
143 instead of adding it.
144
145 If a
146 .B CONTAINER
147 is passed to
148 .I mdadm
149 in this mode, then any arrays within that container will be assembled
150 and started.
151
152 .TP
153 .B Manage
154 This is for doing things to specific components of an array such as
155 adding new spares and removing faulty devices.
156
157 .TP
158 .B Misc
159 This is an 'everything else' mode that supports operations on active
160 arrays, operations on component devices such as erasing old superblocks, and
161 information gathering operations.
162 .\"This mode allows operations on independent devices such as examine MD
163 .\"superblocks, erasing old superblocks and stopping active arrays.
164
165 .TP
166 .B Auto-detect
167 This mode does not act on a specific device or array, but rather it
168 requests the Linux Kernel to activate any auto-detected arrays.
169 .SH OPTIONS
170
171 .SH Options for selecting a mode are:
172
173 .TP
174 .BR \-A ", " \-\-assemble
175 Assemble a pre-existing array.
176
177 .TP
178 .BR \-B ", " \-\-build
179 Build a legacy array without superblocks.
180
181 .TP
182 .BR \-C ", " \-\-create
183 Create a new array.
184
185 .TP
186 .BR \-F ", " \-\-follow ", " \-\-monitor
187 Select
188 .B Monitor
189 mode.
190
191 .TP
192 .BR \-G ", " \-\-grow
193 Change the size or shape of an active array.
194
195 .TP
196 .BR \-I ", " \-\-incremental
197 Add/remove a single device to/from an appropriate array, and possibly start the array.
198
199 .TP
200 .B \-\-auto-detect
201 Request that the kernel starts any auto-detected arrays. This can only
202 work if
203 .I md
204 is compiled into the kernel \(em not if it is a module.
205 Arrays can be auto-detected by the kernel if all the components are in
206 primary MS-DOS partitions with partition type
207 .BR FD ,
208 and all use v0.90 metadata.
209 In-kernel autodetect is not recommended for new installations. Using
210 .I mdadm
211 to detect and assemble arrays \(em possibly in an
212 .I initrd
213 \(em is substantially more flexible and should be preferred.
214
215 .P
216 If a device is given before any options, or if the first option is
217 .BR \-\-add ,
218 .BR \-\-fail ,
219 or
220 .BR \-\-remove ,
221 then the MANAGE mode is assumed.
222 Anything other than these will cause the
223 .B Misc
224 mode to be assumed.
225
226 .SH Options that are not mode-specific are:
227
228 .TP
229 .BR \-h ", " \-\-help
230 Display general help message or, after one of the above options, a
231 mode-specific help message.
232
233 .TP
234 .B \-\-help\-options
235 Display more detailed help about command line parsing and some commonly
236 used options.
237
238 .TP
239 .BR \-V ", " \-\-version
240 Print version information for mdadm.
241
242 .TP
243 .BR \-v ", " \-\-verbose
244 Be more verbose about what is happening. This can be used twice to be
245 extra-verbose.
246 The extra verbosity currently only affects
247 .B \-\-detail \-\-scan
248 and
249 .BR "\-\-examine \-\-scan" .
250
251 .TP
252 .BR \-q ", " \-\-quiet
253 Avoid printing purely informative messages. With this,
254 .I mdadm
255 will be silent unless there is something really important to report.
256
257 .TP
258 .BR \-f ", " \-\-force
259 Be more forceful about certain operations. See the various modes for
260 the exact meaning of this option in different contexts.
261
262 .TP
263 .BR \-c ", " \-\-config=
264 Specify the config file. Default is to use
265 .BR /etc/mdadm.conf ,
266 or if that is missing then
267 .BR /etc/mdadm/mdadm.conf .
268 If the config file given is
269 .B "partitions"
270 then nothing will be read, but
271 .I mdadm
272 will act as though the config file contained exactly
273 .B "DEVICE partitions containers"
274 and will read
275 .B /proc/partitions
276 to find a list of devices to scan, and
277 .B /proc/mdstat
278 to find a list of containers to examine.
279 If the word
280 .B "none"
281 is given for the config file, then
282 .I mdadm
283 will act as though the config file were empty.
284
285 .TP
286 .BR \-s ", " \-\-scan
287 Scan config file or
288 .B /proc/mdstat
289 for missing information.
290 In general, this option gives
291 .I mdadm
292 permission to get any missing information (like component devices,
293 array devices, array identities, and alert destination) from the
294 configuration file (see previous option);
295 one exception is MISC mode when using
296 .B \-\-detail
297 or
298 .B \-\-stop,
299 in which case
300 .B \-\-scan
301 says to get a list of array devices from
302 .BR /proc/mdstat .
303
304 .TP
305 .BR \-e ", " \-\-metadata=
306 Declare the style of RAID metadata (superblock) to be used. The
307 default is {DEFAULT_METADATA} for
308 .BR \-\-create ,
309 and to guess for other operations.
310 The default can be overridden by setting the
311 .B metadata
312 value for the
313 .B CREATE
314 keyword in
315 .BR mdadm.conf .
316
317 Options are:
318 .RS
319 .ie '{DEFAULT_METADATA}'0.90'
320 .IP "0, 0.90, default"
321 .el
322 .IP "0, 0.90"
323 ..
324 Use the original 0.90 format superblock. This format limits arrays to
325 28 component devices and limits component devices of levels 1 and
326 greater to 2 terabytes. It is also possible for there to be confusion
327 about whether the superblock applies to a whole device or just the
328 last partition, if that partition starts on a 64K boundary.
329 .ie '{DEFAULT_METADATA}'0.90'
330 .IP "1, 1.0, 1.1, 1.2"
331 .el
332 .IP "1, 1.0, 1.1, 1.2 default"
333 ..
334 Use the new version-1 format superblock. This has fewer restrictions.
335 It can easily be moved between hosts with different endian-ness, and a
336 recovery operation can be checkpointed and restarted. The different
337 sub-versions store the superblock at different locations on the
338 device, either at the end (for 1.0), at the start (for 1.1) or 4K from
339 the start (for 1.2). "1" is equivalent to "1.0".
340 'if '{DEFAULT_METADATA}'1.2' "default" is equivalent to "1.2".
341 .IP ddf
342 Use the "Industry Standard" DDF (Disk Data Format) format defined by
343 SNIA.
344 When creating a DDF array a
345 .B CONTAINER
346 will be created, and normal arrays can be created in that container.
347 .IP imsm
348 Use the Intel(R) Matrix Storage Manager metadata format. This creates a
349 .B CONTAINER
350 which is managed in a similar manner to DDF, and is supported by an
351 option-rom on some platforms:
352 .IP
353 .B http://www.intel.com/design/chipsets/matrixstorage_sb.htm
354 .PP
355 .RE
356
357 .TP
358 .B \-\-homehost=
359 This will override any
360 .B HOMEHOST
361 setting in the config file and provides the identity of the host which
362 should be considered the home for any arrays.
363
364 When creating an array, the
365 .B homehost
366 will be recorded in the metadata. For version-1 superblocks, it will
367 be prefixed to the array name. For version-0.90 superblocks, part of
368 the SHA1 hash of the hostname will be stored in the later half of the
369 UUID.
370
371 When reporting information about an array, any array which is tagged
372 for the given homehost will be reported as such.
373
374 When using Auto-Assemble, only arrays tagged for the given homehost
375 will be allowed to use 'local' names (i.e. not ending in '_' followed
376 by a digit string). See below under
377 .BR "Auto Assembly" .
378
379 .SH For create, build, or grow:
380
381 .TP
382 .BR \-n ", " \-\-raid\-devices=
383 Specify the number of active devices in the array. This, plus the
384 number of spare devices (see below) must equal the number of
385 .I component-devices
386 (including "\fBmissing\fP" devices)
387 that are listed on the command line for
388 .BR \-\-create .
389 Setting a value of 1 is probably
390 a mistake and so requires that
391 .B \-\-force
392 be specified first. A value of 1 will then be allowed for linear,
393 multipath, RAID0 and RAID1. It is never allowed for RAID4, RAID5 or RAID6.
394 .br
395 This number can only be changed using
396 .B \-\-grow
397 for RAID1, RAID4, RAID5 and RAID6 arrays, and only on kernels which provide
398 the necessary support.
399
400 .TP
401 .BR \-x ", " \-\-spare\-devices=
402 Specify the number of spare (eXtra) devices in the initial array.
403 Spares can also be added
404 and removed later. The number of component devices listed
405 on the command line must equal the number of RAID devices plus the
406 number of spare devices.
407
408 .TP
409 .BR \-z ", " \-\-size=
410 Amount (in Kibibytes) of space to use from each drive in RAID levels 1/4/5/6.
411 This must be a multiple of the chunk size, and must leave about 128Kb
412 of space at the end of the drive for the RAID superblock.
413 If this is not specified
414 (as it normally is not) the smallest drive (or partition) sets the
415 size, though if there is a variance among the drives of greater than 1%, a warning is
416 issued.
417
418 A suffix of 'M' or 'G' can be given to indicate Megabytes or
419 Gigabytes respectively.
420
421 This value can be set with
422 .B \-\-grow
423 for RAID level 1/4/5/6. If the array was created with a size smaller
424 than the currently active drives, the extra space can be accessed
425 using
426 .BR \-\-grow .
427 The size can be given as
428 .B max
429 which means to choose the largest size that fits on all current drives.
430
431 Before reducing the size of the array (with
432 .BR "\-\-grow \-\-size=" )
433 you should make sure that space isn't needed. If the device holds a
434 filesystem, you would need to resize the filesystem to use less space.
435
436 After reducing the array size you should check that the data stored in
437 the device is still available. If the device holds a filesystem, then
438 an 'fsck' of the filesystem is a minimum requirement. If there are
439 problems the array can be made bigger again with no loss with another
440 .B "\-\-grow \-\-size="
441 command.
442
443 This value can not be used with
444 .B CONTAINER
445 metadata such as DDF and IMSM.
446
447 .TP
448 .BR \-Z ", " \-\-array\-size=
449 This is only meaningful with
450 .B \-\-grow
451 and its effect is not persistent: when the array is stopped and
452 restarted the default array size will be restored.
453
454 Setting the array-size causes the array to appear smaller to programs
455 that access the data. This is particularly needed before reshaping an
456 array so that it will be smaller. As the reshape is not reversible,
457 but setting the size with
458 .B \-\-array-size
459 is, it is required that the array size is reduced as appropriate
460 before the number of devices in the array is reduced.
461
462 Before reducing the size of the array you should make sure that space
463 isn't needed. If the device holds a filesystem, you would need to
464 resize the filesystem to use less space.
465
466 After reducing the array size you should check that the data stored in
467 the device is still available. If the device holds a filesystem, then
468 an 'fsck' of the filesystem is a minimum requirement. If there are
469 problems the array can be made bigger again with no loss with another
470 .B "\-\-grow \-\-array\-size="
471 command.
472
473 A suffix of 'M' or 'G' can be given to indicate Megabytes or
474 Gigabytes respectively.
475 A value of
476 .B max
477 restores the apparent size of the array to be whatever the real
478 amount of available space is.
479
480 .TP
481 .BR \-c ", " \-\-chunk=
482 Specify chunk size of kibibytes. The default when creating an
483 array is 512KB. To ensure compatibility with earlier versions, the
484 default when Building and array with no persistent metadata is 64KB.
485 This is only meaningful for RAID0, RAID4, RAID5, RAID6, and RAID10.
486
487 RAID4, RAID5, RAID6, and RAID10 require the chunk size to be a power
488 of 2. In any case it must be a multiple of 4KB.
489
490 A suffix of 'M' or 'G' can be given to indicate Megabytes or
491 Gigabytes respectively.
492
493 .TP
494 .BR \-\-rounding=
495 Specify rounding factor for a Linear array. The size of each
496 component will be rounded down to a multiple of this size.
497 This is a synonym for
498 .B \-\-chunk
499 but highlights the different meaning for Linear as compared to other
500 RAID levels. The default is 64K if a kernel earlier than 2.6.16 is in
501 use, and is 0K (i.e. no rounding) in later kernels.
502
503 .TP
504 .BR \-l ", " \-\-level=
505 Set RAID level. When used with
506 .BR \-\-create ,
507 options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4,
508 raid5, 5, raid6, 6, raid10, 10, multipath, mp, faulty, container.
509 Obviously some of these are synonymous.
510
511 When a
512 .B CONTAINER
513 metadata type is requested, only the
514 .B container
515 level is permitted, and it does not need to be explicitly given.
516
517 When used with
518 .BR \-\-build ,
519 only linear, stripe, raid0, 0, raid1, multipath, mp, and faulty are valid.
520
521 Can be used with
522 .B \-\-grow
523 to change the RAID level in some cases. See LEVEL CHANGES below.
524
525 .TP
526 .BR \-p ", " \-\-layout=
527 This option configures the fine details of data layout for RAID5, RAID6,
528 and RAID10 arrays, and controls the failure modes for
529 .IR faulty .
530
531 The layout of the RAID5 parity block can be one of
532 .BR left\-asymmetric ,
533 .BR left\-symmetric ,
534 .BR right\-asymmetric ,
535 .BR right\-symmetric ,
536 .BR la ", " ra ", " ls ", " rs .
537 The default is
538 .BR left\-symmetric .
539
540 It is also possible to cause RAID5 to use a RAID4-like layout by
541 choosing
542 .BR parity\-first ,
543 or
544 .BR parity\-last .
545
546 Finally for RAID5 there are DDF\-compatible layouts,
547 .BR ddf\-zero\-restart ,
548 .BR ddf\-N\-restart ,
549 and
550 .BR ddf\-N\-continue .
551
552 These same layouts are available for RAID6. There are also 4 layouts
553 that will provide an intermediate stage for converting between RAID5
554 and RAID6. These provide a layout which is identical to the
555 corresponding RAID5 layout on the first N\-1 devices, and has the 'Q'
556 syndrome (the second 'parity' block used by RAID6) on the last device.
557 These layouts are:
558 .BR left\-symmetric\-6 ,
559 .BR right\-symmetric\-6 ,
560 .BR left\-asymmetric\-6 ,
561 .BR right\-asymmetric\-6 ,
562 and
563 .BR parity\-first\-6 .
564
565 When setting the failure mode for level
566 .I faulty,
567 the options are:
568 .BR write\-transient ", " wt ,
569 .BR read\-transient ", " rt ,
570 .BR write\-persistent ", " wp ,
571 .BR read\-persistent ", " rp ,
572 .BR write\-all ,
573 .BR read\-fixable ", " rf ,
574 .BR clear ", " flush ", " none .
575
576 Each failure mode can be followed by a number, which is used as a period
577 between fault generation. Without a number, the fault is generated
578 once on the first relevant request. With a number, the fault will be
579 generated after that many requests, and will continue to be generated
580 every time the period elapses.
581
582 Multiple failure modes can be current simultaneously by using the
583 .B \-\-grow
584 option to set subsequent failure modes.
585
586 "clear" or "none" will remove any pending or periodic failure modes,
587 and "flush" will clear any persistent faults.
588
589 Finally, the layout options for RAID10 are one of 'n', 'o' or 'f' followed
590 by a small number. The default is 'n2'. The supported options are:
591
592 .I 'n'
593 signals 'near' copies. Multiple copies of one data block are at
594 similar offsets in different devices.
595
596 .I 'o'
597 signals 'offset' copies. Rather than the chunks being duplicated
598 within a stripe, whole stripes are duplicated but are rotated by one
599 device so duplicate blocks are on different devices. Thus subsequent
600 copies of a block are in the next drive, and are one chunk further
601 down.
602
603 .I 'f'
604 signals 'far' copies
605 (multiple copies have very different offsets).
606 See md(4) for more detail about 'near', 'offset', and 'far'.
607
608 The number is the number of copies of each datablock. 2 is normal, 3
609 can be useful. This number can be at most equal to the number of
610 devices in the array. It does not need to divide evenly into that
611 number (e.g. it is perfectly legal to have an 'n2' layout for an array
612 with an odd number of devices).
613
614 When an array is converted between RAID5 and RAID6 an intermediate
615 RAID6 layout is used in which the second parity block (Q) is always on
616 the last device. To convert a RAID5 to RAID6 and leave it in this new
617 layout (which does not require re-striping) use
618 .BR \-\-layout=preserve .
619 This will try to avoid any restriping.
620
621 The converse of this is
622 .B \-\-layout=normalise
623 which will change a non-standard RAID6 layout into a more standard
624 arrangement.
625
626 .TP
627 .BR \-\-parity=
628 same as
629 .B \-\-layout
630 (thus explaining the p of
631 .BR \-p ).
632
633 .TP
634 .BR \-b ", " \-\-bitmap=
635 Specify a file to store a write-intent bitmap in. The file should not
636 exist unless
637 .B \-\-force
638 is also given. The same file should be provided
639 when assembling the array. If the word
640 .B "internal"
641 is given, then the bitmap is stored with the metadata on the array,
642 and so is replicated on all devices. If the word
643 .B "none"
644 is given with
645 .B \-\-grow
646 mode, then any bitmap that is present is removed.
647
648 To help catch typing errors, the filename must contain at least one
649 slash ('/') if it is a real file (not 'internal' or 'none').
650
651 Note: external bitmaps are only known to work on ext2 and ext3.
652 Storing bitmap files on other filesystems may result in serious problems.
653
654 .TP
655 .BR \-\-bitmap\-chunk=
656 Set the chunksize of the bitmap. Each bit corresponds to that many
657 Kilobytes of storage.
658 When using a file based bitmap, the default is to use the smallest
659 size that is at-least 4 and requires no more than 2^21 chunks.
660 When using an
661 .B internal
662 bitmap, the chunksize defaults to 64Meg, or larger if necessary to
663 fit the bitmap into the available space.
664
665 A suffix of 'M' or 'G' can be given to indicate Megabytes or
666 Gigabytes respectively.
667
668 .TP
669 .BR \-W ", " \-\-write\-mostly
670 subsequent devices listed in a
671 .BR \-\-build ,
672 .BR \-\-create ,
673 or
674 .B \-\-add
675 command will be flagged as 'write-mostly'. This is valid for RAID1
676 only and means that the 'md' driver will avoid reading from these
677 devices if at all possible. This can be useful if mirroring over a
678 slow link.
679
680 .TP
681 .BR \-\-write\-behind=
682 Specify that write-behind mode should be enabled (valid for RAID1
683 only). If an argument is specified, it will set the maximum number
684 of outstanding writes allowed. The default value is 256.
685 A write-intent bitmap is required in order to use write-behind
686 mode, and write-behind is only attempted on drives marked as
687 .IR write-mostly .
688
689 .TP
690 .BR \-\-assume\-clean
691 Tell
692 .I mdadm
693 that the array pre-existed and is known to be clean. It can be useful
694 when trying to recover from a major failure as you can be sure that no
695 data will be affected unless you actually write to the array. It can
696 also be used when creating a RAID1 or RAID10 if you want to avoid the
697 initial resync, however this practice \(em while normally safe \(em is not
698 recommended. Use this only if you really know what you are doing.
699 .IP
700 When the devices that will be part of a new array were filled
701 with zeros before creation the operator knows the array is
702 actually clean. If that is the case, such as after running
703 badblocks, this argument can be used to tell mdadm the
704 facts the operator knows.
705
706 .TP
707 .BR \-\-backup\-file=
708 This is needed when
709 .B \-\-grow
710 is used to increase the number of raid-devices in a RAID5 or RAID6 if
711 there are no spare devices available, or to shrink, change RAID level
712 or layout. See the GROW MODE section below on RAID\-DEVICES CHANGES.
713 The file must be stored on a separate device, not on the RAID array
714 being reshaped.
715
716 .TP
717 .BR \-N ", " \-\-name=
718 Set a
719 .B name
720 for the array. This is currently only effective when creating an
721 array with a version-1 superblock, or an array in a DDF container.
722 The name is a simple textual string that can be used to identify array
723 components when assembling. If name is needed but not specified, it
724 is taken from the basename of the device that is being created.
725 e.g. when creating
726 .I /dev/md/home
727 the
728 .B name
729 will default to
730 .IR home .
731
732 .TP
733 .BR \-R ", " \-\-run
734 Insist that
735 .I mdadm
736 run the array, even if some of the components
737 appear to be active in another array or filesystem. Normally
738 .I mdadm
739 will ask for confirmation before including such components in an
740 array. This option causes that question to be suppressed.
741
742 .TP
743 .BR \-f ", " \-\-force
744 Insist that
745 .I mdadm
746 accept the geometry and layout specified without question. Normally
747 .I mdadm
748 will not allow creation of an array with only one device, and will try
749 to create a RAID5 array with one missing drive (as this makes the
750 initial resync work faster). With
751 .BR \-\-force ,
752 .I mdadm
753 will not try to be so clever.
754
755 .TP
756 .BR \-a ", " "\-\-auto{=yes,md,mdp,part,p}{NN}"
757 Instruct mdadm how to create the device file if needed, possibly allocating
758 an unused minor number. "md" causes a non-partitionable array
759 to be used (though since Linux 2.6.28, these array devices are in fact
760 partitionable). "mdp", "part" or "p" causes a partitionable array (2.6 and
761 later) to be used. "yes" requires the named md device to have
762 a 'standard' format, and the type and minor number will be determined
763 from this. With mdadm 3.0, device creation is normally left up to
764 .I udev
765 so this option is unlikely to be needed.
766 See DEVICE NAMES below.
767
768 The argument can also come immediately after
769 "\-a". e.g. "\-ap".
770
771 If
772 .B \-\-auto
773 is not given on the command line or in the config file, then
774 the default will be
775 .BR \-\-auto=yes .
776
777 If
778 .B \-\-scan
779 is also given, then any
780 .I auto=
781 entries in the config file will override the
782 .B \-\-auto
783 instruction given on the command line.
784
785 For partitionable arrays,
786 .I mdadm
787 will create the device file for the whole array and for the first 4
788 partitions. A different number of partitions can be specified at the
789 end of this option (e.g.
790 .BR \-\-auto=p7 ).
791 If the device name ends with a digit, the partition names add a 'p',
792 and a number, e.g.
793 .IR /dev/md/home1p3 .
794 If there is no trailing digit, then the partition names just have a
795 number added, e.g.
796 .IR /dev/md/scratch3 .
797
798 If the md device name is in a 'standard' format as described in DEVICE
799 NAMES, then it will be created, if necessary, with the appropriate
800 device number based on that name. If the device name is not in one of these
801 formats, then a unused device number will be allocated. The device
802 number will be considered unused if there is no active array for that
803 number, and there is no entry in /dev for that number and with a
804 non-standard name. Names that are not in 'standard' format are only
805 allowed in "/dev/md/".
806
807 .ig XX
808 .\".TP
809 .\".BR \-\-symlink = no
810 .\"Normally when
811 .\".B \-\-auto
812 .\"causes
813 .\".I mdadm
814 .\"to create devices in
815 .\".B /dev/md/
816 .\"it will also create symlinks from
817 .\".B /dev/
818 .\"with names starting with
819 .\".B md
820 .\"or
821 .\".BR md_ .
822 .\"Use
823 .\".B \-\-symlink=no
824 .\"to suppress this, or
825 .\".B \-\-symlink=yes
826 .\"to enforce this even if it is suppressing
827 .\".IR mdadm.conf .
828 .\"
829 .XX
830
831 .SH For assemble:
832
833 .TP
834 .BR \-u ", " \-\-uuid=
835 uuid of array to assemble. Devices which don't have this uuid are
836 excluded
837
838 .TP
839 .BR \-m ", " \-\-super\-minor=
840 Minor number of device that array was created for. Devices which
841 don't have this minor number are excluded. If you create an array as
842 /dev/md1, then all superblocks will contain the minor number 1, even if
843 the array is later assembled as /dev/md2.
844
845 Giving the literal word "dev" for
846 .B \-\-super\-minor
847 will cause
848 .I mdadm
849 to use the minor number of the md device that is being assembled.
850 e.g. when assembling
851 .BR /dev/md0 ,
852 .B \-\-super\-minor=dev
853 will look for super blocks with a minor number of 0.
854
855 .B \-\-super\-minor
856 is only relevant for v0.90 metadata, and should not normally be used.
857 Using
858 .B \-\-uuid
859 is much safer.
860
861 .TP
862 .BR \-N ", " \-\-name=
863 Specify the name of the array to assemble. This must be the name
864 that was specified when creating the array. It must either match
865 the name stored in the superblock exactly, or it must match
866 with the current
867 .I homehost
868 prefixed to the start of the given name.
869
870 .TP
871 .BR \-f ", " \-\-force
872 Assemble the array even if the metadata on some devices appears to be
873 out-of-date. If
874 .I mdadm
875 cannot find enough working devices to start the array, but can find
876 some devices that are recorded as having failed, then it will mark
877 those devices as working so that the array can be started.
878 An array which requires
879 .B \-\-force
880 to be started may contain data corruption. Use it carefully.
881
882 .TP
883 .BR \-R ", " \-\-run
884 Attempt to start the array even if fewer drives were given than were
885 present last time the array was active. Normally if not all the
886 expected drives are found and
887 .B \-\-scan
888 is not used, then the array will be assembled but not started.
889 With
890 .B \-\-run
891 an attempt will be made to start it anyway.
892
893 .TP
894 .B \-\-no\-degraded
895 This is the reverse of
896 .B \-\-run
897 in that it inhibits the startup of array unless all expected drives
898 are present. This is only needed with
899 .B \-\-scan,
900 and can be used if the physical connections to devices are
901 not as reliable as you would like.
902
903 .TP
904 .BR \-a ", " "\-\-auto{=no,yes,md,mdp,part}"
905 See this option under Create and Build options.
906
907 .TP
908 .BR \-a ", " "\-\-add"
909 This option can be used in Grow mode in two cases.
910
911 If the target array is a Linear array, then
912 .B \-\-add
913 can be used to add one or more devices to the array. They
914 are simply catenated on to the end of the array. Once added, the
915 devices cannot be removed.
916
917 If the
918 .B \-\-raid\-disks
919 option is being used to increase the number of devices in an array,
920 then
921 .B \-\-add
922 can be used to add some extra devices to be included in the array.
923 In most cases this is not needed as the extra devices can be added as
924 spares first, and then the number of raid-disks can be changed.
925 However for RAID0, it is not possible to add spares. So to increase
926 the number of devices in a RAID0, it is necessary to set the new
927 number of devices, and to add the new devices, in the same command.
928
929 .TP
930 .BR \-b ", " \-\-bitmap=
931 Specify the bitmap file that was given when the array was created. If
932 an array has an
933 .B internal
934 bitmap, there is no need to specify this when assembling the array.
935
936 .TP
937 .BR \-\-backup\-file=
938 If
939 .B \-\-backup\-file
940 was used while reshaping an array (e.g. changing number of devices or
941 chunk size) and the system crashed during the critical section, then the same
942 .B \-\-backup\-file
943 must be presented to
944 .B \-\-assemble
945 to allow possibly corrupted data to be restored, and the reshape
946 to be completed.
947
948 .TP
949 .BR \-\-invalid\-backup
950 If the file needed for the above option is not available for any
951 reason an empty file can be given together with this option to
952 indicate that the backup file is invalid. In this case the data that
953 was being rearranged at the time of the crash could be irrecoverably
954 lost, but the rest of the array may still be recoverable. This option
955 should only be used as a last resort if there is no way to recover the
956 backup file.
957
958
959 .TP
960 .BR \-U ", " \-\-update=
961 Update the superblock on each device while assembling the array. The
962 argument given to this flag can be one of
963 .BR sparc2.2 ,
964 .BR summaries ,
965 .BR uuid ,
966 .BR name ,
967 .BR homehost ,
968 .BR resync ,
969 .BR byteorder ,
970 .BR devicesize ,
971 .BR no\-bitmap ,
972 or
973 .BR super\-minor .
974
975 The
976 .B sparc2.2
977 option will adjust the superblock of an array what was created on a Sparc
978 machine running a patched 2.2 Linux kernel. This kernel got the
979 alignment of part of the superblock wrong. You can use the
980 .B "\-\-examine \-\-sparc2.2"
981 option to
982 .I mdadm
983 to see what effect this would have.
984
985 The
986 .B super\-minor
987 option will update the
988 .B "preferred minor"
989 field on each superblock to match the minor number of the array being
990 assembled.
991 This can be useful if
992 .B \-\-examine
993 reports a different "Preferred Minor" to
994 .BR \-\-detail .
995 In some cases this update will be performed automatically
996 by the kernel driver. In particular the update happens automatically
997 at the first write to an array with redundancy (RAID level 1 or
998 greater) on a 2.6 (or later) kernel.
999
1000 The
1001 .B uuid
1002 option will change the uuid of the array. If a UUID is given with the
1003 .B \-\-uuid
1004 option that UUID will be used as a new UUID and will
1005 .B NOT
1006 be used to help identify the devices in the array.
1007 If no
1008 .B \-\-uuid
1009 is given, a random UUID is chosen.
1010
1011 The
1012 .B name
1013 option will change the
1014 .I name
1015 of the array as stored in the superblock. This is only supported for
1016 version-1 superblocks.
1017
1018 The
1019 .B homehost
1020 option will change the
1021 .I homehost
1022 as recorded in the superblock. For version-0 superblocks, this is the
1023 same as updating the UUID.
1024 For version-1 superblocks, this involves updating the name.
1025
1026 The
1027 .B resync
1028 option will cause the array to be marked
1029 .I dirty
1030 meaning that any redundancy in the array (e.g. parity for RAID5,
1031 copies for RAID1) may be incorrect. This will cause the RAID system
1032 to perform a "resync" pass to make sure that all redundant information
1033 is correct.
1034
1035 The
1036 .B byteorder
1037 option allows arrays to be moved between machines with different
1038 byte-order.
1039 When assembling such an array for the first time after a move, giving
1040 .B "\-\-update=byteorder"
1041 will cause
1042 .I mdadm
1043 to expect superblocks to have their byteorder reversed, and will
1044 correct that order before assembling the array. This is only valid
1045 with original (Version 0.90) superblocks.
1046
1047 The
1048 .B summaries
1049 option will correct the summaries in the superblock. That is the
1050 counts of total, working, active, failed, and spare devices.
1051
1052 The
1053 .B devicesize
1054 option will rarely be of use. It applies to version 1.1 and 1.2 metadata
1055 only (where the metadata is at the start of the device) and is only
1056 useful when the component device has changed size (typically become
1057 larger). The version 1 metadata records the amount of the device that
1058 can be used to store data, so if a device in a version 1.1 or 1.2
1059 array becomes larger, the metadata will still be visible, but the
1060 extra space will not. In this case it might be useful to assemble the
1061 array with
1062 .BR \-\-update=devicesize .
1063 This will cause
1064 .I mdadm
1065 to determine the maximum usable amount of space on each device and
1066 update the relevant field in the metadata.
1067
1068 The
1069 .B no\-bitmap
1070 option can be used when an array has an internal bitmap which is
1071 corrupt in some way so that assembling the array normally fails. It
1072 will cause any internal bitmap to be ignored.
1073
1074 .SH For Manage mode:
1075
1076 .TP
1077 .BR \-t ", " \-\-test
1078 Unless a more serious error occurred,
1079 .I mdadm
1080 will exit with a status of 2 if no changes were made to the array and
1081 0 if at least one change was made.
1082 This can be useful when an indirect specifier such as
1083 .BR missing ,
1084 .B detached
1085 or
1086 .B faulty
1087 is used in requesting an operation on the array.
1088 .B \-\-test
1089 will report failure if these specifiers didn't find any match.
1090
1091 .TP
1092 .BR \-a ", " \-\-add
1093 hot-add listed devices.
1094 If a device appears to have recently been part of the array
1095 (possibly it failed or was removed) the device is re\-added as describe
1096 in the next point.
1097 If that fails or the device was never part of the array, the device is
1098 added as a hot-spare.
1099 If the array is degraded, it will immediately start to rebuild data
1100 onto that spare.
1101
1102 Note that this and the following options are only meaningful on array
1103 with redundancy. They don't apply to RAID0 or Linear.
1104
1105 .TP
1106 .BR \-\-re\-add
1107 re\-add a device that was previous removed from an array.
1108 If the metadata on the device reports that it is a member of the
1109 array, and the slot that it used is still vacant, then the device will
1110 be added back to the array in the same position. This will normally
1111 cause the data for that device to be recovered. However based on the
1112 event count on the device, the recovery may only require sections that
1113 are flagged a write-intent bitmap to be recovered or may not require
1114 any recovery at all.
1115
1116 When used on an array that has no metadata (i.e. it was built with
1117 .BR \-\-build)
1118 it will be assumed that bitmap-based recovery is enough to make the
1119 device fully consistent with the array.
1120
1121 When
1122 .B \-\-re\-add
1123 can be accompanied by
1124 .BR \-\-update=devicesize .
1125 See the description of this option when used in Assemble mode for an
1126 explanation of its use.
1127
1128 If the device name given is
1129 .B missing
1130 then mdadm will try to find any device that looks like it should be
1131 part of the array but isn't and will try to re\-add all such devices.
1132
1133 .TP
1134 .BR \-r ", " \-\-remove
1135 remove listed devices. They must not be active. i.e. they should
1136 be failed or spare devices. As well as the name of a device file
1137 (e.g.
1138 .BR /dev/sda1 )
1139 the words
1140 .B failed
1141 and
1142 .B detached
1143 can be given to
1144 .BR \-\-remove .
1145 The first causes all failed device to be removed. The second causes
1146 any device which is no longer connected to the system (i.e an 'open'
1147 returns
1148 .BR ENXIO )
1149 to be removed. This will only succeed for devices that are spares or
1150 have already been marked as failed.
1151
1152 .TP
1153 .BR \-f ", " \-\-fail
1154 mark listed devices as faulty.
1155 As well as the name of a device file, the word
1156 .B detached
1157 can be given. This will cause any device that has been detached from
1158 the system to be marked as failed. It can then be removed.
1159
1160 .TP
1161 .BR \-\-set\-faulty
1162 same as
1163 .BR \-\-fail .
1164
1165 .TP
1166 .BR \-\-write\-mostly
1167 Subsequent devices that are added or re\-added will have the 'write-mostly'
1168 flag set. This is only valid for RAID1 and means that the 'md' driver
1169 will avoid reading from these devices if possible.
1170 .TP
1171 .BR \-\-readwrite
1172 Subsequent devices that are added or re\-added will have the 'write-mostly'
1173 flag cleared.
1174
1175 .P
1176 Each of these options requires that the first device listed is the array
1177 to be acted upon, and the remainder are component devices to be added,
1178 removed, marked as faulty, etc. Several different operations can be
1179 specified for different devices, e.g.
1180 .in +5
1181 mdadm /dev/md0 \-\-add /dev/sda1 \-\-fail /dev/sdb1 \-\-remove /dev/sdb1
1182 .in -5
1183 Each operation applies to all devices listed until the next
1184 operation.
1185
1186 If an array is using a write-intent bitmap, then devices which have
1187 been removed can be re\-added in a way that avoids a full
1188 reconstruction but instead just updates the blocks that have changed
1189 since the device was removed. For arrays with persistent metadata
1190 (superblocks) this is done automatically. For arrays created with
1191 .B \-\-build
1192 mdadm needs to be told that this device we removed recently with
1193 .BR \-\-re\-add .
1194
1195 Devices can only be removed from an array if they are not in active
1196 use, i.e. that must be spares or failed devices. To remove an active
1197 device, it must first be marked as
1198 .B faulty.
1199
1200 .SH For Misc mode:
1201
1202 .TP
1203 .BR \-Q ", " \-\-query
1204 Examine a device to see
1205 (1) if it is an md device and (2) if it is a component of an md
1206 array.
1207 Information about what is discovered is presented.
1208
1209 .TP
1210 .BR \-D ", " \-\-detail
1211 Print details of one or more md devices.
1212
1213 .TP
1214 .BR \-\-detail\-platform
1215 Print details of the platform's RAID capabilities (firmware / hardware
1216 topology) for a given metadata format.
1217
1218 .TP
1219 .BR \-Y ", " \-\-export
1220 When used with
1221 .B \-\-detail
1222 or
1223 .BR \-\-examine ,
1224 output will be formatted as
1225 .B key=value
1226 pairs for easy import into the environment.
1227
1228 .TP
1229 .BR \-E ", " \-\-examine
1230 Print contents of the metadata stored on the named device(s).
1231 Note the contrast between
1232 .B \-\-examine
1233 and
1234 .BR \-\-detail .
1235 .B \-\-examine
1236 applies to devices which are components of an array, while
1237 .B \-\-detail
1238 applies to a whole array which is currently active.
1239 .TP
1240 .B \-\-sparc2.2
1241 If an array was created on a SPARC machine with a 2.2 Linux kernel
1242 patched with RAID support, the superblock will have been created
1243 incorrectly, or at least incompatibly with 2.4 and later kernels.
1244 Using the
1245 .B \-\-sparc2.2
1246 flag with
1247 .B \-\-examine
1248 will fix the superblock before displaying it. If this appears to do
1249 the right thing, then the array can be successfully assembled using
1250 .BR "\-\-assemble \-\-update=sparc2.2" .
1251
1252 .TP
1253 .BR \-X ", " \-\-examine\-bitmap
1254 Report information about a bitmap file.
1255 The argument is either an external bitmap file or an array component
1256 in case of an internal bitmap. Note that running this on an array
1257 device (e.g.
1258 .BR /dev/md0 )
1259 does not report the bitmap for that array.
1260
1261 .TP
1262 .BR \-R ", " \-\-run
1263 start a partially assembled array. If
1264 .B \-\-assemble
1265 did not find enough devices to fully start the array, it might leaving
1266 it partially assembled. If you wish, you can then use
1267 .B \-\-run
1268 to start the array in degraded mode.
1269
1270 .TP
1271 .BR \-S ", " \-\-stop
1272 deactivate array, releasing all resources.
1273
1274 .TP
1275 .BR \-o ", " \-\-readonly
1276 mark array as readonly.
1277
1278 .TP
1279 .BR \-w ", " \-\-readwrite
1280 mark array as readwrite.
1281
1282 .TP
1283 .B \-\-zero\-superblock
1284 If the device contains a valid md superblock, the block is
1285 overwritten with zeros. With
1286 .B \-\-force
1287 the block where the superblock would be is overwritten even if it
1288 doesn't appear to be valid.
1289
1290 .TP
1291 .B \-\-kill\-subarray=
1292 If the device is a container and the argument to \-\-kill\-subarray
1293 specifies an inactive subarray in the container, then the subarray is
1294 deleted. Deleting all subarrays will leave an 'empty-container' or
1295 spare superblock on the drives. See \-\-zero\-superblock for completely
1296 removing a superblock. Note that some formats depend on the subarray
1297 index for generating a UUID, this command will fail if it would change
1298 the UUID of an active subarray.
1299
1300 .TP
1301 .B \-\-update\-subarray=
1302 If the device is a container and the argument to \-\-update\-subarray
1303 specifies a subarray in the container, then attempt to update the given
1304 superblock field in the subarray. See below in
1305 .B MISC MODE
1306 for details.
1307
1308 .TP
1309 .BR \-t ", " \-\-test
1310 When used with
1311 .BR \-\-detail ,
1312 the exit status of
1313 .I mdadm
1314 is set to reflect the status of the device. See below in
1315 .B MISC MODE
1316 for details.
1317
1318 .TP
1319 .BR \-W ", " \-\-wait
1320 For each md device given, wait for any resync, recovery, or reshape
1321 activity to finish before returning.
1322 .I mdadm
1323 will return with success if it actually waited for every device
1324 listed, otherwise it will return failure.
1325
1326 .TP
1327 .BR \-\-wait\-clean
1328 For each md device given, or each device in /proc/mdstat if
1329 .B \-\-scan
1330 is given, arrange for the array to be marked clean as soon as possible.
1331 .I mdadm
1332 will return with success if the array uses external metadata and we
1333 successfully waited. For native arrays this returns immediately as the
1334 kernel handles dirty-clean transitions at shutdown. No action is taken
1335 if safe-mode handling is disabled.
1336
1337 .SH For Incremental Assembly mode:
1338 .TP
1339 .BR \-\-rebuild\-map ", " \-r
1340 Rebuild the map file
1341 .RB ( /var/run/mdadm/map )
1342 that
1343 .I mdadm
1344 uses to help track which arrays are currently being assembled.
1345
1346 .TP
1347 .BR \-\-run ", " \-R
1348 Run any array assembled as soon as a minimal number of devices are
1349 available, rather than waiting until all expected devices are present.
1350
1351 .TP
1352 .BR \-\-scan ", " \-s
1353 Only meaningful with
1354 .B \-R
1355 this will scan the
1356 .B map
1357 file for arrays that are being incrementally assembled and will try to
1358 start any that are not already started. If any such array is listed
1359 in
1360 .B mdadm.conf
1361 as requiring an external bitmap, that bitmap will be attached first.
1362
1363 .TP
1364 .BR \-\-fail ", " \-f
1365 This allows the hot-plug system to remove devices that have fully disappeared
1366 from the kernel. It will first fail and then remove the device from any
1367 array it belongs to.
1368 The device name given should be a kernel device name such as "sda",
1369 not a name in
1370 .IR /dev .
1371
1372 .TP
1373 .BR \-\-path=
1374 Only used with \-\-fail. The 'path' given will be recorded so that if
1375 a new device appears at the same location it can be automatically
1376 added to the same array. This allows the failed device to be
1377 automatically replaced by a new device without metadata if it appears
1378 at specified path. This option is normally only set by a
1379 .I udev
1380 script.
1381
1382 .SH For Monitor mode:
1383 .TP
1384 .BR \-m ", " \-\-mail
1385 Give a mail address to send alerts to.
1386
1387 .TP
1388 .BR \-p ", " \-\-program ", " \-\-alert
1389 Give a program to be run whenever an event is detected.
1390
1391 .TP
1392 .BR \-y ", " \-\-syslog
1393 Cause all events to be reported through 'syslog'. The messages have
1394 facility of 'daemon' and varying priorities.
1395
1396 .TP
1397 .BR \-d ", " \-\-delay
1398 Give a delay in seconds.
1399 .I mdadm
1400 polls the md arrays and then waits this many seconds before polling
1401 again. The default is 60 seconds. Since 2.6.16, there is no need to
1402 reduce this as the kernel alerts
1403 .I mdadm
1404 immediately when there is any change.
1405
1406 .TP
1407 .BR \-r ", " \-\-increment
1408 Give a percentage increment.
1409 .I mdadm
1410 will generate RebuildNN events with the given percentage increment.
1411
1412 .TP
1413 .BR \-f ", " \-\-daemonise
1414 Tell
1415 .I mdadm
1416 to run as a background daemon if it decides to monitor anything. This
1417 causes it to fork and run in the child, and to disconnect from the
1418 terminal. The process id of the child is written to stdout.
1419 This is useful with
1420 .B \-\-scan
1421 which will only continue monitoring if a mail address or alert program
1422 is found in the config file.
1423
1424 .TP
1425 .BR \-i ", " \-\-pid\-file
1426 When
1427 .I mdadm
1428 is running in daemon mode, write the pid of the daemon process to
1429 the specified file, instead of printing it on standard output.
1430
1431 .TP
1432 .BR \-1 ", " \-\-oneshot
1433 Check arrays only once. This will generate
1434 .B NewArray
1435 events and more significantly
1436 .B DegradedArray
1437 and
1438 .B SparesMissing
1439 events. Running
1440 .in +5
1441 .B " mdadm \-\-monitor \-\-scan \-1"
1442 .in -5
1443 from a cron script will ensure regular notification of any degraded arrays.
1444
1445 .TP
1446 .BR \-t ", " \-\-test
1447 Generate a
1448 .B TestMessage
1449 alert for every array found at startup. This alert gets mailed and
1450 passed to the alert program. This can be used for testing that alert
1451 message do get through successfully.
1452
1453 .TP
1454 .BR \-\-no\-sharing
1455 This inhibits the functionality for moving spares between arrays.
1456 Only one monitoring process started with
1457 .B \-\-scan
1458 but without this flag is allowed, otherwise the two could interfere
1459 with each other.
1460
1461 .SH ASSEMBLE MODE
1462
1463 .HP 12
1464 Usage:
1465 .B mdadm \-\-assemble
1466 .I md-device options-and-component-devices...
1467 .HP 12
1468 Usage:
1469 .B mdadm \-\-assemble \-\-scan
1470 .I md-devices-and-options...
1471 .HP 12
1472 Usage:
1473 .B mdadm \-\-assemble \-\-scan
1474 .I options...
1475
1476 .PP
1477 This usage assembles one or more RAID arrays from pre-existing components.
1478 For each array, mdadm needs to know the md device, the identity of the
1479 array, and a number of component-devices. These can be found in a number of ways.
1480
1481 In the first usage example (without the
1482 .BR \-\-scan )
1483 the first device given is the md device.
1484 In the second usage example, all devices listed are treated as md
1485 devices and assembly is attempted.
1486 In the third (where no devices are listed) all md devices that are
1487 listed in the configuration file are assembled. If not arrays are
1488 described by the configuration file, then any arrays that
1489 can be found on unused devices will be assembled.
1490
1491 If precisely one device is listed, but
1492 .B \-\-scan
1493 is not given, then
1494 .I mdadm
1495 acts as though
1496 .B \-\-scan
1497 was given and identity information is extracted from the configuration file.
1498
1499 The identity can be given with the
1500 .B \-\-uuid
1501 option, the
1502 .B \-\-name
1503 option, or the
1504 .B \-\-super\-minor
1505 option, will be taken from the md-device record in the config file, or
1506 will be taken from the super block of the first component-device
1507 listed on the command line.
1508
1509 Devices can be given on the
1510 .B \-\-assemble
1511 command line or in the config file. Only devices which have an md
1512 superblock which contains the right identity will be considered for
1513 any array.
1514
1515 The config file is only used if explicitly named with
1516 .B \-\-config
1517 or requested with (a possibly implicit)
1518 .BR \-\-scan .
1519 In the later case,
1520 .B /etc/mdadm.conf
1521 or
1522 .B /etc/mdadm/mdadm.conf
1523 is used.
1524
1525 If
1526 .B \-\-scan
1527 is not given, then the config file will only be used to find the
1528 identity of md arrays.
1529
1530 Normally the array will be started after it is assembled. However if
1531 .B \-\-scan
1532 is not given and not all expected drives were listed, then the array
1533 is not started (to guard against usage errors). To insist that the
1534 array be started in this case (as may work for RAID1, 4, 5, 6, or 10),
1535 give the
1536 .B \-\-run
1537 flag.
1538
1539 If
1540 .I udev
1541 is active,
1542 .I mdadm
1543 does not create any entries in
1544 .B /dev
1545 but leaves that to
1546 .IR udev .
1547 It does record information in
1548 .B /var/run/mdadm/map
1549 which will allow
1550 .I udev
1551 to choose the correct name.
1552
1553 If
1554 .I mdadm
1555 detects that udev is not configured, it will create the devices in
1556 .B /dev
1557 itself.
1558
1559 In Linux kernels prior to version 2.6.28 there were two distinctly
1560 different types of md devices that could be created: one that could be
1561 partitioned using standard partitioning tools and one that could not.
1562 Since 2.6.28 that distinction is no longer relevant as both type of
1563 devices can be partitioned.
1564 .I mdadm
1565 will normally create the type that originally could not be partitioned
1566 as it has a well defined major number (9).
1567
1568 Prior to 2.6.28, it is important that mdadm chooses the correct type
1569 of array device to use. This can be controlled with the
1570 .B \-\-auto
1571 option. In particular, a value of "mdp" or "part" or "p" tells mdadm
1572 to use a partitionable device rather than the default.
1573
1574 In the no-udev case, the value given to
1575 .B \-\-auto
1576 can be suffixed by a number. This tells
1577 .I mdadm
1578 to create that number of partition devices rather than the default of 4.
1579
1580 The value given to
1581 .B \-\-auto
1582 can also be given in the configuration file as a word starting
1583 .B auto=
1584 on the ARRAY line for the relevant array.
1585
1586 .SS Auto Assembly
1587 When
1588 .B \-\-assemble
1589 is used with
1590 .B \-\-scan
1591 and no devices are listed,
1592 .I mdadm
1593 will first attempt to assemble all the arrays listed in the config
1594 file.
1595
1596 In no array at listed in the config (other than those marked
1597 .BR <ignore> )
1598 it will look through the available devices for possible arrays and
1599 will try to assemble anything that it finds. Arrays which are tagged
1600 as belonging to the given homehost will be assembled and started
1601 normally. Arrays which do not obviously belong to this host are given
1602 names that are expected not to conflict with anything local, and are
1603 started "read-auto" so that nothing is written to any device until the
1604 array is written to. i.e. automatic resync etc is delayed.
1605
1606 If
1607 .I mdadm
1608 finds a consistent set of devices that look like they should comprise
1609 an array, and if the superblock is tagged as belonging to the given
1610 home host, it will automatically choose a device name and try to
1611 assemble the array. If the array uses version-0.90 metadata, then the
1612 .B minor
1613 number as recorded in the superblock is used to create a name in
1614 .B /dev/md/
1615 so for example
1616 .BR /dev/md/3 .
1617 If the array uses version-1 metadata, then the
1618 .B name
1619 from the superblock is used to similarly create a name in
1620 .B /dev/md/
1621 (the name will have any 'host' prefix stripped first).
1622
1623 This behaviour can be modified by the
1624 .I AUTO
1625 line in the
1626 .I mdadm.conf
1627 configuration file. This line can indicate that specific metadata
1628 type should, or should not, be automatically assembled. If an array
1629 is found which is not listed in
1630 .I mdadm.conf
1631 and has a metadata format that is denied by the
1632 .I AUTO
1633 line, then it will not be assembled.
1634 The
1635 .I AUTO
1636 line can also request that all arrays identified as being for this
1637 homehost should be assembled regardless of their metadata type.
1638 See
1639 .IR mdadm.conf (5)
1640 for further details.
1641
1642 Note: Auto assembly cannot be used for assembling and activating some
1643 arrays which are undergoing reshape. In particular as the
1644 .B backup\-file
1645 cannot be given, any reshape which requires a backup-file to continue
1646 cannot be started by auto assembly. An array which is growing to more
1647 devices and has passed the critical section can be assembled using
1648 auto-assembly.
1649
1650 .SH BUILD MODE
1651
1652 .HP 12
1653 Usage:
1654 .B mdadm \-\-build
1655 .I md-device
1656 .BI \-\-chunk= X
1657 .BI \-\-level= Y
1658 .BI \-\-raid\-devices= Z
1659 .I devices
1660
1661 .PP
1662 This usage is similar to
1663 .BR \-\-create .
1664 The difference is that it creates an array without a superblock. With
1665 these arrays there is no difference between initially creating the array and
1666 subsequently assembling the array, except that hopefully there is useful
1667 data there in the second case.
1668
1669 The level may raid0, linear, raid1, raid10, multipath, or faulty, or
1670 one of their synonyms. All devices must be listed and the array will
1671 be started once complete. It will often be appropriate to use
1672 .B \-\-assume\-clean
1673 with levels raid1 or raid10.
1674
1675 .SH CREATE MODE
1676
1677 .HP 12
1678 Usage:
1679 .B mdadm \-\-create
1680 .I md-device
1681 .BI \-\-chunk= X
1682 .BI \-\-level= Y
1683 .br
1684 .BI \-\-raid\-devices= Z
1685 .I devices
1686
1687 .PP
1688 This usage will initialise a new md array, associate some devices with
1689 it, and activate the array.
1690
1691 The named device will normally not exist when
1692 .I "mdadm \-\-create"
1693 is run, but will be created by
1694 .I udev
1695 once the array becomes active.
1696
1697 As devices are added, they are checked to see if they contain RAID
1698 superblocks or filesystems. They are also checked to see if the variance in
1699 device size exceeds 1%.
1700
1701 If any discrepancy is found, the array will not automatically be run, though
1702 the presence of a
1703 .B \-\-run
1704 can override this caution.
1705
1706 To create a "degraded" array in which some devices are missing, simply
1707 give the word "\fBmissing\fP"
1708 in place of a device name. This will cause
1709 .I mdadm
1710 to leave the corresponding slot in the array empty.
1711 For a RAID4 or RAID5 array at most one slot can be
1712 "\fBmissing\fP"; for a RAID6 array at most two slots.
1713 For a RAID1 array, only one real device needs to be given. All of the
1714 others can be
1715 "\fBmissing\fP".
1716
1717 When creating a RAID5 array,
1718 .I mdadm
1719 will automatically create a degraded array with an extra spare drive.
1720 This is because building the spare into a degraded array is in general
1721 faster than resyncing the parity on a non-degraded, but not clean,
1722 array. This feature can be overridden with the
1723 .B \-\-force
1724 option.
1725
1726 When creating an array with version-1 metadata a name for the array is
1727 required.
1728 If this is not given with the
1729 .B \-\-name
1730 option,
1731 .I mdadm
1732 will choose a name based on the last component of the name of the
1733 device being created. So if
1734 .B /dev/md3
1735 is being created, then the name
1736 .B 3
1737 will be chosen.
1738 If
1739 .B /dev/md/home
1740 is being created, then the name
1741 .B home
1742 will be used.
1743
1744 When creating a partition based array, using
1745 .I mdadm
1746 with version-1.x metadata, the partition type should be set to
1747 .B 0xDA
1748 (non fs-data). This type selection allows for greater precision since
1749 using any other [RAID auto-detect (0xFD) or a GNU/Linux partition (0x83)],
1750 might create problems in the event of array recovery through a live cdrom.
1751
1752 A new array will normally get a randomly assigned 128bit UUID which is
1753 very likely to be unique. If you have a specific need, you can choose
1754 a UUID for the array by giving the
1755 .B \-\-uuid=
1756 option. Be warned that creating two arrays with the same UUID is a
1757 recipe for disaster. Also, using
1758 .B \-\-uuid=
1759 when creating a v0.90 array will silently override any
1760 .B \-\-homehost=
1761 setting.
1762 .\"If the
1763 .\".B \-\-size
1764 .\"option is given, it is not necessary to list any component-devices in this command.
1765 .\"They can be added later, before a
1766 .\".B \-\-run.
1767 .\"If no
1768 .\".B \-\-size
1769 .\"is given, the apparent size of the smallest drive given is used.
1770
1771 When creating an array within a
1772 .B CONTAINER
1773 .I mdadm
1774 can be given either the list of devices to use, or simply the name of
1775 the container. The former case gives control over which devices in
1776 the container will be used for the array. The latter case allows
1777 .I mdadm
1778 to automatically choose which devices to use based on how much spare
1779 space is available.
1780
1781 The General Management options that are valid with
1782 .B \-\-create
1783 are:
1784 .TP
1785 .B \-\-run
1786 insist on running the array even if some devices look like they might
1787 be in use.
1788
1789 .TP
1790 .B \-\-readonly
1791 start the array readonly \(em not supported yet.
1792
1793 .SH MANAGE MODE
1794 .HP 12
1795 Usage:
1796 .B mdadm
1797 .I device
1798 .I options... devices...
1799 .PP
1800
1801 This usage will allow individual devices in an array to be failed,
1802 removed or added. It is possible to perform multiple operations with
1803 on command. For example:
1804 .br
1805 .B " mdadm /dev/md0 \-f /dev/hda1 \-r /dev/hda1 \-a /dev/hda1"
1806 .br
1807 will firstly mark
1808 .B /dev/hda1
1809 as faulty in
1810 .B /dev/md0
1811 and will then remove it from the array and finally add it back
1812 in as a spare. However only one md array can be affected by a single
1813 command.
1814
1815 When a device is added to an active array, mdadm checks to see if it
1816 has metadata on it which suggests that it was recently a member of the
1817 array. If it does, it tries to "re\-add" the device. If there have
1818 been no changes since the device was removed, or if the array has a
1819 write-intent bitmap which has recorded whatever changes there were,
1820 then the device will immediately become a full member of the array and
1821 those differences recorded in the bitmap will be resolved.
1822
1823 .SH MISC MODE
1824 .HP 12
1825 Usage:
1826 .B mdadm
1827 .I options ...
1828 .I devices ...
1829 .PP
1830
1831 MISC mode includes a number of distinct operations that
1832 operate on distinct devices. The operations are:
1833 .TP
1834 .B \-\-query
1835 The device is examined to see if it is
1836 (1) an active md array, or
1837 (2) a component of an md array.
1838 The information discovered is reported.
1839
1840 .TP
1841 .B \-\-detail
1842 The device should be an active md device.
1843 .B mdadm
1844 will display a detailed description of the array.
1845 .B \-\-brief
1846 or
1847 .B \-\-scan
1848 will cause the output to be less detailed and the format to be
1849 suitable for inclusion in
1850 .BR mdadm.conf .
1851 The exit status of
1852 .I mdadm
1853 will normally be 0 unless
1854 .I mdadm
1855 failed to get useful information about the device(s); however, if the
1856 .B \-\-test
1857 option is given, then the exit status will be:
1858 .RS
1859 .TP
1860 0
1861 The array is functioning normally.
1862 .TP
1863 1
1864 The array has at least one failed device.
1865 .TP
1866 2
1867 The array has multiple failed devices such that it is unusable.
1868 .TP
1869 4
1870 There was an error while trying to get information about the device.
1871 .RE
1872
1873 .TP
1874 .B \-\-detail\-platform
1875 Print detail of the platform's RAID capabilities (firmware / hardware
1876 topology). If the metadata is specified with
1877 .B \-e
1878 or
1879 .B \-\-metadata=
1880 then the return status will be:
1881 .RS
1882 .TP
1883 0
1884 metadata successfully enumerated its platform components on this system
1885 .TP
1886 1
1887 metadata is platform independent
1888 .TP
1889 2
1890 metadata failed to find its platform components on this system
1891 .RE
1892
1893 .TP
1894 .B \-\-update\-subarray=
1895 If the device is a container and the argument to \-\-update\-subarray
1896 specifies a subarray in the container, then attempt to update the given
1897 superblock field in the subarray. Similar to updating an array in
1898 "assemble" mode, the field to update is selected by
1899 .B \-U
1900 or
1901 .B \-\-update=
1902 option. Currently only
1903 .B name
1904 is supported.
1905
1906 The
1907 .B name
1908 option updates the subarray name in the metadata, it may not affect the
1909 device node name or the device node symlink until the subarray is
1910 re\-assembled. If updating
1911 .B name
1912 would change the UUID of an active subarray this operation is blocked,
1913 and the command will end in an error.
1914
1915 .TP
1916 .B \-\-examine
1917 The device should be a component of an md array.
1918 .I mdadm
1919 will read the md superblock of the device and display the contents.
1920 If
1921 .B \-\-brief
1922 or
1923 .B \-\-scan
1924 is given, then multiple devices that are components of the one array
1925 are grouped together and reported in a single entry suitable
1926 for inclusion in
1927 .BR mdadm.conf .
1928
1929 Having
1930 .B \-\-scan
1931 without listing any devices will cause all devices listed in the
1932 config file to be examined.
1933
1934 .TP
1935 .B \-\-stop
1936 The devices should be active md arrays which will be deactivated, as
1937 long as they are not currently in use.
1938
1939 .TP
1940 .B \-\-run
1941 This will fully activate a partially assembled md array.
1942
1943 .TP
1944 .B \-\-readonly
1945 This will mark an active array as read-only, providing that it is
1946 not currently being used.
1947
1948 .TP
1949 .B \-\-readwrite
1950 This will change a
1951 .B readonly
1952 array back to being read/write.
1953
1954 .TP
1955 .B \-\-scan
1956 For all operations except
1957 .BR \-\-examine ,
1958 .B \-\-scan
1959 will cause the operation to be applied to all arrays listed in
1960 .BR /proc/mdstat .
1961 For
1962 .BR \-\-examine,
1963 .B \-\-scan
1964 causes all devices listed in the config file to be examined.
1965
1966 .TP
1967 .BR \-b ", " \-\-brief
1968 Be less verbose. This is used with
1969 .B \-\-detail
1970 and
1971 .BR \-\-examine .
1972 Using
1973 .B \-\-brief
1974 with
1975 .B \-\-verbose
1976 gives an intermediate level of verbosity.
1977
1978 .SH MONITOR MODE
1979
1980 .HP 12
1981 Usage:
1982 .B mdadm \-\-monitor
1983 .I options... devices...
1984
1985 .PP
1986 This usage causes
1987 .I mdadm
1988 to periodically poll a number of md arrays and to report on any events
1989 noticed.
1990 .I mdadm
1991 will never exit once it decides that there are arrays to be checked,
1992 so it should normally be run in the background.
1993
1994 As well as reporting events,
1995 .I mdadm
1996 may move a spare drive from one array to another if they are in the
1997 same
1998 .B spare-group
1999 or
2000 .B domain
2001 and if the destination array has a failed drive but no spares.
2002
2003 If any devices are listed on the command line,
2004 .I mdadm
2005 will only monitor those devices. Otherwise all arrays listed in the
2006 configuration file will be monitored. Further, if
2007 .B \-\-scan
2008 is given, then any other md devices that appear in
2009 .B /proc/mdstat
2010 will also be monitored.
2011
2012 The result of monitoring the arrays is the generation of events.
2013 These events are passed to a separate program (if specified) and may
2014 be mailed to a given E-mail address.
2015
2016 When passing events to a program, the program is run once for each event,
2017 and is given 2 or 3 command-line arguments: the first is the
2018 name of the event (see below), the second is the name of the
2019 md device which is affected, and the third is the name of a related
2020 device if relevant (such as a component device that has failed).
2021
2022 If
2023 .B \-\-scan
2024 is given, then a program or an E-mail address must be specified on the
2025 command line or in the config file. If neither are available, then
2026 .I mdadm
2027 will not monitor anything.
2028 Without
2029 .B \-\-scan,
2030 .I mdadm
2031 will continue monitoring as long as something was found to monitor. If
2032 no program or email is given, then each event is reported to
2033 .BR stdout .
2034
2035 The different events are:
2036
2037 .RS 4
2038 .TP
2039 .B DeviceDisappeared
2040 An md array which previously was configured appears to no longer be
2041 configured. (syslog priority: Critical)
2042
2043 If
2044 .I mdadm
2045 was told to monitor an array which is RAID0 or Linear, then it will
2046 report
2047 .B DeviceDisappeared
2048 with the extra information
2049 .BR Wrong-Level .
2050 This is because RAID0 and Linear do not support the device-failed,
2051 hot-spare and resync operations which are monitored.
2052
2053 .TP
2054 .B RebuildStarted
2055 An md array started reconstruction. (syslog priority: Warning)
2056
2057 .TP
2058 .BI Rebuild NN
2059 Where
2060 .I NN
2061 is a two-digit number (ie. 05, 48). This indicates that rebuild
2062 has passed that many percent of the total. The events are generated
2063 with fixed increment since 0. Increment size may be specified with
2064 a commandline option (default is 20). (syslog priority: Warning)
2065
2066 .TP
2067 .B RebuildFinished
2068 An md array that was rebuilding, isn't any more, either because it
2069 finished normally or was aborted. (syslog priority: Warning)
2070
2071 .TP
2072 .B Fail
2073 An active component device of an array has been marked as
2074 faulty. (syslog priority: Critical)
2075
2076 .TP
2077 .B FailSpare
2078 A spare component device which was being rebuilt to replace a faulty
2079 device has failed. (syslog priority: Critical)
2080
2081 .TP
2082 .B SpareActive
2083 A spare component device which was being rebuilt to replace a faulty
2084 device has been successfully rebuilt and has been made active.
2085 (syslog priority: Info)
2086
2087 .TP
2088 .B NewArray
2089 A new md array has been detected in the
2090 .B /proc/mdstat
2091 file. (syslog priority: Info)
2092
2093 .TP
2094 .B DegradedArray
2095 A newly noticed array appears to be degraded. This message is not
2096 generated when
2097 .I mdadm
2098 notices a drive failure which causes degradation, but only when
2099 .I mdadm
2100 notices that an array is degraded when it first sees the array.
2101 (syslog priority: Critical)
2102
2103 .TP
2104 .B MoveSpare
2105 A spare drive has been moved from one array in a
2106 .B spare-group
2107 or
2108 .B domain
2109 to another to allow a failed drive to be replaced.
2110 (syslog priority: Info)
2111
2112 .TP
2113 .B SparesMissing
2114 If
2115 .I mdadm
2116 has been told, via the config file, that an array should have a certain
2117 number of spare devices, and
2118 .I mdadm
2119 detects that it has fewer than this number when it first sees the
2120 array, it will report a
2121 .B SparesMissing
2122 message.
2123 (syslog priority: Warning)
2124
2125 .TP
2126 .B TestMessage
2127 An array was found at startup, and the
2128 .B \-\-test
2129 flag was given.
2130 (syslog priority: Info)
2131 .RE
2132
2133 Only
2134 .B Fail,
2135 .B FailSpare,
2136 .B DegradedArray,
2137 .B SparesMissing
2138 and
2139 .B TestMessage
2140 cause Email to be sent. All events cause the program to be run.
2141 The program is run with two or three arguments: the event
2142 name, the array device and possibly a second device.
2143
2144 Each event has an associated array device (e.g.
2145 .BR /dev/md1 )
2146 and possibly a second device. For
2147 .BR Fail ,
2148 .BR FailSpare ,
2149 and
2150 .B SpareActive
2151 the second device is the relevant component device.
2152 For
2153 .B MoveSpare
2154 the second device is the array that the spare was moved from.
2155
2156 For
2157 .I mdadm
2158 to move spares from one array to another, the different arrays need to
2159 be labeled with the same
2160 .B spare-group
2161 or the spares must be allowed to migrate through matching POLICY domains
2162 in the configuration file. The
2163 .B spare-group
2164 name can be any string; it is only necessary that different spare
2165 groups use different names.
2166
2167 When
2168 .I mdadm
2169 detects that an array in a spare group has fewer active
2170 devices than necessary for the complete array, and has no spare
2171 devices, it will look for another array in the same spare group that
2172 has a full complement of working drive and a spare. It will then
2173 attempt to remove the spare from the second drive and add it to the
2174 first.
2175 If the removal succeeds but the adding fails, then it is added back to
2176 the original array.
2177
2178 If the spare group for a degraded array is not defined,
2179 .I mdadm
2180 will look at the rules of spare migration specified by POLICY lines in
2181 .B mdadm.conf
2182 and then follow similar steps as above if a matching spare is found.
2183
2184 .SH GROW MODE
2185 The GROW mode is used for changing the size or shape of an active
2186 array.
2187 For this to work, the kernel must support the necessary change.
2188 Various types of growth are being added during 2.6 development.
2189
2190 Currently the supported changes include
2191 .IP \(bu 4
2192 change the "size" attribute for RAID1, RAID4, RAID5 and RAID6.
2193 .IP \(bu 4
2194 increase or decrease the "raid\-devices" attribute of RAID0, RAID1, RAID4,
2195 RAID5, and RAID6.
2196 .IP \bu 4
2197 change the chunk-size and layout of RAID0, RAID4, RAID5 and RAID6.
2198 .IP \bu 4
2199 convert between RAID1 and RAID5, between RAID5 and RAID6, between
2200 RAID0, RAID5, and RAID5, and between RAID0 and RAID10 (in the near-2 mode).
2201 .IP \(bu 4
2202 add a write-intent bitmap to any array which supports these bitmaps, or
2203 remove a write-intent bitmap from such an array.
2204 .PP
2205
2206 Using GROW on containers is currently only support for Intel's IMSM
2207 container format. The number of devices in a container can be
2208 increased - which affects all arrays in the container - or an array
2209 in a container can be converted between levels where those levels are
2210 supported by the container, and the conversion is on of those listed
2211 above.
2212
2213 Grow functionality (e.g. expand a number of raid devices) for Intel's
2214 IMSM container format has an experimental status. It is guarded by the
2215 .B MDADM_EXPERIMENTAL
2216 environment variable which must be set to '1' for a GROW command to
2217 succeed.
2218 This is for the following reasons:
2219
2220 .IP 1.
2221 Intel's native IMSM check-pointing is not fully implemented yet.
2222 This causes IMSM incompatibility during the grow process: an array
2223 which is growing cannot roam between Microsoft Windows(R) and Linux
2224 systems.
2225
2226 .IP 2.
2227 Interrupting a grow operation is not recommended, because it
2228 has not been fully tested for Intel's IMSM container format yet.
2229
2230 .SS SIZE CHANGES
2231 Normally when an array is built the "size" is taken from the smallest
2232 of the drives. If all the small drives in an arrays are, one at a
2233 time, removed and replaced with larger drives, then you could have an
2234 array of large drives with only a small amount used. In this
2235 situation, changing the "size" with "GROW" mode will allow the extra
2236 space to start being used. If the size is increased in this way, a
2237 "resync" process will start to make sure the new parts of the array
2238 are synchronised.
2239
2240 Note that when an array changes size, any filesystem that may be
2241 stored in the array will not automatically grow for shrink to use or
2242 vacate the space. The
2243 filesystem will need to be explicitly told to use the extra space
2244 after growing, or to reduce its size
2245 .B prior
2246 to shrinking the array.
2247
2248 Also the size of an array cannot be changed while it has an active
2249 bitmap. If an array has a bitmap, it must be removed before the size
2250 can be changed. Once the change it complete a new bitmap can be created.
2251
2252 .SS RAID\-DEVICES CHANGES
2253
2254 A RAID1 array can work with any number of devices from 1 upwards
2255 (though 1 is not very useful). There may be times which you want to
2256 increase or decrease the number of active devices. Note that this is
2257 different to hot-add or hot-remove which changes the number of
2258 inactive devices.
2259
2260 When reducing the number of devices in a RAID1 array, the slots which
2261 are to be removed from the array must already be vacant. That is, the
2262 devices which were in those slots must be failed and removed.
2263
2264 When the number of devices is increased, any hot spares that are
2265 present will be activated immediately.
2266
2267 Changing the number of active devices in a RAID5 or RAID6 is much more
2268 effort. Every block in the array will need to be read and written
2269 back to a new location. From 2.6.17, the Linux Kernel is able to
2270 increase the number of devices in a RAID5 safely, including restarting
2271 an interrupted "reshape". From 2.6.31, the Linux Kernel is able to
2272 increase or decrease the number of devices in a RAID5 or RAID6.
2273
2274 From 2.6.35, the Linux Kernel is able to convert a RAID0 in to a RAID4
2275 or RAID5.
2276 .I mdadm
2277 uses this functionality and the ability to add
2278 devices to a RAID4 to allow devices to be added to a RAID0. When
2279 requested to do this,
2280 .I mdadm
2281 will convert the RAID0 to a RAID4, add the necessary disks and make
2282 the reshape happen, and then convert the RAID4 back to RAID0.
2283
2284 When decreasing the number of devices, the size of the array will also
2285 decrease. If there was data in the array, it could get destroyed and
2286 this is not reversible, so you should firstly shrink the filesystem on
2287 the array to fit within the new size. To help prevent accidents,
2288 .I mdadm
2289 requires that the size of the array be decreased first with
2290 .BR "mdadm --grow --array-size" .
2291 This is a reversible change which simply makes the end of the array
2292 inaccessible. The integrity of any data can then be checked before
2293 the non-reversible reduction in the number of devices is request.
2294
2295 When relocating the first few stripes on a RAID5 or RAID6, it is not
2296 possible to keep the data on disk completely consistent and
2297 crash-proof. To provide the required safety, mdadm disables writes to
2298 the array while this "critical section" is reshaped, and takes a
2299 backup of the data that is in that section. For grows, this backup may be
2300 stored in any spare devices that the array has, however it can also be
2301 stored in a separate file specified with the
2302 .B \-\-backup\-file
2303 option, and is required to be specified for shrinks, RAID level
2304 changes and layout changes. If this option is used, and the system
2305 does crash during the critical period, the same file must be passed to
2306 .B \-\-assemble
2307 to restore the backup and reassemble the array. When shrinking rather
2308 than growing the array, the reshape is done from the end towards the
2309 beginning, so the "critical section" is at the end of the reshape.
2310
2311 .SS LEVEL CHANGES
2312
2313 Changing the RAID level of any array happens instantaneously. However
2314 in the RAID5 to RAID6 case this requires a non-standard layout of the
2315 RAID6 data, and in the RAID6 to RAID5 case that non-standard layout is
2316 required before the change can be accomplished. So while the level
2317 change is instant, the accompanying layout change can take quite a
2318 long time. A
2319 .B \-\-backup\-file
2320 is required. If the array is not simultaneously being grown or
2321 shrunk, so that the array size will remain the same - for example,
2322 reshaping a 3-drive RAID5 into a 4-drive RAID6 - the backup file will
2323 be used not just for a "cricital section" but throughout the reshape
2324 operation, as described below under LAYOUT CHANGES.
2325
2326 .SS CHUNK-SIZE AND LAYOUT CHANGES
2327
2328 Changing the chunk-size of layout without also changing the number of
2329 devices as the same time will involve re-writing all blocks in-place.
2330 To ensure against data loss in the case of a crash, a
2331 .B --backup-file
2332 must be provided for these changes. Small sections of the array will
2333 be copied to the backup file while they are being rearranged. This
2334 means that all the data is copied twice, once to the backup and once
2335 to the new layout on the array, so this type of reshape will go very
2336 slowly.
2337
2338 If the reshape is interrupted for any reason, this backup file must be
2339 made available to
2340 .B "mdadm --assemble"
2341 so the array can be reassembled. Consequently the file cannot be
2342 stored on the device being reshaped.
2343
2344
2345 .SS BITMAP CHANGES
2346
2347 A write-intent bitmap can be added to, or removed from, an active
2348 array. Either internal bitmaps, or bitmaps stored in a separate file,
2349 can be added. Note that if you add a bitmap stored in a file which is
2350 in a filesystem that is on the RAID array being affected, the system
2351 will deadlock. The bitmap must be on a separate filesystem.
2352
2353 .SH INCREMENTAL MODE
2354
2355 .HP 12
2356 Usage:
2357 .B mdadm \-\-incremental
2358 .RB [ \-\-run ]
2359 .RB [ \-\-quiet ]
2360 .I component-device
2361 .HP 12
2362 Usage:
2363 .B mdadm \-\-incremental \-\-fail
2364 .I component-device
2365 .HP 12
2366 Usage:
2367 .B mdadm \-\-incremental \-\-rebuild\-map
2368 .HP 12
2369 Usage:
2370 .B mdadm \-\-incremental \-\-run \-\-scan
2371
2372 .PP
2373 This mode is designed to be used in conjunction with a device
2374 discovery system. As devices are found in a system, they can be
2375 passed to
2376 .B "mdadm \-\-incremental"
2377 to be conditionally added to an appropriate array.
2378
2379 Conversely, it can also be used with the
2380 .B \-\-fail
2381 flag to do just the opposite and find whatever array a particular device
2382 is part of and remove the device from that array.
2383
2384 If the device passed is a
2385 .B CONTAINER
2386 device created by a previous call to
2387 .IR mdadm ,
2388 then rather than trying to add that device to an array, all the arrays
2389 described by the metadata of the container will be started.
2390
2391 .I mdadm
2392 performs a number of tests to determine if the device is part of an
2393 array, and which array it should be part of. If an appropriate array
2394 is found, or can be created,
2395 .I mdadm
2396 adds the device to the array and conditionally starts the array.
2397
2398 Note that
2399 .I mdadm
2400 will normally only add devices to an array which were previously working
2401 (active or spare) parts of that array. The support for automatic
2402 inclusion of a new drive as a spare in some array requires
2403 a configuration through POLICY in config file.
2404
2405 The tests that
2406 .I mdadm
2407 makes are as follow:
2408 .IP +
2409 Is the device permitted by
2410 .BR mdadm.conf ?
2411 That is, is it listed in a
2412 .B DEVICES
2413 line in that file. If
2414 .B DEVICES
2415 is absent then the default it to allow any device. Similar if
2416 .B DEVICES
2417 contains the special word
2418 .B partitions
2419 then any device is allowed. Otherwise the device name given to
2420 .I mdadm
2421 must match one of the names or patterns in a
2422 .B DEVICES
2423 line.
2424
2425 .IP +
2426 Does the device have a valid md superblock. If a specific metadata
2427 version is request with
2428 .B \-\-metadata
2429 or
2430 .B \-e
2431 then only that style of metadata is accepted, otherwise
2432 .I mdadm
2433 finds any known version of metadata. If no
2434 .I md
2435 metadata is found, the device may be still added to an array
2436 as a spare if POLICY allows.
2437
2438 .ig
2439 .IP +
2440 Does the metadata match an expected array?
2441 The metadata can match in two ways. Either there is an array listed
2442 in
2443 .B mdadm.conf
2444 which identifies the array (either by UUID, by name, by device list,
2445 or by minor-number), or the array was created with a
2446 .B homehost
2447 specified and that
2448 .B homehost
2449 matches the one in
2450 .B mdadm.conf
2451 or on the command line.
2452 If
2453 .I mdadm
2454 is not able to positively identify the array as belonging to the
2455 current host, the device will be rejected.
2456 ..
2457
2458 .I mdadm
2459 keeps a list of arrays that it has partially assembled in
2460 .B /var/run/mdadm/map
2461 (or
2462 .B /var/run/mdadm.map
2463 if the directory doesn't exist. Or maybe even
2464 .BR /dev/.mdadm.map ).
2465 If no array exists which matches
2466 the metadata on the new device,
2467 .I mdadm
2468 must choose a device name and unit number. It does this based on any
2469 name given in
2470 .B mdadm.conf
2471 or any name information stored in the metadata. If this name
2472 suggests a unit number, that number will be used, otherwise a free
2473 unit number will be chosen. Normally
2474 .I mdadm
2475 will prefer to create a partitionable array, however if the
2476 .B CREATE
2477 line in
2478 .B mdadm.conf
2479 suggests that a non-partitionable array is preferred, that will be
2480 honoured.
2481
2482 If the array is not found in the config file and its metadata does not
2483 identify it as belonging to the "homehost", then
2484 .I mdadm
2485 will choose a name for the array which is certain not to conflict with
2486 any array which does belong to this host. It does this be adding an
2487 underscore and a small number to the name preferred by the metadata.
2488
2489 Once an appropriate array is found or created and the device is added,
2490 .I mdadm
2491 must decide if the array is ready to be started. It will
2492 normally compare the number of available (non-spare) devices to the
2493 number of devices that the metadata suggests need to be active. If
2494 there are at least that many, the array will be started. This means
2495 that if any devices are missing the array will not be restarted.
2496
2497 As an alternative,
2498 .B \-\-run
2499 may be passed to
2500 .I mdadm
2501 in which case the array will be run as soon as there are enough
2502 devices present for the data to be accessible. For a RAID1, that
2503 means one device will start the array. For a clean RAID5, the array
2504 will be started as soon as all but one drive is present.
2505
2506 Note that neither of these approaches is really ideal. If it can
2507 be known that all device discovery has completed, then
2508 .br
2509 .B " mdadm \-IRs"
2510 .br
2511 can be run which will try to start all arrays that are being
2512 incrementally assembled. They are started in "read-auto" mode in
2513 which they are read-only until the first write request. This means
2514 that no metadata updates are made and no attempt at resync or recovery
2515 happens. Further devices that are found before the first write can
2516 still be added safely.
2517
2518 .SH ENVIRONMENT
2519 This section describes environment variables that affect how mdadm
2520 operates.
2521
2522 .TP
2523 .B MDADM_NO_MDMON
2524 Setting this value to 1 will prevent mdadm from automatically launching
2525 mdmon. This variable is intended primarily for debugging mdadm/mdmon.
2526
2527 .TP
2528 .B MDADM_NO_UDEV
2529 Normally,
2530 .I mdadm
2531 does not create any device nodes in /dev, but leaves that task to
2532 .IR udev .
2533 If
2534 .I udev
2535 appears not to be configured, or if this environment variable is set
2536 to '1', the
2537 .I mdadm
2538 will create and devices that are needed.
2539
2540 .SH EXAMPLES
2541
2542 .B " mdadm \-\-query /dev/name-of-device"
2543 .br
2544 This will find out if a given device is a RAID array, or is part of
2545 one, and will provide brief information about the device.
2546
2547 .B " mdadm \-\-assemble \-\-scan"
2548 .br
2549 This will assemble and start all arrays listed in the standard config
2550 file. This command will typically go in a system startup file.
2551
2552 .B " mdadm \-\-stop \-\-scan"
2553 .br
2554 This will shut down all arrays that can be shut down (i.e. are not
2555 currently in use). This will typically go in a system shutdown script.
2556
2557 .B " mdadm \-\-follow \-\-scan \-\-delay=120"
2558 .br
2559 If (and only if) there is an Email address or program given in the
2560 standard config file, then
2561 monitor the status of all arrays listed in that file by
2562 polling them ever 2 minutes.
2563
2564 .B " mdadm \-\-create /dev/md0 \-\-level=1 \-\-raid\-devices=2 /dev/hd[ac]1"
2565 .br
2566 Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1.
2567
2568 .br
2569 .B " echo 'DEVICE /dev/hd*[0\-9] /dev/sd*[0\-9]' > mdadm.conf"
2570 .br
2571 .B " mdadm \-\-detail \-\-scan >> mdadm.conf"
2572 .br
2573 This will create a prototype config file that describes currently
2574 active arrays that are known to be made from partitions of IDE or SCSI drives.
2575 This file should be reviewed before being used as it may
2576 contain unwanted detail.
2577
2578 .B " echo 'DEVICE /dev/hd[a\-z] /dev/sd*[a\-z]' > mdadm.conf"
2579 .br
2580 .B " mdadm \-\-examine \-\-scan \-\-config=mdadm.conf >> mdadm.conf"
2581 .br
2582 This will find arrays which could be assembled from existing IDE and
2583 SCSI whole drives (not partitions), and store the information in the
2584 format of a config file.
2585 This file is very likely to contain unwanted detail, particularly
2586 the
2587 .B devices=
2588 entries. It should be reviewed and edited before being used as an
2589 actual config file.
2590
2591 .B " mdadm \-\-examine \-\-brief \-\-scan \-\-config=partitions"
2592 .br
2593 .B " mdadm \-Ebsc partitions"
2594 .br
2595 Create a list of devices by reading
2596 .BR /proc/partitions ,
2597 scan these for RAID superblocks, and printout a brief listing of all
2598 that were found.
2599
2600 .B " mdadm \-Ac partitions \-m 0 /dev/md0"
2601 .br
2602 Scan all partitions and devices listed in
2603 .BR /proc/partitions
2604 and assemble
2605 .B /dev/md0
2606 out of all such devices with a RAID superblock with a minor number of 0.
2607
2608 .B " mdadm \-\-monitor \-\-scan \-\-daemonise > /var/run/mdadm"
2609 .br
2610 If config file contains a mail address or alert program, run mdadm in
2611 the background in monitor mode monitoring all md devices. Also write
2612 pid of mdadm daemon to
2613 .BR /var/run/mdadm .
2614
2615 .B " mdadm \-Iq /dev/somedevice"
2616 .br
2617 Try to incorporate newly discovered device into some array as
2618 appropriate.
2619
2620 .B " mdadm \-\-incremental \-\-rebuild\-map \-\-run \-\-scan"
2621 .br
2622 Rebuild the array map from any current arrays, and then start any that
2623 can be started.
2624
2625 .B " mdadm /dev/md4 --fail detached --remove detached"
2626 .br
2627 Any devices which are components of /dev/md4 will be marked as faulty
2628 and then remove from the array.
2629
2630 .B " mdadm --grow /dev/md4 --level=6 --backup-file=/root/backup-md4
2631 .br
2632 The array
2633 .B /dev/md4
2634 which is currently a RAID5 array will be converted to RAID6. There
2635 should normally already be a spare drive attached to the array as a
2636 RAID6 needs one more drive than a matching RAID5.
2637
2638 .B " mdadm --create /dev/md/ddf --metadata=ddf --raid-disks 6 /dev/sd[a-f]"
2639 .br
2640 Create a DDF array over 6 devices.
2641
2642 .B " mdadm --create /dev/md/home -n3 -l5 -z 30000000 /dev/md/ddf"
2643 .br
2644 Create a RAID5 array over any 3 devices in the given DDF set. Use
2645 only 30 gigabytes of each device.
2646
2647 .B " mdadm -A /dev/md/ddf1 /dev/sd[a-f]"
2648 .br
2649 Assemble a pre-exist ddf array.
2650
2651 .B " mdadm -I /dev/md/ddf1"
2652 .br
2653 Assemble all arrays contained in the ddf array, assigning names as
2654 appropriate.
2655
2656 .B " mdadm \-\-create \-\-help"
2657 .br
2658 Provide help about the Create mode.
2659
2660 .B " mdadm \-\-config \-\-help"
2661 .br
2662 Provide help about the format of the config file.
2663
2664 .B " mdadm \-\-help"
2665 .br
2666 Provide general help.
2667
2668 .SH FILES
2669
2670 .SS /proc/mdstat
2671
2672 If you're using the
2673 .B /proc
2674 filesystem,
2675 .B /proc/mdstat
2676 lists all active md devices with information about them.
2677 .I mdadm
2678 uses this to find arrays when
2679 .B \-\-scan
2680 is given in Misc mode, and to monitor array reconstruction
2681 on Monitor mode.
2682
2683 .SS /etc/mdadm.conf
2684
2685 The config file lists which devices may be scanned to see if
2686 they contain MD super block, and gives identifying information
2687 (e.g. UUID) about known MD arrays. See
2688 .BR mdadm.conf (5)
2689 for more details.
2690
2691 .SS /var/run/mdadm/map
2692 When
2693 .B \-\-incremental
2694 mode is used, this file gets a list of arrays currently being created.
2695 If
2696 .B /var/run/mdadm
2697 does not exist as a directory, then
2698 .B /var/run/mdadm.map
2699 is used instead. If
2700 .B /var/run
2701 is not available (as may be the case during early boot),
2702 .B /dev/.mdadm.map
2703 is used on the basis that
2704 .B /dev
2705 is usually available very early in boot.
2706
2707 .SH DEVICE NAMES
2708
2709 .I mdadm
2710 understand two sorts of names for array devices.
2711
2712 The first is the so-called 'standard' format name, which matches the
2713 names used by the kernel and which appear in
2714 .IR /proc/mdstat .
2715
2716 The second sort can be freely chosen, but must reside in
2717 .IR /dev/md/ .
2718 When giving a device name to
2719 .I mdadm
2720 to create or assemble an array, either full path name such as
2721 .I /dev/md0
2722 or
2723 .I /dev/md/home
2724 can be given, or just the suffix of the second sort of name, such as
2725 .I home
2726 can be given.
2727
2728 When
2729 .I mdadm
2730 chooses device names during auto-assembly or incremental assembly, it
2731 will sometimes add a small sequence number to the end of the name to
2732 avoid conflicted between multiple arrays that have the same name. If
2733 .I mdadm
2734 can reasonably determine that the array really is meant for this host,
2735 either by a hostname in the metadata, or by the presence of the array
2736 in
2737 .BR mdadm.conf ,
2738 then it will leave off the suffix if possible.
2739 Also if the homehost is specified as
2740 .B <ignore>
2741 .I mdadm
2742 will only use a suffix if a different array of the same name already
2743 exists or is listed in the config file.
2744
2745 The standard names for non-partitioned arrays (the only sort of md
2746 array available in 2.4 and earlier) are of the form
2747 .IP
2748 /dev/mdNN
2749 .PP
2750 where NN is a number.
2751 The standard names for partitionable arrays (as available from 2.6
2752 onwards) are of the form
2753 .IP
2754 /dev/md_dNN
2755 .PP
2756 Partition numbers should be indicated by added "pMM" to these, thus "/dev/md/d1p2".
2757 .PP
2758 From kernel version, 2.6.28 the "non-partitioned array" can actually
2759 be partitioned. So the "md_dNN" names are no longer needed, and
2760 partitions such as "/dev/mdNNpXX" are possible.
2761
2762 .SH NOTE
2763 .I mdadm
2764 was previously known as
2765 .IR mdctl .
2766 .P
2767 .I mdadm
2768 is completely separate from the
2769 .I raidtools
2770 package, and does not use the
2771 .I /etc/raidtab
2772 configuration file at all.
2773
2774 .SH SEE ALSO
2775 For further information on mdadm usage, MD and the various levels of
2776 RAID, see:
2777 .IP
2778 .B http://linux\-raid.osdl.org/
2779 .PP
2780 (based upon Jakob \(/Ostergaard's Software\-RAID.HOWTO)
2781 .\".PP
2782 .\"for new releases of the RAID driver check out:
2783 .\"
2784 .\".IP
2785 .\".UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
2786 .\"ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
2787 .\".UE
2788 .\".PP
2789 .\"or
2790 .\".IP
2791 .\".UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
2792 .\"http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
2793 .\".UE
2794 .PP
2795 The latest version of
2796 .I mdadm
2797 should always be available from
2798 .IP
2799 .B http://www.kernel.org/pub/linux/utils/raid/mdadm/
2800 .PP
2801 Related man pages:
2802 .PP
2803 .IR mdmon (8),
2804 .IR mdadm.conf (5),
2805 .IR md (4).
2806 .PP
2807 .IR raidtab (5),
2808 .IR raid0run (8),
2809 .IR raidstop (8),
2810 .IR mkraid (8).