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