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