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