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