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