]> git.ipfire.org Git - thirdparty/mdadm.git/blame - mdadm.8
mdadm-1.0.0
[thirdparty/mdadm.git] / mdadm.8
CommitLineData
52826846 1.\" -*- nroff -*-
e0d19036 2.TH MDADM 8
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),
30.B RAID4
31and
32.B RAID5.
33
34Recent kernels (2002) also support a mode known as
35.BR MULTIPATH .
9a9dab36 36.B mdadm
e0d19036 37only provides limited support for MULTIPATH as yet.
52826846 38
9a9dab36 39.B mdadm
11a3e71d
NB
40is a program that can be used to create, manage, and monitor
41MD devices. As
cd29a5c8
NB
42such it provides a similar set of functionality to the
43.B raidtools
44packages.
45The key differences between
9a9dab36 46.B mdadm
cd29a5c8
NB
47and
48.B raidtools
49are:
50.IP \(bu 4
9a9dab36 51.B mdadm
cd29a5c8
NB
52is a single program and not a collection of programs.
53.IP \(bu 4
9a9dab36 54.B mdadm
cd29a5c8 55can perform (almost) all of its functions without having a
2d465520
NB
56configuration file. Also
57.B mdadm
58helps with management of the configuration
cd29a5c8
NB
59file.
60.IP \(bu 4
9a9dab36 61.B mdadm
e0d19036 62can provide information about your arrays (through Query, Detail, and Examine)
cd29a5c8
NB
63that
64.B raidtools
65cannot.
52826846
NB
66
67.SH MODES
e0d19036 68mdadm has 6 major modes of operation:
cd29a5c8
NB
69.TP
70.B Assemble
71Assemble the parts of a previously created
52826846
NB
72array into an active array. Components can be explicitly given
73or can be searched for.
9a9dab36 74.B mdadm
cd29a5c8
NB
75checks that the components
76do form a bona fide array, and can, on request, fiddle superblock
77information so as to assemble a faulty array.
78
79.TP
80.B Build
81Build a legacy array without per-device superblocks.
82
83.TP
84.B Create
85Create a new array with per-device superblocks.
86'''It can progress
87'''in several step create-add-add-run or it can all happen with one command.
88
89.TP
e0d19036
NB
90.B Manage
91This is for doing things to specific components of an array such as
92adding new spares and removing faulty devices.
cd29a5c8
NB
93
94.TP
e0d19036
NB
95.B Misc
96This mode allows operations on independent devices such as examine MD
97superblocks, erasing old superblocks and stopping active arrays.
cd29a5c8
NB
98
99.TP
100.B "Follow or Monitor"
101Monitor one or more md devices and act on any state changes.
102
52826846
NB
103.SH OPTIONS
104
105Available options are:
106
cd29a5c8
NB
107.TP
108.BR -A ", " --assemble
2d465520 109Assemble a pre-existing array.
52826846 110
cd29a5c8
NB
111.TP
112.BR -B ", " --build
113Build a legacy array without superblocks.
52826846 114
cd29a5c8
NB
115.TP
116.BR -C ", " --create
117Create a new array.
52826846 118
e0d19036
NB
119.TP
120.BR -Q ", " --query
121Examine a device to see
122(1) if it is an md device and (2) if it is a component of an md
123array.
124Information about what is discovered is presented.
125
cd29a5c8
NB
126.TP
127.BR -D ", " --detail
128Print detail of one or more md devices.
52826846 129
cd29a5c8
NB
130.TP
131.BR -E ", " --examine
132Print content of md superblock on device(s).
52826846 133
cd29a5c8
NB
134.TP
135.BR -F ", " --follow ", " --monitor
136Select
137.B Monitor
138mode.
52826846 139
cd29a5c8
NB
140.TP
141.BR -h ", " --help
142Display help message or, after above option, mode specific help message.
52826846 143
cd29a5c8
NB
144.TP
145.BR -V ", " --version
9a9dab36 146Print version information for mdadm.
52826846 147
cd29a5c8
NB
148.TP
149.BR -v ", " --verbose
150Be more verbose about what is happening.
52826846 151
cd29a5c8
NB
152.TP
153.BR -b ", " --brief
154Be less verbose. This is used with
155.B --detail
156and
157.BR --examine .
52826846 158
e0d19036
NB
159.TP
160.BR -f ", " --force
161Be more forceful about certain operations. See the various modes of
162the exact meaning of this option in different contexts.
163
164.TP
165.BR -c ", " --config=
166Specify the config file. Default is
167.BR /etc/mdadm.conf .
168
169.TP
170.BR -s ", " --scan
171scan config file or
172.B /proc/mdstat
173for missing information.
174In general, this option gives
175.B mdadm
176permission to get any missing information, like component devices,
177array devices, array identities, and alert destination from the
178configuration file:
179.BR /etc/mdadm.conf .
180One exception is MISC mode when using
181.B --detail
182or
183.B --stop
184in which case
185.B --scan
186says to get a list of array devices from
187.BR /proc/mdstat .
188
cd29a5c8 189.SH For create or build:
52826846 190
cd29a5c8
NB
191.TP
192.BR -c ", " --chunk=
193Specify chunk size of kibibytes. The default is 64.
52826846 194
cd29a5c8
NB
195.TP
196.BR --rounding=
197Specify rounding factor for linear array (==chunk size)
52826846 198
cd29a5c8
NB
199.TP
200.BR -l ", " --level=
201Set raid level. Options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid5, 4,
c913b90e 202raid5, 5, multipath, mp. Obviously some of these are synonymous.
cd29a5c8 203Only the first 4 are valid when Building.
52826846 204
cd29a5c8
NB
205.TP
206.BR -p ", " --parity=
207Set raid5 parity algorithm. Options are:
2d465520
NB
208left-asymmetric,
209left-symmetric,
210right-asymmetric,
211right-symmetric,
212la, ra, ls, rs. The default is left-symmetric.
52826846 213
cd29a5c8
NB
214.TP
215.BR --layout=
216same as --parity
52826846 217
cd29a5c8 218.TP
b83d95f3 219.BR -n ", " --raid-devices=
cd29a5c8
NB
220number of active devices in array.
221
222.TP
b83d95f3
NB
223.BR -x ", " --spare-devices=
224number of spare (eXtra) devices in initial array. Spares can be added
cd29a5c8
NB
225and removed later.
226
227.TP
228.BR -z ", " --size=
229Amount (in Kibibytes) of space to use from each drive in RAID1/4/5.
230This must be a multiple of the chunk size, and must leave about 128Kb
231of space at the end of the drive for the RAID superblock.
232If this is not specified
233(as it normally is not) the smallest drive (or partition) sets the
234size, though if there is a variance among the drives of greater than 1%, a warning is
235issued.
52826846
NB
236
237.SH For assemble:
238
cd29a5c8
NB
239.TP
240.BR -u ", " --uuid=
241uuid of array to assemble. Devices which don't have this uuid are
242excluded
243
244.TP
245.BR -m ", " --super-minor=
246Minor number of device that array was created for. Devices which
247don't have this minor number are excluded. If you create an array as
2d465520 248/dev/md1, then all superblocks will contain the minor number 1, even if
cd29a5c8
NB
249the array is later assembled as /dev/md2.
250
cd29a5c8
NB
251.TP
252.BR -f ", " --force
52826846
NB
253Assemble the array even if some superblocks appear out-of-date
254
cd29a5c8
NB
255.TP
256.BR -R ", " --run
257Attempt to start the array even if fewer drives were given than are
258needed for a full array. Normally if not all drives are found and
259.B --scan
260is not used, then the array will be assembled but not started.
261With
262.B --run
263an attempt will be made to start it anyway.
52826846 264
e0d19036 265.SH For Manage mode:
52826846 266
cd29a5c8
NB
267.TP
268.BR -a ", " --add
269'''add, or
270hotadd listed devices.
52826846 271
cd29a5c8
NB
272.TP
273.BR -r ", " --remove
2d465520 274remove listed devices. They must not be active. i.e. they should
cd29a5c8 275be failed or spare devices.
52826846 276
cd29a5c8
NB
277.TP
278.BR -f ", " --fail
279mark listed devices as faulty.
52826846 280
cd29a5c8
NB
281.TP
282.BR --set-faulty
283same as --fail.
52826846 284
e0d19036
NB
285.SH For Misc mode:
286
cd29a5c8
NB
287.TP
288.BR -R ", " --run
289start a partially built array.
52826846 290
cd29a5c8
NB
291.TP
292.BR -S ", " --stop
293deactivate array, releasing all resources.
52826846 294
cd29a5c8
NB
295.TP
296.BR -o ", " --readonly
297mark array as readonly.
52826846 298
cd29a5c8
NB
299.TP
300.BR -w ", " --readwrite
301mark array as readwrite.
52826846 302
e0d19036
NB
303.TP
304.B --zero-superblock
305If the device contains a valid md superblock, the block is
306over-written with zeros. With
307--force
308the block where the superblock would be is over-written even if it
309doesn't appear to be valid.
52826846 310
e0d19036
NB
311.SH For Monitor mode:
312.TP
313.BR -m ", " --mail
314Give a mail address to send alerts to.
315
316.TP
317.BR -p ", " --program ", " --alert
318Give a program to be run whenever an event is detected.
319
320.TP
321.BR -d ", " --delay
322Give a delay in seconds.
323.B mdadm
324polls the md arrays and then waits this many seconds before polling
325again. The default is 60 seconds.
326
327.SH ASSEMBLE MODE
52826846 328
cd29a5c8
NB
329.HP 12
330Usage:
9a9dab36 331.B mdadm --assemble
cd29a5c8
NB
332.I device options...
333.HP 12
334Usage:
9a9dab36 335.B mdadm --assemble --scan
cd29a5c8 336.I options...
52826846 337
cd29a5c8 338.PP
52826846 339This usage assembles one or more raid arrays from pre-existing components.
9a9dab36 340For each array, mdadm needs to know the md device, the identity of the
e0d19036 341array, and a number of component-devices. These can be found in a number of ways.
52826846
NB
342
343The md device is either given before
344.B --scan
345or is found from the config file. In the latter case, multiple md devices
9a9dab36 346can be started with a single mdadm command.
52826846 347
cd29a5c8 348The identity can be given with the
52826846 349.B --uuid
cd29a5c8
NB
350option, with the
351.B --super-minor
352option, can be found in in the config file, or will be taken from the
e0d19036 353super block on the first component-device listed on the command line.
52826846
NB
354
355Devices can be given on the
356.B --assemble
cd29a5c8
NB
357command line or from the config file. Only devices which have an md
358superblock which contains the right identity will be considered for any device.
52826846
NB
359
360The config file is only used if explicitly named with
361.B --config
362or requested with
363.B --scan.
364In the later case,
9a9dab36 365.B /etc/mdadm.conf
52826846
NB
366is used.
367
368If
369.B --scan
cd29a5c8
NB
370is not given, then the config file will only be used to find the
371identity of md arrays.
52826846 372
2d465520 373Normally the array will be started after it is assembled. However if
cd29a5c8 374.B --scan
2d465520 375is not given and insufficient drives were listed to start a complete
cd29a5c8
NB
376(non-degraded) array, then the array is not started (to guard against
377usage errors). To insist that the array be started in this case (as
378may work for RAID1 or RAID5), give the
379.B --run
380flag.
52826846 381
52826846 382
cd29a5c8 383.SH BUILD MODE
52826846 384
cd29a5c8
NB
385.HP 12
386Usage:
9a9dab36 387.B mdadm --build
cd29a5c8
NB
388.I device
389.BI --chunk= X
390.BI --level= Y
b83d95f3 391.BI --raid-devices= Z
cd29a5c8
NB
392.I devices
393
394.PP
52826846 395This usage is similar to
cd29a5c8 396.BR --create .
52826846 397The difference is that it creates a legacy array without a superblock. With
cd29a5c8 398these arrays there is no difference between initially creating the array and
52826846
NB
399subsequently assembling the array, except that hopefully there is useful
400data there in the second case.
401
cd29a5c8
NB
402The level may only be 0, raid0, or linear. All devices must be listed
403and the array will be started once complete.
404
405.SH CREATE MODE
406
407.HP 12
408Usage:
9a9dab36 409.B mdadm --create
cd29a5c8
NB
410.I device
411.BI --chunk= X
412.BI --level= Y
413.br
b83d95f3 414.BI --raid-devices= Z
cd29a5c8
NB
415.I devices
416
417.PP
418This usage will initialise a new md array, associate some devices with
419it, and activate the array.
420
421As devices are added, they are checked to see if they contain raid
2d465520 422superblocks or filesystems. They are also checked to see if the variance in
cd29a5c8
NB
423device size exceeds 1%.
424
425If any discrepancy is found, the array will not automatically be run, though
426the presence of a
427.B --run
428can override this caution.
429
2d465520
NB
430To create a "degraded" array in which some devices are missing, simply
431give the word
432.B missing
433in place of a device name. This will cause
434.B mdadm
435to leave the corresponding slot in the array empty.
436For a RAID4 or RAID5 array at most one slot can be
437.BR missing .
438For a RAID1 array, only one real device needs to be given. All of the
439others can be
440.BR missing .
441
cd29a5c8
NB
442'''If the
443'''.B --size
e0d19036 444'''option is given, it is not necessary to list any component-devices in this command.
cd29a5c8
NB
445'''They can be added later, before a
446'''.B --run.
447'''If no
448'''.B --size
449'''is given, the apparent size of the smallest drive given is used.
450
451The General Management options that are valid with --create are:
452.TP
453.B --run
454insist of running the array even if some devices look like they might
455be in use.
456
457.TP
458.B --readonly
459start the array readonly - not supported yet.
52826846 460
e0d19036 461.SH MANAGE MODE
cd29a5c8
NB
462.HP 12
463Usage:
e0d19036
NB
464.B mdadm
465.I device
466.I options... devices...
cd29a5c8
NB
467.PP
468
e0d19036
NB
469This usage will allow individual devices in an array to be failed,
470removed or added. It is possible to perform multiple operations with
471on command. For example:
472.br
2d465520 473.B " mdadm /dev/md0 -f /dev/hda1 -r /dev/hda1 /a /dev/hda1"
e0d19036
NB
474.br
475will firstly mark
476.B /dev/hda1
477as faulty in
478.B /dev/md0
479and will then remove it from the array and finally add it back
2d465520 480in as a spare. However only one md array can be affected by a single
e0d19036
NB
481command.
482
483.SH MISC MODE
484.HP 12
485Usage:
9a9dab36 486.B mdadm
e0d19036
NB
487.I options ...
488.I devices ...
489.PP
cd29a5c8 490
e0d19036
NB
491MISC mode includes a number if distinct operations that
492operate on distinct devices. The operations are:
493.TP
494--query
495The device is examined to see if it is
496(1) an active md array, or
497(2) a component of an md array.
498The information discovered is reported.
499
500.TP
501--detail
2d465520
NB
502The device should be an active md device.
503.B mdadm
504will display a detailed description of the array.
cd29a5c8 505.B --brief
2d465520
NB
506or
507.B --scan
508will cause the output to be less detailed and the format to be
e0d19036 509suitable for inclusion in
9a9dab36 510.BR /etc/mdadm.conf .
cd29a5c8 511
e0d19036
NB
512.TP
513--examine
2d465520
NB
514The device should be a component of an md array.
515.B mdadm
516will read the md superblock of the device and display the contents.
e0d19036
NB
517If
518.B --brief
519is given, or
520.B --scan
521then multiple devices that are components of the one array
522are grouped together and reported in a single entry suitable
523for inclusion in
524.BR /etc/mdadm.conf .
525
2d465520 526Having
e0d19036
NB
527.B --scan
528without listing any devices will cause all devices listed in the
529config file to be examined.
530
531.TP
532--stop
533This devices should active md arrays which will be deactivated, if
534they are not currently in use.
535
536.TP
537--run
538This will fully activate a partially assembled md array.
539
540.TP
541--readonly
542This will mark an active array as read-only, providing that it is
543not currently being used.
544
545.TP
546--readwrite
547This will change a
548.B readonly
549array back to being read/write.
550
2d465520
NB
551.TP
552--scan
553For all operations except
554.BR --examine ,
555.B --scan
556will cause the operation to be applied to all arrays listed in
557.BR /proc/mdstat .
558For
559.BR --examine,
560.B --scan
561causes all devices listed in the config file to be examined.
562
563
e0d19036
NB
564.SH MONITOR MODE
565
cd29a5c8
NB
566.HP 12
567Usage:
e0d19036
NB
568.B mdadm --monitor
569.I options... devices...
570
cd29a5c8 571.PP
e0d19036
NB
572This usage causes
573.B mdadm
574to periodically poll a number of md arrays and to report on any events
575noticed.
576.B mdadm
577will never exit once it decides that there are arrays to be checked,
578so it should normally be run in the background.
579
2d465520
NB
580As well as reporting events,
581.B mdadm
582may move a spare drive from one array to another if they are in the
583same
584.B spare-group
585and if the destination array has a failed drive but not spares.
586
e0d19036
NB
587If any devices are listed on the command line,
588.B mdadm
589will only monitor those devices. Otherwise all arrays listed in the
590configuration file will be monitored. Further, if
591.B --scan
592is given, then any other md devices that appear in
593.B /proc/mdstat
594will also be monitored.
595
596The result of monitoring the arrays is the generation of events.
597These events are passed to a separate program (is specified) and may
2d465520 598be mailed to a given E-mail address.
e0d19036 599
cd29a5c8
NB
600
601If
602.B --scan
e0d19036
NB
603is given, then a program or an E-mail address must be specified on the
604command line or in the config file. If neither are available, then
605.B mdadm
606will not monitor anything.
607Without
cd29a5c8 608.B --scan
e0d19036 609.B mdadm
2d465520 610will continue monitoring as long as something was found to monitor. If
e0d19036
NB
611no program or email is given, then each event is reported to
612.BR stdout .
cd29a5c8 613
e0d19036
NB
614The different events are:
615
616.RS 4
617.TP
618.B DeviceDisappeared
2d465520 619An md array which previously was configured appears to no longer be
e0d19036
NB
620configured.
621
622.TP
623.B RebuildStarted
624An md array started reconstruction.
625
626.TP
627.BI Rebuild NN
628Where
629.I NN
630is 20, 40, 60, or 80, this indicates that rebuild has passed that many
631percentage of the total.
632
633.TP
634.B Fail
635An active component device of an array has been marked as faulty.
636
637.TP
638.B FailSpare
639A spare component device which was being rebuilt to replace a faulty
640device has failed.
641
642.TP
643.B SpareActive
644A spare component device which was being rebuilt to replace a faulty
645device as been successfully rebuild and has been made active.
646
647.TP
648.B NewArray
649A new md array has been detected in the
650.B /proc/mdstat
651file.
652
653.TP
654.B MoveSpare
655A spare drive has been moved from one array in a
656.B spare-group
657to another to allow a failed drive to be replaced.
658
659.RE
660
661Only
662.B Fail
663and
664.B FailSpare
665cause Email to be sent. All events cause the program to be run.
666The program is run with two or three arguments, they being the event
667name, the array device and possibly a second device.
668
669Each event has an associated array device (e.g.
670.BR /dev/md1 )
671and possibly a second device. For
672.BR Fail ,
673.BR FailSpare ,
674and
675.B SpareActive
676the second device is the relevant component device.
677For
678.B MoveSpare
679the second device is the array that the spare was moved from.
680
681For
682.B mdadm
683to move spares from one array to another, the different arrays need to
684be labelled with the same
685.B spare-group
686in the configuration file. The
687.B spare-group
688name can be any string. It is only necessary that different spare
2d465520 689groups use different names.
e0d19036
NB
690
691When
9a9dab36 692.B mdadm
e0d19036
NB
693detects that an array which is in a spare group has fewer active
694devices than necessary for the complete array, and has no spare
695devices, it will look for another array in the same spare group that
696has a full complement of working drive and a spare. It will then
697attempt to remove the spare from the second drive and add it to the
698first.
699If the removal succeeds but the adding fails, then it is added back to
700the original array.
701
2d465520
NB
702.SH EXAMPLES
703
704To find out if a devices is a raid array or part of one:
705.br
706.B " mdadm -Q /dev/name-of-device"
707
708To assemble and start all array listed in the standard config file:
709.br
710.B " mdadm -As"
711
712To shut down all arrays (that are not still in used):
713.br
714.B " mdadm --stop --scan"
715
716To monitor all arrays if (and only if) an email address or program
717was given in the config file, but poll every 2 minutes:
718.br
719.B " mdadm -Fs --delay=120"
720
721To create /dev/md0 as a RAID1 array with /dev/hda1 and /dev/hdc1:
722.br
723.B " mdadm -C /dev/md0 -l1 -n2 /dev/hd[ac]1"
724
725To create prototype a config file that describes currently
726active arrays that are known to be made from partitions of
727IDE or SCSI drives:
728.br
729.B " echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > mdadm.conf"
730.br
731.B " mdadm --detail --scan >> mdadm.conf"
732.br
733This file should be reviewed before being used as it may
734contain unwanted detail.
735
736To find out what raid arrays could be assembled from existing
737IDE and SCSI whole drives (not partitions):
738.br
739.B " echo 'DEVICE /dev/hd[a-z] /dev/sd*[a-z]' > mdadm.conf"
740.br
741.B " mdadm -Es -c mdadm.conf >> mdadm.conf"
742This file is very likely to contain unwanted detail, particularly
743the
744.B devices=
745entries.
746
747To get help about Create mode:
748.br
749.B " mdadm --create --help"
750
751To get help about the format of the config file:
752.br
753.B " mdadm --config --help"
754
755To get general help:
756.br
757.B " mdadm --help"
758
759
cd29a5c8 760
cd29a5c8
NB
761
762.SH FILES
763
764.SS /proc/mdstat
765
766If you're using the
767.B /proc
768filesystem,
769.B /proc/mdstat
2d465520
NB
770lists all active md devices with information about them.
771.B mdadm
772uses this to find arrays when
773.B --scan
774is given in Misc mode, and to monitor array reconstruction
775on Monitor mode.
776
cd29a5c8 777
9a9dab36 778.SS /etc/mdadm.conf
cd29a5c8 779
11a3e71d
NB
780The config file lists which devices may be scanned to see if
781they contain MD super block, and gives identifying information
782(e.g. UUID) about known MD arrays. See
783.BR mdadm.conf (5)
784for more details.
cd29a5c8 785
52826846 786
2d465520
NB
787.SH NOTE
788.B mdadm
789was previously known as
790.BR mdctl .
791
52826846 792.SH SEE ALSO
cd29a5c8
NB
793For information on the various levels of
794RAID, check out:
795
796.IP
797.UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
798http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/
799.UE
800.PP
801for new releases of the RAID driver check out:
802
803.IP
804.UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
805ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches
806.UE
807.PP
808or
809.IP
810.UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
811http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/
812.URk
813.PP
56eb10c0
NB
814.BR mdadm.conf (5),
815.BR md (4).
816.PP
52826846
NB
817.IR raidtab (5),
818.IR raid0run (8),
819.IR raidstop (8),
820.IR mkraid (8)