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