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