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