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