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