]>
Commit | Line | Data |
---|---|---|
52826846 | 1 | .\" -*- nroff -*- |
feb716e9 | 2 | .TH MDADM 8 "" v1.4.0 |
52826846 | 3 | .SH NAME |
9a9dab36 | 4 | mdadm \- manage MD devices |
cd29a5c8 NB |
5 | .I aka |
6 | Linux Software Raid. | |
7 | ||
52826846 NB |
8 | .SH SYNOPSIS |
9 | ||
e0d19036 | 10 | .BI mdadm " [mode] <raiddevice> [options] <component-devices>" |
52826846 NB |
11 | |
12 | .SH DESCRIPTION | |
13 | RAID devices are virtual devices created from two or more | |
cd29a5c8 NB |
14 | real block devices. This allows multiple devices (typically disk |
15 | drives or partitions there-of) to be combined into a single device to | |
16 | hold (for example) a single filesystem. | |
2d465520 | 17 | Some RAID levels include redundancy and so can survive some degree of |
cd29a5c8 NB |
18 | device failure. |
19 | ||
2d465520 NB |
20 | Linux Software RAID devices are implemented through the md (Multiple |
21 | Devices) device driver. | |
cd29a5c8 NB |
22 | |
23 | Currently, Linux supports | |
24 | .B LINEAR | |
25 | md devices, | |
26 | .B RAID0 | |
27 | (striping), | |
28 | .B RAID1 | |
29 | (mirroring), | |
d013a55e NB |
30 | .BR RAID4 , |
31 | .BR RAID5 , | |
cd29a5c8 | 32 | and |
cd29a5c8 | 33 | .BR MULTIPATH . |
d013a55e NB |
34 | |
35 | .B MULTIPATH is not a Software RAID mechanism, but does involve | |
36 | multiple devices. For | |
37 | .B MULTIPATH | |
38 | each device is a path to one common physical storage device. | |
39 | ||
52826846 | 40 | |
9a9dab36 | 41 | .B mdadm |
11a3e71d NB |
42 | is a program that can be used to create, manage, and monitor |
43 | MD devices. As | |
cd29a5c8 NB |
44 | such it provides a similar set of functionality to the |
45 | .B raidtools | |
46 | packages. | |
47 | The key differences between | |
9a9dab36 | 48 | .B mdadm |
cd29a5c8 NB |
49 | and |
50 | .B raidtools | |
51 | are: | |
52 | .IP \(bu 4 | |
9a9dab36 | 53 | .B mdadm |
cd29a5c8 NB |
54 | is a single program and not a collection of programs. |
55 | .IP \(bu 4 | |
9a9dab36 | 56 | .B mdadm |
cd29a5c8 | 57 | can perform (almost) all of its functions without having a |
5787fa49 | 58 | configuration file and does not use one by default. Also |
2d465520 NB |
59 | .B mdadm |
60 | helps with management of the configuration | |
cd29a5c8 NB |
61 | file. |
62 | .IP \(bu 4 | |
9a9dab36 | 63 | .B mdadm |
e0d19036 | 64 | can provide information about your arrays (through Query, Detail, and Examine) |
cd29a5c8 NB |
65 | that |
66 | .B raidtools | |
67 | cannot. | |
5787fa49 NB |
68 | .P |
69 | .I mdadm | |
70 | does not use | |
71 | .IR /etc/raidtab , | |
72 | the | |
73 | .B raidtools | |
74 | configuration file, at all. It has a different configuration file | |
75 | with a different format and an different purpose. | |
52826846 NB |
76 | |
77 | .SH MODES | |
e0d19036 | 78 | mdadm has 6 major modes of operation: |
cd29a5c8 NB |
79 | .TP |
80 | .B Assemble | |
81 | Assemble the parts of a previously created | |
52826846 NB |
82 | array into an active array. Components can be explicitly given |
83 | or can be searched for. | |
9a9dab36 | 84 | .B mdadm |
cd29a5c8 NB |
85 | checks that the components |
86 | do form a bona fide array, and can, on request, fiddle superblock | |
87 | information so as to assemble a faulty array. | |
88 | ||
89 | .TP | |
90 | .B Build | |
91 | Build a legacy array without per-device superblocks. | |
92 | ||
93 | .TP | |
94 | .B Create | |
95 | Create a new array with per-device superblocks. | |
96 | '''It can progress | |
97 | '''in several step create-add-add-run or it can all happen with one command. | |
98 | ||
99 | .TP | |
e0d19036 NB |
100 | .B Manage |
101 | This is for doing things to specific components of an array such as | |
102 | adding new spares and removing faulty devices. | |
cd29a5c8 NB |
103 | |
104 | .TP | |
e0d19036 NB |
105 | .B Misc |
106 | This mode allows operations on independent devices such as examine MD | |
107 | superblocks, erasing old superblocks and stopping active arrays. | |
cd29a5c8 NB |
108 | |
109 | .TP | |
110 | .B "Follow or Monitor" | |
5787fa49 NB |
111 | Monitor one or more md devices and act on any state changes. This is |
112 | only meaningful for raid1, raid5 or multipath arrays as only these have | |
113 | interesting state. raid0 or linear never have missing, spare, or | |
114 | failed drives, so there is nothing to monitor. | |
115 | ||
cd29a5c8 | 116 | |
52826846 NB |
117 | .SH OPTIONS |
118 | ||
119 | Available options are: | |
120 | ||
cd29a5c8 NB |
121 | .TP |
122 | .BR -A ", " --assemble | |
2d465520 | 123 | Assemble a pre-existing array. |
52826846 | 124 | |
cd29a5c8 NB |
125 | .TP |
126 | .BR -B ", " --build | |
127 | Build a legacy array without superblocks. | |
52826846 | 128 | |
cd29a5c8 NB |
129 | .TP |
130 | .BR -C ", " --create | |
131 | Create a new array. | |
52826846 | 132 | |
e0d19036 NB |
133 | .TP |
134 | .BR -Q ", " --query | |
135 | Examine a device to see | |
136 | (1) if it is an md device and (2) if it is a component of an md | |
137 | array. | |
138 | Information about what is discovered is presented. | |
139 | ||
cd29a5c8 NB |
140 | .TP |
141 | .BR -D ", " --detail | |
142 | Print detail of one or more md devices. | |
52826846 | 143 | |
cd29a5c8 NB |
144 | .TP |
145 | .BR -E ", " --examine | |
146 | Print content of md superblock on device(s). | |
52826846 | 147 | |
cd29a5c8 NB |
148 | .TP |
149 | .BR -F ", " --follow ", " --monitor | |
150 | Select | |
151 | .B Monitor | |
152 | mode. | |
52826846 | 153 | |
cd29a5c8 NB |
154 | .TP |
155 | .BR -h ", " --help | |
56eedc1a NB |
156 | Display help message or, after above option, mode specific help |
157 | message. | |
158 | ||
159 | .TP | |
160 | .B --help-options | |
161 | Display more detailed help about command line parsing and some commonly | |
162 | used options. | |
52826846 | 163 | |
cd29a5c8 NB |
164 | .TP |
165 | .BR -V ", " --version | |
9a9dab36 | 166 | Print version information for mdadm. |
52826846 | 167 | |
cd29a5c8 NB |
168 | .TP |
169 | .BR -v ", " --verbose | |
170 | Be more verbose about what is happening. | |
52826846 | 171 | |
cd29a5c8 NB |
172 | .TP |
173 | .BR -b ", " --brief | |
174 | Be less verbose. This is used with | |
175 | .B --detail | |
176 | and | |
177 | .BR --examine . | |
52826846 | 178 | |
e0d19036 NB |
179 | .TP |
180 | .BR -f ", " --force | |
181 | Be more forceful about certain operations. See the various modes of | |
182 | the exact meaning of this option in different contexts. | |
183 | ||
184 | .TP | |
185 | .BR -c ", " --config= | |
186 | Specify the config file. Default is | |
187 | .BR /etc/mdadm.conf . | |
5787fa49 NB |
188 | If the config file given is |
189 | .B partitions | |
190 | then nothing will be read, but | |
191 | .I mdadm | |
192 | will act as though the config file contained exactly | |
193 | .B "DEVICE partitions" | |
194 | and will read | |
195 | .B /proc/partitions | |
196 | to find a list of devices to scan. | |
d013a55e NB |
197 | If the word |
198 | .B none | |
199 | is given for the config file, then | |
200 | .I mdadm | |
201 | will act as though the config file were empty. | |
e0d19036 NB |
202 | |
203 | .TP | |
204 | .BR -s ", " --scan | |
205 | scan config file or | |
206 | .B /proc/mdstat | |
207 | for missing information. | |
208 | In general, this option gives | |
209 | .B mdadm | |
210 | permission to get any missing information, like component devices, | |
211 | array devices, array identities, and alert destination from the | |
212 | configuration file: | |
213 | .BR /etc/mdadm.conf . | |
214 | One exception is MISC mode when using | |
215 | .B --detail | |
216 | or | |
217 | .B --stop | |
218 | in which case | |
219 | .B --scan | |
220 | says to get a list of array devices from | |
221 | .BR /proc/mdstat . | |
222 | ||
cd29a5c8 | 223 | .SH For create or build: |
52826846 | 224 | |
cd29a5c8 NB |
225 | .TP |
226 | .BR -c ", " --chunk= | |
227 | Specify chunk size of kibibytes. The default is 64. | |
52826846 | 228 | |
cd29a5c8 NB |
229 | .TP |
230 | .BR --rounding= | |
231 | Specify rounding factor for linear array (==chunk size) | |
52826846 | 232 | |
cd29a5c8 NB |
233 | .TP |
234 | .BR -l ", " --level= | |
aa88f531 NB |
235 | Set raid level. When used with |
236 | .IR --create , | |
237 | options are: linear, raid0, 0, stripe, raid1, 1, mirror, raid5, 4, | |
c913b90e | 238 | raid5, 5, multipath, mp. Obviously some of these are synonymous. |
aa88f531 NB |
239 | |
240 | When used with | |
241 | .IR --build , | |
242 | only linear, raid0, 0, stripe are valid. | |
52826846 | 243 | |
cd29a5c8 NB |
244 | .TP |
245 | .BR -p ", " --parity= | |
246 | Set raid5 parity algorithm. Options are: | |
2d465520 NB |
247 | left-asymmetric, |
248 | left-symmetric, | |
249 | right-asymmetric, | |
250 | right-symmetric, | |
251 | la, ra, ls, rs. The default is left-symmetric. | |
52826846 | 252 | |
cd29a5c8 NB |
253 | .TP |
254 | .BR --layout= | |
255 | same as --parity | |
52826846 | 256 | |
cd29a5c8 | 257 | .TP |
b83d95f3 | 258 | .BR -n ", " --raid-devices= |
5787fa49 NB |
259 | Specify the number of active devices in the array. This, plus the |
260 | number of spare devices (see below) must equal the number of | |
261 | .I component-devices | |
d013a55e | 262 | (including "\fBmissing\fP" devices) |
aa88f531 NB |
263 | that are listed on the command line. Setting a value of 1 is probably |
264 | a mistake and so requires that | |
265 | .B --force | |
266 | be specified first. A value of 1 will then be allowed for linear, | |
267 | multipath, raid0 and raid1. It is never allowed for raid4 or raid5. | |
268 | .br | |
269 | Note that this number cannot be changed once the array has been created. | |
cd29a5c8 NB |
270 | |
271 | .TP | |
b83d95f3 | 272 | .BR -x ", " --spare-devices= |
5787fa49 NB |
273 | Specify the number of spare (eXtra) devices in the initial array. |
274 | Spares can also be added | |
275 | and removed later. The number of component devices listed | |
276 | on the command line must equal the number of raid devices plus the | |
277 | number of spare devices. | |
278 | ||
cd29a5c8 NB |
279 | |
280 | .TP | |
281 | .BR -z ", " --size= | |
282 | Amount (in Kibibytes) of space to use from each drive in RAID1/4/5. | |
283 | This must be a multiple of the chunk size, and must leave about 128Kb | |
284 | of space at the end of the drive for the RAID superblock. | |
285 | If this is not specified | |
286 | (as it normally is not) the smallest drive (or partition) sets the | |
287 | size, though if there is a variance among the drives of greater than 1%, a warning is | |
288 | issued. | |
52826846 NB |
289 | |
290 | .SH For assemble: | |
291 | ||
cd29a5c8 NB |
292 | .TP |
293 | .BR -u ", " --uuid= | |
294 | uuid of array to assemble. Devices which don't have this uuid are | |
295 | excluded | |
296 | ||
297 | .TP | |
298 | .BR -m ", " --super-minor= | |
299 | Minor number of device that array was created for. Devices which | |
300 | don't have this minor number are excluded. If you create an array as | |
2d465520 | 301 | /dev/md1, then all superblocks will contain the minor number 1, even if |
cd29a5c8 NB |
302 | the array is later assembled as /dev/md2. |
303 | ||
d013a55e NB |
304 | Giving the literal word "dev" for |
305 | .B --super-minor | |
306 | will cause | |
307 | .I mdadm | |
308 | to use the minor number of the md device that is being assembled. | |
309 | e.g. when assembling | |
310 | .BR /dev/md0 , | |
311 | .M --super-minor=dev | |
312 | will look for super blocks with a minor number of 0. | |
313 | ||
cd29a5c8 NB |
314 | .TP |
315 | .BR -f ", " --force | |
52826846 NB |
316 | Assemble the array even if some superblocks appear out-of-date |
317 | ||
cd29a5c8 NB |
318 | .TP |
319 | .BR -R ", " --run | |
320 | Attempt to start the array even if fewer drives were given than are | |
321 | needed for a full array. Normally if not all drives are found and | |
322 | .B --scan | |
323 | is not used, then the array will be assembled but not started. | |
324 | With | |
325 | .B --run | |
326 | an attempt will be made to start it anyway. | |
52826846 | 327 | |
5787fa49 NB |
328 | .TP |
329 | .BR -U ", " --update= | |
330 | Update the superblock on each device while assembling the array. The | |
feb716e9 NB |
331 | argument given to this flag can be one of |
332 | .BR sparc2.2 , | |
333 | .BR summaries , | |
5787fa49 NB |
334 | or |
335 | .BR super-minor . | |
336 | ||
337 | The | |
338 | .B sparc2.2 | |
339 | option will adjust the superblock of an array what was created on a Sparc | |
340 | machine running a patched 2.2 Linux kernel. This kernel got the | |
341 | alignment of part of the superblock wrong. You can use the | |
342 | .B "--examine --sparc2.2" | |
343 | option to | |
344 | .I mdadm | |
345 | to see what effect this would have. | |
346 | ||
347 | The | |
348 | .B super-minor | |
349 | option will update the | |
350 | .B "prefered minor" | |
351 | field on each superblock to match the minor number of the array being | |
feb716e9 | 352 | assembled. This is not needed on 2.6 and later kernels as they make |
5787fa49 NB |
353 | this adjustment automatically. |
354 | ||
feb716e9 NB |
355 | The |
356 | .B summaries | |
357 | option will correct the summaries in the superblock. That is the | |
358 | counts of total, working, active, failed, and spare devices. | |
5787fa49 | 359 | |
e0d19036 | 360 | .SH For Manage mode: |
52826846 | 361 | |
cd29a5c8 NB |
362 | .TP |
363 | .BR -a ", " --add | |
364 | '''add, or | |
365 | hotadd listed devices. | |
52826846 | 366 | |
cd29a5c8 NB |
367 | .TP |
368 | .BR -r ", " --remove | |
2d465520 | 369 | remove listed devices. They must not be active. i.e. they should |
cd29a5c8 | 370 | be failed or spare devices. |
52826846 | 371 | |
cd29a5c8 NB |
372 | .TP |
373 | .BR -f ", " --fail | |
374 | mark listed devices as faulty. | |
52826846 | 375 | |
cd29a5c8 NB |
376 | .TP |
377 | .BR --set-faulty | |
378 | same as --fail. | |
52826846 | 379 | |
5787fa49 NB |
380 | .SH For Examine mode: |
381 | ||
382 | .TP | |
383 | .B --sparc2.2 | |
384 | In an array was created on a 2.2 Linux kernel patched with RAID | |
385 | support, the superblock will have been created incorrectly, or at | |
386 | least incompatibly with 2.4 and later kernels. Using the | |
387 | .B --sparc2.2 | |
388 | flag with | |
389 | .B --examine | |
390 | will fix the superblock before displaying it. If this appears to do | |
391 | the right thing, then the array can be successfully assembled using | |
392 | .BR "--assemble --update=sparc2.2" . | |
393 | ||
e0d19036 NB |
394 | .SH For Misc mode: |
395 | ||
cd29a5c8 NB |
396 | .TP |
397 | .BR -R ", " --run | |
398 | start a partially built array. | |
52826846 | 399 | |
cd29a5c8 NB |
400 | .TP |
401 | .BR -S ", " --stop | |
402 | deactivate array, releasing all resources. | |
52826846 | 403 | |
cd29a5c8 NB |
404 | .TP |
405 | .BR -o ", " --readonly | |
406 | mark array as readonly. | |
52826846 | 407 | |
cd29a5c8 NB |
408 | .TP |
409 | .BR -w ", " --readwrite | |
410 | mark array as readwrite. | |
52826846 | 411 | |
e0d19036 NB |
412 | .TP |
413 | .B --zero-superblock | |
414 | If the device contains a valid md superblock, the block is | |
415 | over-written with zeros. With | |
416 | --force | |
417 | the block where the superblock would be is over-written even if it | |
418 | doesn't appear to be valid. | |
52826846 | 419 | |
feb716e9 NB |
420 | .TP |
421 | .BR -t ", " --test | |
422 | When used with | |
423 | .BR --detail , | |
424 | the exit status of | |
425 | .I mdadm | |
426 | is set to reflect the status of the device. | |
427 | ||
e0d19036 NB |
428 | .SH For Monitor mode: |
429 | .TP | |
430 | .BR -m ", " --mail | |
431 | Give a mail address to send alerts to. | |
432 | ||
433 | .TP | |
434 | .BR -p ", " --program ", " --alert | |
435 | Give a program to be run whenever an event is detected. | |
436 | ||
437 | .TP | |
438 | .BR -d ", " --delay | |
439 | Give a delay in seconds. | |
440 | .B mdadm | |
441 | polls the md arrays and then waits this many seconds before polling | |
442 | again. The default is 60 seconds. | |
443 | ||
d013a55e NB |
444 | .TP |
445 | .BR -f ", " --daemonise | |
446 | Tell | |
447 | .B mdadm | |
448 | to run as a background daemon if it decides to monitor anything. This | |
449 | causes it to fork and run in the child, and to disconnect form the | |
450 | terminal. The process id of the child is written to stdout. | |
451 | This is useful with | |
452 | .B --scan | |
453 | which will only continue monitoring if a mail address or alert program | |
454 | is found in the config file. | |
455 | ||
aa88f531 NB |
456 | .TP |
457 | .BR -1 ", " --oneshot | |
458 | Check arrays only once. This will generate | |
459 | .B NewArray | |
460 | events and more significantly | |
461 | .B DegradedArray | |
462 | events. Running | |
463 | .in +5 | |
464 | .B " mdadm --monitor --scan -1" | |
465 | .in -5 | |
466 | from a cron script will ensure regular notification of any degraded arrays. | |
467 | ||
e0d19036 | 468 | .SH ASSEMBLE MODE |
52826846 | 469 | |
cd29a5c8 NB |
470 | .HP 12 |
471 | Usage: | |
9a9dab36 | 472 | .B mdadm --assemble |
5787fa49 NB |
473 | .I md-device options-and-component-devices... |
474 | .HP 12 | |
475 | Usage: | |
476 | .B mdadm --assemble --scan | |
477 | .I md-devices-and-options... | |
cd29a5c8 NB |
478 | .HP 12 |
479 | Usage: | |
9a9dab36 | 480 | .B mdadm --assemble --scan |
cd29a5c8 | 481 | .I options... |
52826846 | 482 | |
cd29a5c8 | 483 | .PP |
52826846 | 484 | This usage assembles one or more raid arrays from pre-existing components. |
9a9dab36 | 485 | For each array, mdadm needs to know the md device, the identity of the |
e0d19036 | 486 | array, and a number of component-devices. These can be found in a number of ways. |
52826846 | 487 | |
5787fa49 NB |
488 | In the first usage example (without the |
489 | .BR --scan ) | |
490 | the first device given is the md device. | |
491 | In the second usage example, all devices listed are treated as md | |
492 | devices and assembly is attempted. | |
493 | In the third (where no devices are listed) all md devices that are | |
494 | listed in the configuration file are assembled. | |
52826846 | 495 | |
d013a55e NB |
496 | If precisely one device is listed, but |
497 | .B --scan | |
498 | is not given, that | |
499 | .I mdadm | |
500 | acts as though | |
501 | .B --scan | |
502 | was given and identify information is extracted from the configuration file. | |
503 | ||
cd29a5c8 | 504 | The identity can be given with the |
52826846 | 505 | .B --uuid |
cd29a5c8 NB |
506 | option, with the |
507 | .B --super-minor | |
5787fa49 | 508 | option, can be found in the config file, or will be taken from the |
e0d19036 | 509 | super block on the first component-device listed on the command line. |
52826846 NB |
510 | |
511 | Devices can be given on the | |
512 | .B --assemble | |
5787fa49 NB |
513 | command line or in the config file. Only devices which have an md |
514 | superblock which contains the right identity will be considered for | |
515 | any array. | |
52826846 NB |
516 | |
517 | The config file is only used if explicitly named with | |
518 | .B --config | |
d013a55e | 519 | or requested with (a possibly implicit) |
52826846 NB |
520 | .B --scan. |
521 | In the later case, | |
9a9dab36 | 522 | .B /etc/mdadm.conf |
52826846 NB |
523 | is used. |
524 | ||
525 | If | |
526 | .B --scan | |
cd29a5c8 NB |
527 | is not given, then the config file will only be used to find the |
528 | identity of md arrays. | |
52826846 | 529 | |
2d465520 | 530 | Normally the array will be started after it is assembled. However if |
cd29a5c8 | 531 | .B --scan |
2d465520 | 532 | is not given and insufficient drives were listed to start a complete |
cd29a5c8 NB |
533 | (non-degraded) array, then the array is not started (to guard against |
534 | usage errors). To insist that the array be started in this case (as | |
535 | may work for RAID1 or RAID5), give the | |
536 | .B --run | |
537 | flag. | |
52826846 | 538 | |
52826846 | 539 | |
cd29a5c8 | 540 | .SH BUILD MODE |
52826846 | 541 | |
cd29a5c8 NB |
542 | .HP 12 |
543 | Usage: | |
9a9dab36 | 544 | .B mdadm --build |
cd29a5c8 NB |
545 | .I device |
546 | .BI --chunk= X | |
547 | .BI --level= Y | |
b83d95f3 | 548 | .BI --raid-devices= Z |
cd29a5c8 NB |
549 | .I devices |
550 | ||
551 | .PP | |
52826846 | 552 | This usage is similar to |
cd29a5c8 | 553 | .BR --create . |
52826846 | 554 | The difference is that it creates a legacy array without a superblock. With |
cd29a5c8 | 555 | these arrays there is no difference between initially creating the array and |
52826846 NB |
556 | subsequently assembling the array, except that hopefully there is useful |
557 | data there in the second case. | |
558 | ||
cd29a5c8 NB |
559 | The level may only be 0, raid0, or linear. All devices must be listed |
560 | and the array will be started once complete. | |
561 | ||
562 | .SH CREATE MODE | |
563 | ||
564 | .HP 12 | |
565 | Usage: | |
9a9dab36 | 566 | .B mdadm --create |
cd29a5c8 NB |
567 | .I device |
568 | .BI --chunk= X | |
569 | .BI --level= Y | |
570 | .br | |
b83d95f3 | 571 | .BI --raid-devices= Z |
cd29a5c8 NB |
572 | .I devices |
573 | ||
574 | .PP | |
575 | This usage will initialise a new md array, associate some devices with | |
576 | it, and activate the array. | |
577 | ||
578 | As devices are added, they are checked to see if they contain raid | |
2d465520 | 579 | superblocks or filesystems. They are also checked to see if the variance in |
cd29a5c8 NB |
580 | device size exceeds 1%. |
581 | ||
582 | If any discrepancy is found, the array will not automatically be run, though | |
583 | the presence of a | |
584 | .B --run | |
585 | can override this caution. | |
586 | ||
2d465520 | 587 | To create a "degraded" array in which some devices are missing, simply |
d013a55e | 588 | give the word "\fBmissing\fP" |
2d465520 NB |
589 | in place of a device name. This will cause |
590 | .B mdadm | |
591 | to leave the corresponding slot in the array empty. | |
592 | For a RAID4 or RAID5 array at most one slot can be | |
d013a55e | 593 | "\fBmissing\fP". |
2d465520 NB |
594 | For a RAID1 array, only one real device needs to be given. All of the |
595 | others can be | |
d013a55e | 596 | "\fBmissing\fP". |
2d465520 | 597 | |
feb716e9 NB |
598 | When creating a RAID5 array, |
599 | .B mdadm | |
600 | will automatically create a degraded array with an extra spare drive. | |
601 | This is because building the spare into a degraded array is in general faster than resyncing | |
602 | the parity on a non-degraded, but not clean, array. This feature can | |
603 | be over-ridden with the | |
604 | -I --force | |
605 | option. | |
606 | ||
cd29a5c8 NB |
607 | '''If the |
608 | '''.B --size | |
e0d19036 | 609 | '''option is given, it is not necessary to list any component-devices in this command. |
cd29a5c8 NB |
610 | '''They can be added later, before a |
611 | '''.B --run. | |
612 | '''If no | |
613 | '''.B --size | |
614 | '''is given, the apparent size of the smallest drive given is used. | |
615 | ||
616 | The General Management options that are valid with --create are: | |
617 | .TP | |
618 | .B --run | |
619 | insist of running the array even if some devices look like they might | |
620 | be in use. | |
621 | ||
622 | .TP | |
623 | .B --readonly | |
624 | start the array readonly - not supported yet. | |
52826846 | 625 | |
e0d19036 | 626 | .SH MANAGE MODE |
cd29a5c8 NB |
627 | .HP 12 |
628 | Usage: | |
e0d19036 NB |
629 | .B mdadm |
630 | .I device | |
631 | .I options... devices... | |
cd29a5c8 NB |
632 | .PP |
633 | ||
e0d19036 NB |
634 | This usage will allow individual devices in an array to be failed, |
635 | removed or added. It is possible to perform multiple operations with | |
636 | on command. For example: | |
637 | .br | |
5787fa49 | 638 | .B " mdadm /dev/md0 -f /dev/hda1 -r /dev/hda1 -a /dev/hda1" |
e0d19036 NB |
639 | .br |
640 | will firstly mark | |
641 | .B /dev/hda1 | |
642 | as faulty in | |
643 | .B /dev/md0 | |
644 | and will then remove it from the array and finally add it back | |
2d465520 | 645 | in as a spare. However only one md array can be affected by a single |
e0d19036 NB |
646 | command. |
647 | ||
648 | .SH MISC MODE | |
649 | .HP 12 | |
650 | Usage: | |
9a9dab36 | 651 | .B mdadm |
e0d19036 NB |
652 | .I options ... |
653 | .I devices ... | |
654 | .PP | |
cd29a5c8 | 655 | |
e0d19036 NB |
656 | MISC mode includes a number if distinct operations that |
657 | operate on distinct devices. The operations are: | |
658 | .TP | |
659 | --query | |
660 | The device is examined to see if it is | |
661 | (1) an active md array, or | |
662 | (2) a component of an md array. | |
663 | The information discovered is reported. | |
664 | ||
665 | .TP | |
666 | --detail | |
2d465520 NB |
667 | The device should be an active md device. |
668 | .B mdadm | |
669 | will display a detailed description of the array. | |
cd29a5c8 | 670 | .B --brief |
2d465520 NB |
671 | or |
672 | .B --scan | |
673 | will cause the output to be less detailed and the format to be | |
e0d19036 | 674 | suitable for inclusion in |
9a9dab36 | 675 | .BR /etc/mdadm.conf . |
feb716e9 NB |
676 | The exit status of |
677 | .I mdadm | |
678 | will normally be 0 unless | |
679 | .I mdadm | |
680 | failed to get useful information about the device(s). However if the | |
681 | .B --test | |
682 | option is given, then the exit status will be: | |
683 | .RS | |
684 | .TP | |
685 | 0 | |
686 | The array is functioning normally. | |
687 | .TP | |
688 | 1 | |
689 | The array has at least one failed device. | |
690 | .TP | |
691 | 2 | |
692 | The array has multiple failed devices and hence is unusable (raid4 or | |
693 | raid5). | |
694 | .TP | |
695 | 4 | |
696 | There was an error while trying to get information about the device. | |
697 | .RE | |
cd29a5c8 | 698 | |
e0d19036 NB |
699 | .TP |
700 | --examine | |
2d465520 NB |
701 | The device should be a component of an md array. |
702 | .B mdadm | |
703 | will read the md superblock of the device and display the contents. | |
e0d19036 NB |
704 | If |
705 | .B --brief | |
706 | is given, or | |
707 | .B --scan | |
708 | then multiple devices that are components of the one array | |
709 | are grouped together and reported in a single entry suitable | |
710 | for inclusion in | |
711 | .BR /etc/mdadm.conf . | |
712 | ||
2d465520 | 713 | Having |
e0d19036 NB |
714 | .B --scan |
715 | without listing any devices will cause all devices listed in the | |
716 | config file to be examined. | |
717 | ||
718 | .TP | |
719 | --stop | |
720 | This devices should active md arrays which will be deactivated, if | |
721 | they are not currently in use. | |
722 | ||
723 | .TP | |
724 | --run | |
725 | This will fully activate a partially assembled md array. | |
726 | ||
727 | .TP | |
728 | --readonly | |
729 | This will mark an active array as read-only, providing that it is | |
730 | not currently being used. | |
731 | ||
732 | .TP | |
733 | --readwrite | |
734 | This will change a | |
735 | .B readonly | |
736 | array back to being read/write. | |
737 | ||
2d465520 NB |
738 | .TP |
739 | --scan | |
740 | For all operations except | |
741 | .BR --examine , | |
742 | .B --scan | |
743 | will cause the operation to be applied to all arrays listed in | |
744 | .BR /proc/mdstat . | |
745 | For | |
746 | .BR --examine, | |
747 | .B --scan | |
748 | causes all devices listed in the config file to be examined. | |
749 | ||
750 | ||
e0d19036 NB |
751 | .SH MONITOR MODE |
752 | ||
cd29a5c8 NB |
753 | .HP 12 |
754 | Usage: | |
e0d19036 NB |
755 | .B mdadm --monitor |
756 | .I options... devices... | |
757 | ||
cd29a5c8 | 758 | .PP |
e0d19036 NB |
759 | This usage causes |
760 | .B mdadm | |
761 | to periodically poll a number of md arrays and to report on any events | |
762 | noticed. | |
763 | .B mdadm | |
764 | will never exit once it decides that there are arrays to be checked, | |
765 | so it should normally be run in the background. | |
766 | ||
2d465520 NB |
767 | As well as reporting events, |
768 | .B mdadm | |
769 | may move a spare drive from one array to another if they are in the | |
770 | same | |
771 | .B spare-group | |
772 | and if the destination array has a failed drive but not spares. | |
773 | ||
e0d19036 NB |
774 | If any devices are listed on the command line, |
775 | .B mdadm | |
776 | will only monitor those devices. Otherwise all arrays listed in the | |
777 | configuration file will be monitored. Further, if | |
778 | .B --scan | |
779 | is given, then any other md devices that appear in | |
780 | .B /proc/mdstat | |
781 | will also be monitored. | |
782 | ||
783 | The result of monitoring the arrays is the generation of events. | |
bd526cee | 784 | These events are passed to a separate program (if specified) and may |
2d465520 | 785 | be mailed to a given E-mail address. |
e0d19036 | 786 | |
bd526cee NB |
787 | When passing event to program, the program is run once for each event |
788 | and is given 2 or 3 command-line arguements. The first is the | |
789 | name of the event (see below). The second is the name of the | |
790 | md device which is affected, and the third is the name of a related | |
791 | device if relevant, such as a component device that has failed. | |
cd29a5c8 NB |
792 | |
793 | If | |
794 | .B --scan | |
e0d19036 NB |
795 | is given, then a program or an E-mail address must be specified on the |
796 | command line or in the config file. If neither are available, then | |
797 | .B mdadm | |
798 | will not monitor anything. | |
799 | Without | |
cd29a5c8 | 800 | .B --scan |
e0d19036 | 801 | .B mdadm |
2d465520 | 802 | will continue monitoring as long as something was found to monitor. If |
e0d19036 NB |
803 | no program or email is given, then each event is reported to |
804 | .BR stdout . | |
cd29a5c8 | 805 | |
e0d19036 NB |
806 | The different events are: |
807 | ||
808 | .RS 4 | |
809 | .TP | |
810 | .B DeviceDisappeared | |
2d465520 | 811 | An md array which previously was configured appears to no longer be |
e0d19036 NB |
812 | configured. |
813 | ||
814 | .TP | |
815 | .B RebuildStarted | |
816 | An md array started reconstruction. | |
817 | ||
818 | .TP | |
819 | .BI Rebuild NN | |
820 | Where | |
821 | .I NN | |
822 | is 20, 40, 60, or 80, this indicates that rebuild has passed that many | |
823 | percentage of the total. | |
824 | ||
825 | .TP | |
826 | .B Fail | |
827 | An active component device of an array has been marked as faulty. | |
828 | ||
829 | .TP | |
830 | .B FailSpare | |
831 | A spare component device which was being rebuilt to replace a faulty | |
832 | device has failed. | |
833 | ||
834 | .TP | |
835 | .B SpareActive | |
836 | A spare component device which was being rebuilt to replace a faulty | |
837 | device as been successfully rebuild and has been made active. | |
838 | ||
839 | .TP | |
840 | .B NewArray | |
841 | A new md array has been detected in the | |
842 | .B /proc/mdstat | |
843 | file. | |
844 | ||
aa88f531 NB |
845 | .TP |
846 | .B DegradedArray | |
847 | A newly noticed array appears to be degraded. This message is not | |
848 | generated when | |
849 | .I mdadm | |
850 | notices a drive failure which causes degradation, but only when | |
851 | .I mdadm | |
852 | notices that an array is degraded when it first sees the array. | |
853 | ||
e0d19036 NB |
854 | .TP |
855 | .B MoveSpare | |
856 | A spare drive has been moved from one array in a | |
857 | .B spare-group | |
858 | to another to allow a failed drive to be replaced. | |
859 | ||
860 | .RE | |
861 | ||
862 | Only | |
863 | .B Fail | |
864 | and | |
865 | .B FailSpare | |
866 | cause Email to be sent. All events cause the program to be run. | |
867 | The program is run with two or three arguments, they being the event | |
868 | name, the array device and possibly a second device. | |
869 | ||
870 | Each event has an associated array device (e.g. | |
871 | .BR /dev/md1 ) | |
872 | and possibly a second device. For | |
873 | .BR Fail , | |
874 | .BR FailSpare , | |
875 | and | |
876 | .B SpareActive | |
877 | the second device is the relevant component device. | |
878 | For | |
879 | .B MoveSpare | |
880 | the second device is the array that the spare was moved from. | |
881 | ||
882 | For | |
883 | .B mdadm | |
884 | to move spares from one array to another, the different arrays need to | |
885 | be labelled with the same | |
886 | .B spare-group | |
887 | in the configuration file. The | |
888 | .B spare-group | |
889 | name can be any string. It is only necessary that different spare | |
2d465520 | 890 | groups use different names. |
e0d19036 NB |
891 | |
892 | When | |
9a9dab36 | 893 | .B mdadm |
e0d19036 NB |
894 | detects that an array which is in a spare group has fewer active |
895 | devices than necessary for the complete array, and has no spare | |
896 | devices, it will look for another array in the same spare group that | |
897 | has a full complement of working drive and a spare. It will then | |
898 | attempt to remove the spare from the second drive and add it to the | |
899 | first. | |
900 | If the removal succeeds but the adding fails, then it is added back to | |
901 | the original array. | |
902 | ||
2d465520 NB |
903 | .SH EXAMPLES |
904 | ||
5787fa49 | 905 | .B " mdadm --query /dev/name-of-device" |
2d465520 | 906 | .br |
5787fa49 NB |
907 | This will find out if a given device is a raid array, or is part of |
908 | one, and will provide brief information about the device. | |
2d465520 | 909 | |
5787fa49 | 910 | .B " mdadm --assemble --scan" |
2d465520 | 911 | .br |
5787fa49 NB |
912 | This will assemble and start all arrays listed in the standard confile |
913 | file. This command will typically go in a system startup file. | |
2d465520 | 914 | |
2d465520 | 915 | .B " mdadm --stop --scan" |
5787fa49 NB |
916 | .br |
917 | This will shut down all array that can be shut down (i.e. are not | |
918 | currently in used). This will typically going in a system shutdown script. | |
2d465520 | 919 | |
5787fa49 | 920 | .B " mdadm --follow --scan --delay=120" |
2d465520 | 921 | .br |
5787fa49 NB |
922 | If (and only if) there is an Email address or program given in the |
923 | standard config file, then | |
924 | monitor the status of all arrays listed in that file by | |
925 | polling them ever 2 minutes. | |
2d465520 | 926 | |
5787fa49 | 927 | .B " mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[ac]1" |
2d465520 | 928 | .br |
5787fa49 | 929 | Create /dev/md0 as a RAID1 array consisting of /dev/hda1 and /dev/hdc1. |
2d465520 | 930 | |
2d465520 NB |
931 | .br |
932 | .B " echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > mdadm.conf" | |
933 | .br | |
934 | .B " mdadm --detail --scan >> mdadm.conf" | |
935 | .br | |
5787fa49 NB |
936 | This will create a prototype config file that describes currently |
937 | active arrays that are known to be made from partitions of IDE or SCSI drives. | |
2d465520 NB |
938 | This file should be reviewed before being used as it may |
939 | contain unwanted detail. | |
940 | ||
2d465520 NB |
941 | .B " echo 'DEVICE /dev/hd[a-z] /dev/sd*[a-z]' > mdadm.conf" |
942 | .br | |
5787fa49 NB |
943 | .B " mdadm --examine --scan --config=mdadm.conf >> mdadm.conf" |
944 | .ber | |
945 | This will find what arrays could be assembled from existign IDE and | |
946 | SCSI whole drives (not partitions) and store the information is the | |
947 | format of a config file. | |
2d465520 NB |
948 | This file is very likely to contain unwanted detail, particularly |
949 | the | |
950 | .B devices= | |
5787fa49 NB |
951 | entries. It should be reviewed and edited before being used as an |
952 | actual config file. | |
2d465520 | 953 | |
5787fa49 | 954 | .B " mdadm --examine --brief --scan --config=partitions" |
2d465520 | 955 | .br |
5787fa49 NB |
956 | .B " mdadm -Ebsc partitions" |
957 | .br | |
958 | Create a list of devices by reading | |
959 | .BR /proc/partitions , | |
960 | scan these for RAID superblocks, and printout a brief listing of all | |
961 | that was found. | |
2d465520 | 962 | |
5787fa49 | 963 | .B " mdadm -Ac partitions -m 0 /dev/md0" |
2d465520 | 964 | .br |
5787fa49 NB |
965 | Scan all partitions and devices listed in |
966 | .BR /proc/partitions | |
967 | and assemble | |
968 | .B /dev/md0 | |
969 | out of all such devices with a RAID superblock with a minor number of 0. | |
2d465520 | 970 | |
d013a55e NB |
971 | .B " mdadm --monitor --scan --daemonise > /var/run/mdadm" |
972 | .br | |
973 | If config file contains a mail address or alert program, run mdadm in | |
974 | the background in monitor mode monitoring all md devices. Also write | |
975 | pid of mdadm daemon to | |
976 | .BR /var/run/mdadm . | |
977 | ||
5787fa49 | 978 | .B " mdadm --create --help" |
2d465520 | 979 | .br |
5787fa49 | 980 | Providew help about the Create mode. |
2d465520 | 981 | |
5787fa49 NB |
982 | .B " mdadm --config --help" |
983 | .br | |
984 | Provide help about the format of the config file. | |
2d465520 | 985 | |
5787fa49 NB |
986 | .B " mdadm --help" |
987 | .br | |
988 | Provide general help. | |
cd29a5c8 | 989 | |
cd29a5c8 NB |
990 | |
991 | .SH FILES | |
992 | ||
993 | .SS /proc/mdstat | |
994 | ||
995 | If you're using the | |
996 | .B /proc | |
997 | filesystem, | |
998 | .B /proc/mdstat | |
2d465520 NB |
999 | lists all active md devices with information about them. |
1000 | .B mdadm | |
1001 | uses this to find arrays when | |
1002 | .B --scan | |
1003 | is given in Misc mode, and to monitor array reconstruction | |
1004 | on Monitor mode. | |
1005 | ||
cd29a5c8 | 1006 | |
9a9dab36 | 1007 | .SS /etc/mdadm.conf |
cd29a5c8 | 1008 | |
11a3e71d NB |
1009 | The config file lists which devices may be scanned to see if |
1010 | they contain MD super block, and gives identifying information | |
1011 | (e.g. UUID) about known MD arrays. See | |
1012 | .BR mdadm.conf (5) | |
1013 | for more details. | |
cd29a5c8 | 1014 | |
52826846 | 1015 | |
2d465520 NB |
1016 | .SH NOTE |
1017 | .B mdadm | |
1018 | was previously known as | |
1019 | .BR mdctl . | |
1020 | ||
52826846 | 1021 | .SH SEE ALSO |
cd29a5c8 NB |
1022 | For information on the various levels of |
1023 | RAID, check out: | |
1024 | ||
1025 | .IP | |
1026 | .UR http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ | |
1027 | http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/ | |
1028 | .UE | |
1029 | .PP | |
1030 | for new releases of the RAID driver check out: | |
1031 | ||
1032 | .IP | |
1033 | .UR ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches | |
1034 | ftp://ftp.kernel.org/pub/linux/kernel/people/mingo/raid-patches | |
1035 | .UE | |
1036 | .PP | |
1037 | or | |
1038 | .IP | |
1039 | .UR http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/ | |
1040 | http://www.cse.unsw.edu.au/~neilb/patches/linux-stable/ | |
1041 | .URk | |
1042 | .PP | |
56eb10c0 NB |
1043 | .BR mdadm.conf (5), |
1044 | .BR md (4). | |
1045 | .PP | |
52826846 NB |
1046 | .IR raidtab (5), |
1047 | .IR raid0run (8), | |
1048 | .IR raidstop (8), | |
1049 | .IR mkraid (8) |