]> git.ipfire.org Git - thirdparty/mdadm.git/blame - mdadm.8
Fix a test that will allow arrays with bitmaps to be assembled.
[thirdparty/mdadm.git] / mdadm.8
CommitLineData
52826846 1.\" -*- nroff -*-
570c0542 2.TH MDADM 8 "" v1.11.1
52826846 3.SH NAME
9a9dab36 4mdadm \- manage MD devices
cd29a5c8
NB
5.I aka
6Linux Software Raid.
7
52826846
NB
8.SH SYNOPSIS
9
e0d19036 10.BI mdadm " [mode] <raiddevice> [options] <component-devices>"
52826846
NB
11
12.SH DESCRIPTION
13RAID devices are virtual devices created from two or more
cd29a5c8
NB
14real block devices. This allows multiple devices (typically disk
15drives or partitions there-of) to be combined into a single device to
16hold (for example) a single filesystem.
2d465520 17Some RAID levels include redundancy and so can survive some degree of
cd29a5c8
NB
18device failure.
19
2d465520
NB
20Linux Software RAID devices are implemented through the md (Multiple
21Devices) device driver.
cd29a5c8
NB
22
23Currently, Linux supports
24.B LINEAR
25md devices,
26.B RAID0
27(striping),
28.B RAID1
29(mirroring),
d013a55e
NB
30.BR RAID4 ,
31.BR RAID5 ,
98c6faba 32.BR RAID6 ,
b5e64645 33.BR MULTIPATH ,
cd29a5c8 34and
b5e64645 35.BR FAULTY .
d013a55e
NB
36
37.B MULTIPATH is not a Software RAID mechanism, but does involve
38multiple devices. For
39.B MULTIPATH
40each device is a path to one common physical storage device.
41
b5e64645
NB
42.B FAULTY is also no true RAID, and it only involves one device. It
43provides a layer over a true device that can be used to inject faults.
52826846 44
9a9dab36 45.B mdadm
11a3e71d
NB
46is a program that can be used to create, manage, and monitor
47MD devices. As
cd29a5c8
NB
48such it provides a similar set of functionality to the
49.B raidtools
50packages.
51The key differences between
9a9dab36 52.B mdadm
cd29a5c8
NB
53and
54.B raidtools
55are:
56.IP \(bu 4
9a9dab36 57.B mdadm
cd29a5c8
NB
58is a single program and not a collection of programs.
59.IP \(bu 4
9a9dab36 60.B mdadm
cd29a5c8 61can perform (almost) all of its functions without having a
5787fa49 62configuration file and does not use one by default. Also
2d465520
NB
63.B mdadm
64helps with management of the configuration
cd29a5c8
NB
65file.
66.IP \(bu 4
9a9dab36 67.B mdadm
e0d19036 68can provide information about your arrays (through Query, Detail, and Examine)
cd29a5c8
NB
69that
70.B raidtools
71cannot.
5787fa49
NB
72.P
73.I mdadm
74does not use
75.IR /etc/raidtab ,
76the
77.B raidtools
78configuration file, at all. It has a different configuration file
79with a different format and an different purpose.
52826846
NB
80
81.SH MODES
dd0781e5 82mdadm has 7 major modes of operation:
cd29a5c8
NB
83.TP
84.B Assemble
85Assemble the parts of a previously created
52826846
NB
86array into an active array. Components can be explicitly given
87or can be searched for.
9a9dab36 88.B mdadm
cd29a5c8
NB
89checks that the components
90do form a bona fide array, and can, on request, fiddle superblock
91information so as to assemble a faulty array.
92
93.TP
94.B Build
570c0542 95Build an array without per-device superblocks.
cd29a5c8
NB
96
97.TP
98.B Create
99Create a new array with per-device superblocks.
100'''It can progress
101'''in several step create-add-add-run or it can all happen with one command.
102
103.TP
e0d19036
NB
104.B Manage
105This is for doing things to specific components of an array such as
106adding new spares and removing faulty devices.
cd29a5c8
NB
107
108.TP
e0d19036
NB
109.B Misc
110This mode allows operations on independent devices such as examine MD
111superblocks, erasing old superblocks and stopping active arrays.
cd29a5c8
NB
112
113.TP
114.B "Follow or Monitor"
5787fa49 115Monitor one or more md devices and act on any state changes. This is
98c6faba
NB
116only meaningful for raid1, 4, 5, 6 or multipath arrays as
117only these have interesting state. raid0 or linear never have
118missing, spare, or failed drives, so there is nothing to monitor.
5787fa49 119
dd0781e5
NB
120.TP
121.B "Grow"
122Grow (or shrink) an array, or otherwise reshape it in some way.
123Currently supported growth options including changing the active size
124of componenet devices in RAID level 1/4/5/6 and changing the number of
125active devices in RAID1.
cd29a5c8 126
52826846
NB
127.SH OPTIONS
128
129Available options are:
130
cd29a5c8
NB
131.TP
132.BR -A ", " --assemble
2d465520 133Assemble a pre-existing array.
52826846 134
cd29a5c8
NB
135.TP
136.BR -B ", " --build
137Build a legacy array without superblocks.
52826846 138
cd29a5c8
NB
139.TP
140.BR -C ", " --create
141Create a new array.
52826846 142
e0d19036
NB
143.TP
144.BR -Q ", " --query
145Examine a device to see
146(1) if it is an md device and (2) if it is a component of an md
147array.
148Information about what is discovered is presented.
149
cd29a5c8
NB
150.TP
151.BR -D ", " --detail
152Print detail of one or more md devices.
52826846 153
cd29a5c8
NB
154.TP
155.BR -E ", " --examine
156Print content of md superblock on device(s).
52826846 157
cd29a5c8
NB
158.TP
159.BR -F ", " --follow ", " --monitor
160Select
161.B Monitor
162mode.
52826846 163
dd0781e5
NB
164.TP
165.BR -G ", " --grow
166Change the size or shape of an active array.
167
cd29a5c8
NB
168.TP
169.BR -h ", " --help
56eedc1a
NB
170Display help message or, after above option, mode specific help
171message.
172
173.TP
174.B --help-options
175Display more detailed help about command line parsing and some commonly
176used options.
52826846 177
cd29a5c8
NB
178.TP
179.BR -V ", " --version
9a9dab36 180Print version information for mdadm.
52826846 181
cd29a5c8
NB
182.TP
183.BR -v ", " --verbose
184Be more verbose about what is happening.
52826846 185
cd29a5c8
NB
186.TP
187.BR -b ", " --brief
188Be less verbose. This is used with
189.B --detail
190and
191.BR --examine .
52826846 192
e0d19036
NB
193.TP
194.BR -f ", " --force
195Be more forceful about certain operations. See the various modes of
196the exact meaning of this option in different contexts.
197
198.TP
199.BR -c ", " --config=
200Specify the config file. Default is
201.BR /etc/mdadm.conf .
5787fa49
NB
202If the config file given is
203.B partitions
204then nothing will be read, but
205.I mdadm
206will act as though the config file contained exactly
207.B "DEVICE partitions"
208and will read
209.B /proc/partitions
210to find a list of devices to scan.
d013a55e
NB
211If the word
212.B none
213is given for the config file, then
214.I mdadm
215will act as though the config file were empty.
e0d19036
NB
216
217.TP
218.BR -s ", " --scan
219scan config file or
220.B /proc/mdstat
221for missing information.
222In general, this option gives
223.B mdadm
224permission to get any missing information, like component devices,
225array devices, array identities, and alert destination from the
226configuration file:
227.BR /etc/mdadm.conf .
228One exception is MISC mode when using
229.B --detail
230or
231.B --stop
232in which case
233.B --scan
234says to get a list of array devices from
235.BR /proc/mdstat .
236
570c0542
NB
237.TP
238.B -e ", " --metadata=
239Declare the style of superblock (raid metadata) to be used. The
240default is 0.90 for --create, and to guess for other operations.
241
242Options are:
243.RS
244.IP "0, 0.90, default"
245Use the original 0.90 format superblock. This format limits arrays to
24628 componenet devices and limits component devices of levels 1 and
247greater to 2 terabytes.
248.IP "1, 1.0, 1.1, 1.2"
249Use the new version-1 format superblock. This has few restrictions.
250The different subversion store the superblock at different locations
251on the device, either at the end (for 1.0), at the start (for 1.1) or
2524K from the start (for 1.2).
253.RE
254
cd29a5c8 255.SH For create or build:
52826846 256
cd29a5c8
NB
257.TP
258.BR -c ", " --chunk=
259Specify chunk size of kibibytes. The default is 64.
52826846 260
cd29a5c8
NB
261.TP
262.BR --rounding=
263Specify rounding factor for linear array (==chunk size)
52826846 264
cd29a5c8
NB
265.TP
266.BR -l ", " --level=
aa88f531
NB
267Set raid level. When used with
268.IR --create ,
98c6faba 269options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid4, 4,
b5e64645 270raid5, 5, raid6, 6, multipath, mp, fautly. Obviously some of these are synonymous.
aa88f531
NB
271
272When used with
273.IR --build ,
274only linear, raid0, 0, stripe are valid.
52826846 275
cd29a5c8
NB
276.TP
277.BR -p ", " --parity=
278Set raid5 parity algorithm. Options are:
2d465520
NB
279left-asymmetric,
280left-symmetric,
281right-asymmetric,
282right-symmetric,
283la, ra, ls, rs. The default is left-symmetric.
52826846 284
b5e64645
NB
285This option is also used to set the failure mode for
286.IR faulty .
287The options are:
288write-transient,
289wt,
290read-transient,
291rt,
292write-presistent,
293wp,
294read-persistent,
295rp,
296write-all,
297read-fixable,
298rf,
299clear,
300flush,
301none.
302
303Each mode can be followed by a number which is used as a period
304between fault generation. Without a number, the fault is generated
305once on the first relevant request. With a number, the fault will be
306generated after that many request, and will continue to be generated
307every time the period elapses.
308
309Multiple failure modes can be current simultaneously by using the
310"--grow" option to set subsequent failure modes.
311
312"clear" or "none" will remove any pending or periodic failure modes,
313and "flush" will clear any persistant faults.
314
315To set the parity with "--grow", the level of the array ("faulty")
316must be specified before the fault mode is specified.
317
cd29a5c8
NB
318.TP
319.BR --layout=
320same as --parity
52826846 321
cd29a5c8 322.TP
b83d95f3 323.BR -n ", " --raid-devices=
5787fa49
NB
324Specify the number of active devices in the array. This, plus the
325number of spare devices (see below) must equal the number of
326.I component-devices
d013a55e 327(including "\fBmissing\fP" devices)
dd0781e5
NB
328that are listed on the command line for
329.BR --create .
330Setting a value of 1 is probably
aa88f531
NB
331a mistake and so requires that
332.B --force
333be specified first. A value of 1 will then be allowed for linear,
334multipath, raid0 and raid1. It is never allowed for raid4 or raid5.
335.br
dd0781e5
NB
336This number can only be changed using
337.B --grow
338for RAID1 arrays, and only on kernels which provide necessary support.
cd29a5c8
NB
339
340.TP
b83d95f3 341.BR -x ", " --spare-devices=
5787fa49
NB
342Specify the number of spare (eXtra) devices in the initial array.
343Spares can also be added
344and removed later. The number of component devices listed
345on the command line must equal the number of raid devices plus the
346number of spare devices.
347
cd29a5c8
NB
348
349.TP
350.BR -z ", " --size=
98c6faba 351Amount (in Kibibytes) of space to use from each drive in RAID1/4/5/6.
cd29a5c8
NB
352This must be a multiple of the chunk size, and must leave about 128Kb
353of space at the end of the drive for the RAID superblock.
354If this is not specified
355(as it normally is not) the smallest drive (or partition) sets the
356size, though if there is a variance among the drives of greater than 1%, a warning is
357issued.
52826846 358
dd0781e5
NB
359This value can be set with
360.B --grow
361for RAID level 1/4/5/6. If the array was created with a size smaller
362than the currently active drives, the extra space can be accessed
363using
364.BR --grow .
365
366.TP
367.BR --assume-clean
368Tell
369.I mdadm
370that the array pre-existed and is known to be clean. This is only
371really useful for Building RAID1 array. Only use this if you really
372know what you are doing. This is currently only supported for --build.
373
374.TP
375.BR -R ", " --run
376Insist that
377.I mdadm
378run the array, even if some of the components
379appear to be active in another array or filesystem. Normally
380.I mdadm
381will ask for confirmation before including such components in an
382array. This option causes that question to be suppressed.
383
384.TP
385.BR -f ", " --force
386Insist that
387.I mdadm
388accept the geometry and layout specified without question. Normally
389.I mdadm
390will not allow creation of an array with only one device, and will try
391to create a raid5 array with one missing drive (as this makes the
392initial resync work faster). With
393.BR --force ,
394.I mdadm
395will not try to be so clever.
396
397.TP
398.BR -a ", " "--auto{=no,yes,md,mdp,part,p}{NN}"
48f7b27a
NB
399Instruct mdadm to create the device file if needed, possibly allocating
400an unused minor number. "md" causes a non-partitionable array
dd0781e5 401to be used. "mdp", "part" or "p" causes a partitionable array (2.6 and
48f7b27a
NB
402later) to be used. "yes" requires the named md device to have a
403'standard' format, and the type and minor number will be determined
404from this. See DEVICE NAMES below.
405
406The argumentment can also come immediately after
dd0781e5
NB
407"-a". e.g. "-ap".
408
409For partitionable arrays,
410.I mdadm
411will create the device file for the whole array and for the first 4
412partitions. A different number of partitions can be specified at the
413end of this option (e.g.
414.BR --auto=p7 ).
48f7b27a
NB
415If the device name ends with a digit, the partition names add a'p',
416and a number, e.g. "/dev/home1p3". If there is no
dd0781e5
NB
417trailing digit, then the partition names just have a number added,
418e.g. "/dev/scratch3".
419
48f7b27a
NB
420If the md device name is in a 'standard' format as described in DEVICE
421NAMES, then it will be created, if necessary, with the appropriate
422number based on that name. If the device name is not in one of these
423formats, then a unused minor number will be allocted. The minor
424number will be considered unused if there is no active array for that
425number, and there is no entry in /dev for that number and with a
426non-standard name.
427
52826846
NB
428.SH For assemble:
429
cd29a5c8
NB
430.TP
431.BR -u ", " --uuid=
432uuid of array to assemble. Devices which don't have this uuid are
433excluded
434
435.TP
436.BR -m ", " --super-minor=
437Minor number of device that array was created for. Devices which
438don't have this minor number are excluded. If you create an array as
2d465520 439/dev/md1, then all superblocks will contain the minor number 1, even if
cd29a5c8
NB
440the array is later assembled as /dev/md2.
441
d013a55e
NB
442Giving the literal word "dev" for
443.B --super-minor
444will cause
445.I mdadm
446to use the minor number of the md device that is being assembled.
447e.g. when assembling
448.BR /dev/md0 ,
449.M --super-minor=dev
450will look for super blocks with a minor number of 0.
451
cd29a5c8
NB
452.TP
453.BR -f ", " --force
52826846
NB
454Assemble the array even if some superblocks appear out-of-date
455
cd29a5c8
NB
456.TP
457.BR -R ", " --run
458Attempt to start the array even if fewer drives were given than are
459needed for a full array. Normally if not all drives are found and
460.B --scan
461is not used, then the array will be assembled but not started.
462With
463.B --run
464an attempt will be made to start it anyway.
52826846 465
dd0781e5
NB
466.TP
467.BR -a ", " "--auto{=no,yes,md,mdp,part}"
468See this option under Create and Build options.
469
5787fa49
NB
470.TP
471.BR -U ", " --update=
472Update the superblock on each device while assembling the array. The
feb716e9
NB
473argument given to this flag can be one of
474.BR sparc2.2 ,
475.BR summaries ,
e5329c37 476.BR resync ,
5787fa49
NB
477or
478.BR super-minor .
479
480The
481.B sparc2.2
482option will adjust the superblock of an array what was created on a Sparc
483machine running a patched 2.2 Linux kernel. This kernel got the
484alignment of part of the superblock wrong. You can use the
485.B "--examine --sparc2.2"
486option to
487.I mdadm
488to see what effect this would have.
489
490The
491.B super-minor
492option will update the
493.B "prefered minor"
494field on each superblock to match the minor number of the array being
feb716e9 495assembled. This is not needed on 2.6 and later kernels as they make
5787fa49
NB
496this adjustment automatically.
497
e5329c37
NB
498The
499.B resync
500option will cause the array to be marked
501.I dirty
502meaning that any redundancy in the array (e.g. parity for raid5,
503copies for raid1) may be incorrect. This will cause the raid system
504to perform a "resync" pass to make sure that all redundant information
505is correct.
506
feb716e9
NB
507The
508.B summaries
509option will correct the summaries in the superblock. That is the
510counts of total, working, active, failed, and spare devices.
5787fa49 511
e0d19036 512.SH For Manage mode:
52826846 513
cd29a5c8
NB
514.TP
515.BR -a ", " --add
516'''add, or
517hotadd listed devices.
52826846 518
cd29a5c8
NB
519.TP
520.BR -r ", " --remove
2d465520 521remove listed devices. They must not be active. i.e. they should
cd29a5c8 522be failed or spare devices.
52826846 523
cd29a5c8
NB
524.TP
525.BR -f ", " --fail
526mark listed devices as faulty.
52826846 527
cd29a5c8
NB
528.TP
529.BR --set-faulty
530same as --fail.
52826846 531
5787fa49
NB
532.SH For Examine mode:
533
534.TP
535.B --sparc2.2
536In an array was created on a 2.2 Linux kernel patched with RAID
537support, the superblock will have been created incorrectly, or at
538least incompatibly with 2.4 and later kernels. Using the
539.B --sparc2.2
540flag with
541.B --examine
542will fix the superblock before displaying it. If this appears to do
543the right thing, then the array can be successfully assembled using
544.BR "--assemble --update=sparc2.2" .
545
e0d19036
NB
546.SH For Misc mode:
547
cd29a5c8
NB
548.TP
549.BR -R ", " --run
550start a partially built array.
52826846 551
cd29a5c8
NB
552.TP
553.BR -S ", " --stop
554deactivate array, releasing all resources.
52826846 555
cd29a5c8
NB
556.TP
557.BR -o ", " --readonly
558mark array as readonly.
52826846 559
cd29a5c8
NB
560.TP
561.BR -w ", " --readwrite
562mark array as readwrite.
52826846 563
e0d19036
NB
564.TP
565.B --zero-superblock
566If the device contains a valid md superblock, the block is
567over-written with zeros. With
568--force
569the block where the superblock would be is over-written even if it
570doesn't appear to be valid.
52826846 571
feb716e9
NB
572.TP
573.BR -t ", " --test
574When used with
575.BR --detail ,
576the exit status of
577.I mdadm
578is set to reflect the status of the device.
579
e0d19036
NB
580.SH For Monitor mode:
581.TP
582.BR -m ", " --mail
583Give a mail address to send alerts to.
584
585.TP
586.BR -p ", " --program ", " --alert
587Give a program to be run whenever an event is detected.
588
589.TP
590.BR -d ", " --delay
591Give a delay in seconds.
592.B mdadm
593polls the md arrays and then waits this many seconds before polling
594again. The default is 60 seconds.
595
d013a55e
NB
596.TP
597.BR -f ", " --daemonise
598Tell
599.B mdadm
600to run as a background daemon if it decides to monitor anything. This
601causes it to fork and run in the child, and to disconnect form the
602terminal. The process id of the child is written to stdout.
603This is useful with
604.B --scan
605which will only continue monitoring if a mail address or alert program
606is found in the config file.
607
b5e64645
NB
608.TP
609.BR -i ", " --pid-file
610When
611.B mdadm
612is running in daemon mode, write the pid of the daemon process to
613the specified file, instead of printing it on standard output.
614
aa88f531
NB
615.TP
616.BR -1 ", " --oneshot
617Check arrays only once. This will generate
618.B NewArray
619events and more significantly
620.B DegradedArray
621events. Running
622.in +5
623.B " mdadm --monitor --scan -1"
624.in -5
625from a cron script will ensure regular notification of any degraded arrays.
626
98c6faba
NB
627.TP
628.BR -t ", " --test
629Generate a
630.B TestMessage
631alert for every array found at startup. This alert gets mailed and
632passed to the alert program. This can be used for testing that alert
633message to get through successfully.
634
e0d19036 635.SH ASSEMBLE MODE
52826846 636
cd29a5c8
NB
637.HP 12
638Usage:
9a9dab36 639.B mdadm --assemble
5787fa49
NB
640.I md-device options-and-component-devices...
641.HP 12
642Usage:
643.B mdadm --assemble --scan
644.I md-devices-and-options...
cd29a5c8
NB
645.HP 12
646Usage:
9a9dab36 647.B mdadm --assemble --scan
cd29a5c8 648.I options...
52826846 649
cd29a5c8 650.PP
52826846 651This usage assembles one or more raid arrays from pre-existing components.
9a9dab36 652For each array, mdadm needs to know the md device, the identity of the
e0d19036 653array, and a number of component-devices. These can be found in a number of ways.
52826846 654
5787fa49
NB
655In the first usage example (without the
656.BR --scan )
657the first device given is the md device.
658In the second usage example, all devices listed are treated as md
659devices and assembly is attempted.
660In the third (where no devices are listed) all md devices that are
661listed in the configuration file are assembled.
52826846 662
d013a55e
NB
663If precisely one device is listed, but
664.B --scan
dd0781e5 665is not given, then
d013a55e
NB
666.I mdadm
667acts as though
668.B --scan
669was given and identify information is extracted from the configuration file.
670
cd29a5c8 671The identity can be given with the
52826846 672.B --uuid
cd29a5c8
NB
673option, with the
674.B --super-minor
5787fa49 675option, can be found in the config file, or will be taken from the
e0d19036 676super block on the first component-device listed on the command line.
52826846
NB
677
678Devices can be given on the
679.B --assemble
5787fa49
NB
680command line or in the config file. Only devices which have an md
681superblock which contains the right identity will be considered for
682any array.
52826846
NB
683
684The config file is only used if explicitly named with
685.B --config
d013a55e 686or requested with (a possibly implicit)
52826846
NB
687.B --scan.
688In the later case,
9a9dab36 689.B /etc/mdadm.conf
52826846
NB
690is used.
691
692If
693.B --scan
cd29a5c8
NB
694is not given, then the config file will only be used to find the
695identity of md arrays.
52826846 696
2d465520 697Normally the array will be started after it is assembled. However if
cd29a5c8 698.B --scan
2d465520 699is not given and insufficient drives were listed to start a complete
cd29a5c8
NB
700(non-degraded) array, then the array is not started (to guard against
701usage errors). To insist that the array be started in this case (as
98c6faba 702may work for RAID1, 4, 5 or 6), give the
cd29a5c8
NB
703.B --run
704flag.
52826846 705
dd0781e5
NB
706If an
707.B auto
708option is given, either on the command line (--auto) or in the
709configuration file (e.g. auto=part), then
710.I mdadm
711will create the md device if necessary or will re-create it if it
712doesn't look usable as it is.
713
714This can be useful for handling partitioned devices (which don't have
715a stable device number - it can change after a reboot) and when using
716"udev" to manage your
717.B /dev
718tree (udev cannot handle md devices because of the unusual device
719initialisation conventions).
720
721If the option to "auto" is "mdp" or "part" or (on the command line
722only) "p", then mdadm will create a partitionable array, using the
723first free one that is not inuse, and does not already have an entry
724in /dev (apart from numeric /dev/md* entries).
725
726If the option to "auto" is "yes" or "md" or (on the command line)
727nothing, then mdadm will create a traditional, non-partitionable md
728array.
729
730It is expected that the "auto" functionality will be used to create
731device entries with meaningful names such as "/dev/md/home" or
732"/dev/md/root", rather than names based on the numerical array number.
733
734When using this option to create a partitionable array, the device
735files for the first 4 partitions are also created. If a different
736number is required it can be simply appended to the auto option.
737e.g. "auto=part8". Partition names are created by appending a digit
738string to the device name, with an intervening "_p" if the device name
739ends with a digit.
740
741The
742.B --auto
743option is also available in Build and Create modes. As those modes do
744not use a config file, the "auto=" config option does not apply to
745these modes.
52826846 746
cd29a5c8 747.SH BUILD MODE
52826846 748
cd29a5c8
NB
749.HP 12
750Usage:
9a9dab36 751.B mdadm --build
cd29a5c8
NB
752.I device
753.BI --chunk= X
754.BI --level= Y
b83d95f3 755.BI --raid-devices= Z
cd29a5c8
NB
756.I devices
757
758.PP
52826846 759This usage is similar to
cd29a5c8 760.BR --create .
52826846 761The difference is that it creates a legacy array without a superblock. With
cd29a5c8 762these arrays there is no difference between initially creating the array and
52826846
NB
763subsequently assembling the array, except that hopefully there is useful
764data there in the second case.
765
cd29a5c8
NB
766The level may only be 0, raid0, or linear. All devices must be listed
767and the array will be started once complete.
768
769.SH CREATE MODE
770
771.HP 12
772Usage:
9a9dab36 773.B mdadm --create
cd29a5c8
NB
774.I device
775.BI --chunk= X
776.BI --level= Y
777.br
b83d95f3 778.BI --raid-devices= Z
cd29a5c8
NB
779.I devices
780
781.PP
782This usage will initialise a new md array, associate some devices with
783it, and activate the array.
784
dd0781e5
NB
785This the
786.B --auto
787option is given (as described in more detail in the section on
788Assemble mode), then the md device will be created with a suitable
789device number if necessary.
790
cd29a5c8 791As devices are added, they are checked to see if they contain raid
2d465520 792superblocks or filesystems. They are also checked to see if the variance in
cd29a5c8
NB
793device size exceeds 1%.
794
795If any discrepancy is found, the array will not automatically be run, though
796the presence of a
797.B --run
798can override this caution.
799
2d465520 800To create a "degraded" array in which some devices are missing, simply
d013a55e 801give the word "\fBmissing\fP"
2d465520
NB
802in place of a device name. This will cause
803.B mdadm
804to leave the corresponding slot in the array empty.
805For a RAID4 or RAID5 array at most one slot can be
98c6faba 806"\fBmissing\fP"; for a RAID6 array at most two slots.
2d465520
NB
807For a RAID1 array, only one real device needs to be given. All of the
808others can be
d013a55e 809"\fBmissing\fP".
2d465520 810
feb716e9
NB
811When creating a RAID5 array,
812.B mdadm
813will automatically create a degraded array with an extra spare drive.
814This is because building the spare into a degraded array is in general faster than resyncing
815the parity on a non-degraded, but not clean, array. This feature can
816be over-ridden with the
b5e64645 817.I --force
feb716e9
NB
818option.
819
cd29a5c8
NB
820'''If the
821'''.B --size
e0d19036 822'''option is given, it is not necessary to list any component-devices in this command.
cd29a5c8
NB
823'''They can be added later, before a
824'''.B --run.
825'''If no
826'''.B --size
827'''is given, the apparent size of the smallest drive given is used.
828
829The General Management options that are valid with --create are:
830.TP
831.B --run
dd0781e5 832insist on running the array even if some devices look like they might
cd29a5c8
NB
833be in use.
834
835.TP
836.B --readonly
837start the array readonly - not supported yet.
52826846 838
e0d19036 839.SH MANAGE MODE
cd29a5c8
NB
840.HP 12
841Usage:
e0d19036
NB
842.B mdadm
843.I device
844.I options... devices...
cd29a5c8
NB
845.PP
846
e0d19036
NB
847This usage will allow individual devices in an array to be failed,
848removed or added. It is possible to perform multiple operations with
849on command. For example:
850.br
5787fa49 851.B " mdadm /dev/md0 -f /dev/hda1 -r /dev/hda1 -a /dev/hda1"
e0d19036
NB
852.br
853will firstly mark
854.B /dev/hda1
855as faulty in
856.B /dev/md0
857and will then remove it from the array and finally add it back
2d465520 858in as a spare. However only one md array can be affected by a single
e0d19036
NB
859command.
860
861.SH MISC MODE
862.HP 12
863Usage:
9a9dab36 864.B mdadm
e0d19036
NB
865.I options ...
866.I devices ...
867.PP
cd29a5c8 868
b5e64645 869MISC mode includes a number of distinct operations that
e0d19036
NB
870operate on distinct devices. The operations are:
871.TP
872--query
873The device is examined to see if it is
874(1) an active md array, or
875(2) a component of an md array.
876The information discovered is reported.
877
878.TP
879--detail
2d465520
NB
880The device should be an active md device.
881.B mdadm
882will display a detailed description of the array.
cd29a5c8 883.B --brief
2d465520
NB
884or
885.B --scan
886will cause the output to be less detailed and the format to be
e0d19036 887suitable for inclusion in
9a9dab36 888.BR /etc/mdadm.conf .
feb716e9
NB
889The exit status of
890.I mdadm
891will normally be 0 unless
892.I mdadm
893failed to get useful information about the device(s). However if the
894.B --test
895option is given, then the exit status will be:
896.RS
897.TP
8980
899The array is functioning normally.
900.TP
9011
902The array has at least one failed device.
903.TP
9042
905The array has multiple failed devices and hence is unusable (raid4 or
906raid5).
907.TP
9084
909There was an error while trying to get information about the device.
910.RE
cd29a5c8 911
e0d19036
NB
912.TP
913--examine
2d465520
NB
914The device should be a component of an md array.
915.B mdadm
916will read the md superblock of the device and display the contents.
e0d19036
NB
917If
918.B --brief
919is given, or
920.B --scan
921then multiple devices that are components of the one array
922are grouped together and reported in a single entry suitable
923for inclusion in
924.BR /etc/mdadm.conf .
925
2d465520 926Having
e0d19036
NB
927.B --scan
928without listing any devices will cause all devices listed in the
929config file to be examined.
930
931.TP
932--stop
98c6faba
NB
933The devices should be active md arrays which will be deactivated, as
934long as they are not currently in use.
e0d19036
NB
935
936.TP
937--run
938This will fully activate a partially assembled md array.
939
940.TP
941--readonly
942This will mark an active array as read-only, providing that it is
943not currently being used.
944
945.TP
946--readwrite
947This will change a
948.B readonly
949array back to being read/write.
950
2d465520
NB
951.TP
952--scan
953For all operations except
954.BR --examine ,
955.B --scan
956will cause the operation to be applied to all arrays listed in
957.BR /proc/mdstat .
958For
959.BR --examine,
960.B --scan
961causes all devices listed in the config file to be examined.
962
963
e0d19036
NB
964.SH MONITOR MODE
965
cd29a5c8
NB
966.HP 12
967Usage:
e0d19036
NB
968.B mdadm --monitor
969.I options... devices...
970
cd29a5c8 971.PP
e0d19036
NB
972This usage causes
973.B mdadm
974to periodically poll a number of md arrays and to report on any events
975noticed.
976.B mdadm
977will never exit once it decides that there are arrays to be checked,
978so it should normally be run in the background.
979
2d465520
NB
980As well as reporting events,
981.B mdadm
982may move a spare drive from one array to another if they are in the
983same
984.B spare-group
985and if the destination array has a failed drive but not spares.
986
e0d19036
NB
987If any devices are listed on the command line,
988.B mdadm
989will only monitor those devices. Otherwise all arrays listed in the
990configuration file will be monitored. Further, if
991.B --scan
992is given, then any other md devices that appear in
993.B /proc/mdstat
994will also be monitored.
995
996The result of monitoring the arrays is the generation of events.
bd526cee 997These events are passed to a separate program (if specified) and may
2d465520 998be mailed to a given E-mail address.
e0d19036 999
bd526cee
NB
1000When passing event to program, the program is run once for each event
1001and is given 2 or 3 command-line arguements. The first is the
1002name of the event (see below). The second is the name of the
1003md device which is affected, and the third is the name of a related
1004device if relevant, such as a component device that has failed.
cd29a5c8
NB
1005
1006If
1007.B --scan
e0d19036
NB
1008is given, then a program or an E-mail address must be specified on the
1009command line or in the config file. If neither are available, then
1010.B mdadm
1011will not monitor anything.
1012Without
cd29a5c8 1013.B --scan
e0d19036 1014.B mdadm
2d465520 1015will continue monitoring as long as something was found to monitor. If
e0d19036
NB
1016no program or email is given, then each event is reported to
1017.BR stdout .
cd29a5c8 1018
e0d19036
NB
1019The different events are:
1020
1021.RS 4
1022.TP
1023.B DeviceDisappeared
2d465520 1024An md array which previously was configured appears to no longer be
e0d19036
NB
1025configured.
1026
1027.TP
1028.B RebuildStarted
1029An md array started reconstruction.
1030
1031.TP
1032.BI Rebuild NN
1033Where
1034.I NN
1035is 20, 40, 60, or 80, this indicates that rebuild has passed that many
1036percentage of the total.
1037
98c6faba
NB
1038.TP
1039.B RebuildFinished
1040An md array that was rebuilding, isn't any more, either because it
1041finished normally or was aborted.
1042
e0d19036
NB
1043.TP
1044.B Fail
1045An active component device of an array has been marked as faulty.
1046
1047.TP
1048.B FailSpare
1049A spare component device which was being rebuilt to replace a faulty
1050device has failed.
1051
1052.TP
1053.B SpareActive
1054A spare component device which was being rebuilt to replace a faulty
1055device as been successfully rebuild and has been made active.
1056
1057.TP
1058.B NewArray
1059A new md array has been detected in the
1060.B /proc/mdstat
1061file.
1062
aa88f531
NB
1063.TP
1064.B DegradedArray
1065A newly noticed array appears to be degraded. This message is not
1066generated when
1067.I mdadm
1068notices a drive failure which causes degradation, but only when
1069.I mdadm
1070notices that an array is degraded when it first sees the array.
1071
e0d19036
NB
1072.TP
1073.B MoveSpare
1074A spare drive has been moved from one array in a
1075.B spare-group
1076to another to allow a failed drive to be replaced.
1077
98c6faba
NB
1078.TP
1079.B TestMessage
1080An array was found at startup, and the
1081.B --test
1082flag was given.
e0d19036
NB
1083.RE
1084
1085Only
98c6faba
NB
1086.B Fail ,
1087.B FailSpare ,
1088.B DegradedArray ,
e0d19036 1089and
98c6faba 1090.B TestMessage
e0d19036
NB
1091cause Email to be sent. All events cause the program to be run.
1092The program is run with two or three arguments, they being the event
1093name, the array device and possibly a second device.
1094
1095Each event has an associated array device (e.g.
1096.BR /dev/md1 )
1097and possibly a second device. For
1098.BR Fail ,
1099.BR FailSpare ,
1100and
1101.B SpareActive
1102the second device is the relevant component device.
1103For
1104.B MoveSpare
1105the second device is the array that the spare was moved from.
1106
1107For
1108.B mdadm
1109to move spares from one array to another, the different arrays need to
1110be labelled with the same
1111.B spare-group
1112in the configuration file. The
1113.B spare-group
1114name can be any string. It is only necessary that different spare
2d465520 1115groups use different names.
e0d19036
NB
1116
1117When
9a9dab36 1118.B mdadm
e0d19036
NB
1119detects that an array which is in a spare group has fewer active
1120devices than necessary for the complete array, and has no spare
1121devices, it will look for another array in the same spare group that
1122has a full complement of working drive and a spare. It will then
1123attempt to remove the spare from the second drive and add it to the
1124first.
1125If the removal succeeds but the adding fails, then it is added back to
1126the original array.
1127
dd0781e5
NB
1128.SH GROW MODE
1129The GROW mode is used for changing the size or shape of an active
1130array.
1131For this to work, the kernel must support the necessary change.
1132Various types of growth may be added during 2.6 development, possibly
1133including restructuring a raid5 array to have more active devices.
1134
1135Currently the only support available is to change the "size" attribute
1136for arrays with redundancy, and the raid-disks attribute of RAID1
1137arrays.
1138
1139Normally when an array is build the "size" it taken from the smallest
1140of the drives. If all the small drives in an arrays are, one at a
1141time, removed and replaced with larger drives, then you could have an
1142array of large drives with only a small amount used. In this
1143situation, changing the "size" with "GROW" mode will allow the extra
1144space to start being used. If the size is increased in this way, a
1145"resync" process will start to make sure the new parts of the array
1146are synchronised.
1147
1148Note that when an array changes size, any filesystem that may be
1149stored in the array will not automatically grow to use the space. The
1150filesystem will need to be explicitly told to use the extra space.
1151
1152A RAID1 array can work with any number of devices from 1 upwards
1153(though 1 is not very useful). There may be times which you want to
1154increase or decrease the number of active devices. Note that this is
1155different to hot-add or hot-remove which changes the number of
1156inactive devices.
1157
1158When reducing the number of devices in a RAID1 array, the slots which
1159are to be removed from the array must already be vacant. That is, the
1160devices that which were in those slots must be failed and removed.
1161
1162When the number of devices is increased, any hot spares that are
1163present may be activated immediately.
1164
2d465520
NB
1165.SH EXAMPLES
1166
5787fa49 1167.B " mdadm --query /dev/name-of-device"
2d465520 1168.br
5787fa49
NB
1169This will find out if a given device is a raid array, or is part of
1170one, and will provide brief information about the device.
2d465520 1171
5787fa49 1172.B " mdadm --assemble --scan"
2d465520 1173.br
5787fa49
NB
1174This will assemble and start all arrays listed in the standard confile
1175file. This command will typically go in a system startup file.
2d465520 1176
2d465520 1177.B " mdadm --stop --scan"
5787fa49
NB
1178.br
1179This will shut down all array that can be shut down (i.e. are not
19f8b8fc 1180currently in use). This will typically go in a system shutdown script.
2d465520 1181
5787fa49 1182.B " mdadm --follow --scan --delay=120"
2d465520 1183.br
5787fa49
NB
1184If (and only if) there is an Email address or program given in the
1185standard config file, then
1186monitor the status of all arrays listed in that file by
1187polling them ever 2 minutes.
2d465520 1188
5787fa49 1189.B " mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[ac]1"
2d465520 1190.br
5787fa49 1191Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1.
2d465520 1192
2d465520
NB
1193.br
1194.B " echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > mdadm.conf"
1195.br
1196.B " mdadm --detail --scan >> mdadm.conf"
1197.br
5787fa49
NB
1198This will create a prototype config file that describes currently
1199active arrays that are known to be made from partitions of IDE or SCSI drives.
2d465520
NB
1200This file should be reviewed before being used as it may
1201contain unwanted detail.
1202
2d465520
NB
1203.B " echo 'DEVICE /dev/hd[a-z] /dev/sd*[a-z]' > mdadm.conf"
1204.br
5787fa49
NB
1205.B " mdadm --examine --scan --config=mdadm.conf >> mdadm.conf"
1206.ber
1207This will find what arrays could be assembled from existign IDE and
1208SCSI whole drives (not partitions) and store the information is the
1209format of a config file.
2d465520
NB
1210This file is very likely to contain unwanted detail, particularly
1211the
1212.B devices=
5787fa49
NB
1213entries. It should be reviewed and edited before being used as an
1214actual config file.
2d465520 1215
5787fa49 1216.B " mdadm --examine --brief --scan --config=partitions"
2d465520 1217.br
5787fa49
NB
1218.B " mdadm -Ebsc partitions"
1219.br
1220Create a list of devices by reading
1221.BR /proc/partitions ,
1222scan these for RAID superblocks, and printout a brief listing of all
1223that was found.
2d465520 1224
5787fa49 1225.B " mdadm -Ac partitions -m 0 /dev/md0"
2d465520 1226.br
5787fa49
NB
1227Scan all partitions and devices listed in
1228.BR /proc/partitions
1229and assemble
1230.B /dev/md0
1231out of all such devices with a RAID superblock with a minor number of 0.
2d465520 1232
d013a55e
NB
1233.B " mdadm --monitor --scan --daemonise > /var/run/mdadm"
1234.br
1235If config file contains a mail address or alert program, run mdadm in
1236the background in monitor mode monitoring all md devices. Also write
1237pid of mdadm daemon to
1238.BR /var/run/mdadm .
1239
5787fa49 1240.B " mdadm --create --help"
2d465520 1241.br
5787fa49 1242Providew help about the Create mode.
2d465520 1243
5787fa49
NB
1244.B " mdadm --config --help"
1245.br
1246Provide help about the format of the config file.
2d465520 1247
5787fa49
NB
1248.B " mdadm --help"
1249.br
1250Provide general help.
cd29a5c8 1251
cd29a5c8
NB
1252
1253.SH FILES
1254
1255.SS /proc/mdstat
1256
1257If you're using the
1258.B /proc
1259filesystem,
1260.B /proc/mdstat
2d465520
NB
1261lists all active md devices with information about them.
1262.B mdadm
1263uses this to find arrays when
1264.B --scan
1265is given in Misc mode, and to monitor array reconstruction
1266on Monitor mode.
1267
cd29a5c8 1268
9a9dab36 1269.SS /etc/mdadm.conf
cd29a5c8 1270
11a3e71d
NB
1271The config file lists which devices may be scanned to see if
1272they contain MD super block, and gives identifying information
1273(e.g. UUID) about known MD arrays. See
1274.BR mdadm.conf (5)
1275for more details.
cd29a5c8 1276
48f7b27a
NB
1277.SH DEVICE NAMES
1278
1279While entries in the /dev directory can have any format you like,
1280.I mdadm
1281has an understanding of 'standard' formats which it uses to guide its
1282behaviour when creating device files via the
1283.I --auto
1284option.
1285
1286The standard names for non-partitioned arrays (the only sort of md
1287array available in 2.4 and earlier) either of
1288.IP
1289/dev/mdNN
1290.br
1291/dev/md/NN
1292.PP
1293where NN is a number.
1294The standard names for partitionable arrays (as available from 2.6
1295onwards) is one of
1296.IP
1297/dev/md/dNN
1298.br
1299/dev/md_dNN
1300.PP
1301Partition numbers should be indicated by added "pMM" to these, thus "/dev/md/d1p2".
52826846 1302
2d465520
NB
1303.SH NOTE
1304.B mdadm
1305was previously known as
1306.BR mdctl .
1307
52826846 1308.SH SEE ALSO
cd29a5c8
NB
1309For information on the various levels of
1310RAID, check out:
1311
1312.IP
1313.UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
1314http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
1315.UE
1316.PP
1317for new releases of the RAID driver check out:
1318
1319.IP
1320.UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
1321ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
1322.UE
1323.PP
1324or
1325.IP
1326.UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
1327http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
1328.URk
1329.PP
56eb10c0
NB
1330.BR mdadm.conf (5),
1331.BR md (4).
1332.PP
52826846
NB
1333.IR raidtab (5),
1334.IR raid0run (8),
1335.IR raidstop (8),
1336.IR mkraid (8)