2 * mdadm - manage Linux "md" devices aka RAID arrays.
4 * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Email: <neilb@cse.unsw.edu.au>
24 * School of Computer Science and Engineering
25 * The University of New South Wales
32 char Version
[] = Name
" - v2.6 - 21 December 2006\n";
37 * This file contains general comments about the implementation
38 * and the various usage messages that can be displayed by mdadm
40 * mdadm is a single program that can be used to control Linux md devices.
41 * It is intended to provide all the functionality of the mdtools and
42 * raidtools but with a very different interface.
43 * mdadm can perform all functions without a configuration file.
44 * There is the option of using a configuration file, but not in the same
45 * way that raidtools uses one
46 * raidtools uses a configuration file to describe how to create a RAID
47 * array, and also uses this file partially to start a previously
48 * created RAID array. Further, raidtools requires the configuration
49 * file for such things as stopping a raid array which needs to know
50 * nothing about the array.
52 * The configuration file that can be used by mdadm lists two
54 * 1/ a mapping from uuid to md device to identify which arrays are
55 * expect and what names (numbers) they should be given
56 * 2/ a list of devices that should be scanned for md sub-devices
62 * mdadm has 7 major modes of operation:
64 * This mode is used to create a new array with a superblock
65 * It can progress in several step create-add-add-run
66 * or it can all happen with one command
68 * This mode is used to assemble the parts of a previously created
69 * array into an active array. Components can be explicitly given
70 * or can be searched for. mdadm (optionally) check that the components
71 * do form a bona-fide array, and can, on request, fiddle superblock
72 * version numbers so as to assemble a faulty array.
74 * This is for building legacy arrays without superblocks
76 * This is for doing something to one or more devices
77 * in an array, such as add,remove,fail.
78 * run/stop/readonly/readwrite are also available
80 * This is for doing things to individual devices.
81 * They might be parts of an array so
82 * zero-superblock, examine might be appropriate
83 * They might be md arrays so
84 * run,stop,rw,ro,detail might be appropriate
85 * Also query will treat it as either
87 * This mode never exits but just monitors arrays and reports changes.
89 * This mode allows for changing of key attributes of a raid array, such
90 * as size, number of devices, and possibly even layout.
91 * At the time if writing, there is only minimal support.
94 char short_options
[]="-ABCDEFGIQhVXWvqbc:i:l:p:m:n:x:u:c:d:z:U:sarfRSow1tye:";
95 char short_bitmap_auto_options
[]=
96 "-ABCDEFGIQhVXWvqb:c:i:l:p:m:n:x:u:c:d:z:U:sa:rfRSow1tye:";
98 struct option long_options
[] = {
99 {"manage", 0, 0, '@'},
101 {"assemble", 0, 0, 'A'},
102 {"build", 0, 0, 'B'},
103 {"create", 0, 0, 'C'},
104 {"detail", 0, 0, 'D'},
105 {"examine", 0, 0, 'E'},
106 {"follow", 0, 0, 'F'},
108 {"incremental",0,0, 'I'},
109 {"zero-superblock", 0, 0, 'K'}, /* deliberately no a short_option */
110 {"query", 0, 0, 'Q'},
111 {"examine-bitmap", 0, 0, 'X'},
114 {"monitor", 0, 0, 'F'},
116 /* after those will normally come the name of the md device */
118 {"help-options",0,0,'h'},
119 {"version", 0, 0, 'V'},
120 {"verbose", 0, 0, 'v'},
121 {"quiet", 0, 0, 'q'},
123 /* For create or build: */
124 {"chunk", 1, 0, 'c'},
125 {"rounding", 1, 0, 'c'}, /* for linear, chunk is really a rounding number */
126 {"level", 1, 0, 'l'}, /* 0,1,4,5,6,linear */
127 {"parity", 1, 0, 'p'}, /* {left,right}-{a,}symmetric */
128 {"layout", 1, 0, 'p'},
129 {"raid-disks",1, 0, 'n'},
130 {"raid-devices",1, 0, 'n'},
131 {"spare-disks",1,0, 'x'},
132 {"spare-devices",1,0, 'x'},
134 {"auto", 1, 0, 'a'}, /* also for --assemble */
135 {"assume-clean",0,0, AssumeClean
},
136 {"metadata", 1, 0, 'e'}, /* superblock format */
137 {"bitmap", 1, 0, 'b'},
138 {"bitmap-chunk", 1, 0, BitmapChunk
},
139 {"write-behind", 2, 0, WriteBehind
},
140 {"write-mostly",0, 0, 'W'},
141 {"re-add", 0, 0, ReAdd
},
142 {"homehost", 1, 0, HomeHost
},
143 {"auto-update-homehost", 0, 0, AutoHomeHost
},
144 {"symlinks", 1, 0, Symlinks
},
148 {"super-minor",1,0, 'm'},
150 {"config", 1, 0, 'c'},
152 {"force", 0, 0, 'f'},
153 {"update", 1, 0, 'U'},
157 {"remove", 0, 0, 'r'},
159 {"set-faulty",0, 0, 'f'},
162 {"readonly", 0, 0, 'o'},
163 {"readwrite", 0, 0, 'w'},
164 {"no-degraded",0,0, NoDegraded
},
167 /* For Detail/Examine */
168 {"brief", 0, 0, 'b'},
169 {"sparc2.2", 0, 0, Sparc22
},
172 /* For Follow/monitor */
174 {"program", 1, 0, 'p'},
175 {"alert", 1, 0, 'p'},
176 {"delay", 1, 0, 'd'},
177 {"daemonise", 0, 0, 'f'},
178 {"daemonize", 0, 0, 'f'},
179 {"oneshot", 0, 0, '1'},
180 {"pid-file", 1, 0, 'i'},
181 {"syslog", 0, 0, 'y'},
183 {"backup-file", 1,0, BackupFile
},
185 /* For Incremental */
186 {"rebuild-map", 0, 0, 'r'},
191 "Usage: mdadm --help\n"
196 "mdadm is used for building, managing, and monitoring\n"
197 "Linux md devices (aka RAID arrays)\n"
198 "Usage: mdadm --create device options...\n"
199 " Create a new array from unused devices.\n"
200 " mdadm --assemble device options...\n"
201 " Assemble a previously created array.\n"
202 " mdadm --build device options...\n"
203 " Create or assemble an array without metadata.\n"
204 " mdadm --manage device options...\n"
205 " make changes to an existing array.\n"
206 " mdadm --misc options... devices\n"
207 " report on or modify various md related devices.\n"
208 " mdadm --grow options device\n"
209 " resize/reshape an active array\n"
210 " mdadm --incremental device\n"
211 " add a device to an array as appropriate\n"
212 " mdadm --monitor options...\n"
213 " Monitor one or more array for significant changes.\n"
214 " mdadm device options...\n"
215 " Shorthand for --manage.\n"
216 "Any parameter that does not start with '-' is treated as a device name\n"
217 "or, for --examine-bitmap, a file name.\n"
218 "The first such name is often the name of an md device. Subsequent\n"
219 "names are often names of component devices.\n"
221 " For detailed help on the above major modes use --help after the mode\n"
223 " mdadm --assemble --help\n"
224 " For general help on options use\n"
225 " mdadm --help-options\n"
229 "Any parameter that does not start with '-' is treated as a device name\n"
230 "or, for --examine-bitmap, a file name.\n"
231 "The first such name is often the name of an md device. Subsequent\n"
232 "names are often names of component devices.\n"
234 "Some common options are:\n"
235 " --help -h : General help message or, after above option,\n"
236 " mode specific help message\n"
237 " --help-options : This help message\n"
238 " --version -V : Print version information for mdadm\n"
239 " --verbose -v : Be more verbose about what is happening\n"
240 " --quiet -q : Don't print un-necessary messages\n"
241 " --brief -b : Be less verbose, more brief\n"
242 " --force -f : Override normal checks and be more forceful\n"
244 " --assemble -A : Assemble an array\n"
245 " --build -B : Build an array without metadata\n"
246 " --create -C : Create a new array\n"
247 " --detail -D : Display details of an array\n"
248 " --examine -E : Examine superblock on an array component\n"
249 " --examine-bitmap -X: Display the detail of a bitmap file\n"
250 " --monitor -F : monitor (follow) some arrays\n"
251 " --grow -G : resize/ reshape and array\n"
252 " --incremental -I : add a single device to an array as appropriate\n"
253 " --query -Q : Display general information about how a\n"
254 " device relates to the md driver\n"
258 " For create or build:\n"
259 " --bitmap= -b : File to store bitmap in - may pre-exist for --build\n"
260 " --chunk= -c : chunk size of kibibytes\n"
261 " --rounding= : rounding factor for linear array (==chunk size)\n"
262 " --level= -l : raid level: 0,1,4,5,6,linear,mp. 0 or linear for build\n"
263 " --parity= -p : raid5/6 parity algorithm: {left,right}-{,a}symmetric\n"
264 " --layout= : same as --parity\n"
265 " --raid-devices= -n : number of active devices in array\n"
266 " --spare-devices= -x: number of spares (eXtras) devices in initial array\n"
267 " --size= -z : Size (in K) of each drive in RAID1/4/5/6/10 - optional\n"
268 " --force -f : Honour devices as listed on command line. Don't\n"
269 " : insert a missing drive for RAID5.\n"
270 " --auto(=p) -a : Automatically allocate new (partitioned) md array if needed.\n"
271 " --assume-clean : Assume the array is already in-sync. This is dangerous.\n"
272 " --bitmap-chunk= : chunksize of bitmap in bitmap file (Kilobytes)\n"
273 " --delay= -d : seconds between bitmap updates\n"
274 " --write-behind= : number of simultaneous write-behind requests to allow (requires bitmap)\n"
275 " --name= -N : Textual name for array - max 32 characters\n"
278 " --bitmap= -b : File to find bitmap information in\n"
279 " --uuid= -u : uuid of array to assemble. Devices which don't\n"
280 " have this uuid are excluded\n"
281 " --super-minor= -m : minor number to look for in super-block when\n"
282 " choosing devices to use.\n"
283 " --name= -N : Array name to look for in super-block.\n"
284 " --config= -c : config file\n"
285 " --scan -s : scan config file for missing information\n"
286 " --force -f : Assemble the array even if some superblocks appear out-of-date\n"
287 " --update= -U : Update superblock: try '-A --update=?' for list of options.\n"
288 " --auto(=p) -a : Automatically allocate new (partitioned) md array if needed.\n"
289 " --no-degraded : Do not start any degraded arrays - default unless --scan.\n"
291 " For detail or examine:\n"
292 " --brief -b : Just print device name and UUID\n"
294 " For follow/monitor:\n"
295 " --mail= -m : Address to mail alerts of failure to\n"
296 " --program= -p : Program to run when an event is detected\n"
297 " --alert= : same as --program\n"
298 " --delay= -d : seconds of delay between polling state. default=60\n"
300 " General management:\n"
301 " --add -a : add, or hotadd subsequent devices\n"
302 " --remove -r : remove subsequent devices\n"
303 " --fail -f : mark subsequent devices a faulty\n"
304 " --set-faulty : same as --fail\n"
305 " --run -R : start a partially built array\n"
306 " --stop -S : deactivate array, releasing all resources\n"
307 " --readonly -o : mark array as readonly\n"
308 " --readwrite -w : mark array as readwrite\n"
309 " --zero-superblock : erase the MD superblock from a device.\n"
310 " --wait -W : wait for recovery/resync/reshape to finish.\n"
315 "Usage: mdadm --create device -chunk=X --level=Y --raid-devices=Z devices\n"
317 " This usage will initialise a new md array, associate some\n"
318 " devices with it, and activate the array. In order to create an\n"
319 " array with some devices missing, use the special word 'missing' in\n"
320 " place of the relevant device name.\n"
322 " Before devices are added, they are checked to see if they already contain\n"
323 " raid superblocks or filesystems. They are also checked to see if\n"
324 " the variance in device size exceeds 1%.\n"
325 " If any discrepancy is found, the user will be prompted for confirmation\n"
326 " before the array is created. The presence of a '--run' can override this\n"
329 " If the --size option is given then only that many kilobytes of each\n"
330 " device is used, no matter how big each device is.\n"
331 " If no --size is given, the apparent size of the smallest drive given\n"
332 " is used for raid level 1 and greater, and the full device is used for\n"
335 " Options that are valid with --create (-C) are:\n"
336 " --bitmap= : Create a bitmap for the array with the given filename\n"
337 " --chunk= -c : chunk size of kibibytes\n"
338 " --rounding= : rounding factor for linear array (==chunk size)\n"
339 " --level= -l : raid level: 0,1,4,5,6,linear,multipath and synonyms\n"
340 " --parity= -p : raid5/6 parity algorithm: {left,right}-{,a}symmetric\n"
341 " --layout= : same as --parity\n"
342 " --raid-devices= -n : number of active devices in array\n"
343 " --spare-devices= -x: number of spares (eXtras) devices in initial array\n"
344 " --size= -z : Size (in K) of each drive in RAID1/4/5/6/10 - optional\n"
345 " --force -f : Honour devices as listed on command line. Don't\n"
346 " : insert a missing drive for RAID5.\n"
347 " --run -R : insist of running the array even if not all\n"
348 " : devices are present or some look odd.\n"
349 " --readonly -o : start the array readonly - not supported yet.\n"
350 " --name= -N : Textual name for array - max 32 characters\n"
351 " --bitmap-chunk= : bitmap chunksize in Kilobytes.\n"
352 " --delay= -d : bitmap update delay in seconds.\n"
357 "Usage: mdadm --build device -chunk=X --level=Y --raid-devices=Z devices\n"
359 " This usage is similar to --create. The difference is that it creates\n"
360 " a legacy array without a superblock. With these arrays there is no\n"
361 " different between initially creating the array and subsequently\n"
362 " assembling the array, except that hopefully there is useful data\n"
363 " there in the second case.\n"
365 " The level may only be 0, raid0, or linear.\n"
366 " All devices must be listed and the array will be started once complete.\n"
367 " Options that are valid with --build (-B) are:\n"
368 " --bitmap= : file to store/find bitmap information in.\n"
369 " --chunk= -c : chunk size of kibibytes\n"
370 " --rounding= : rounding factor for linear array (==chunk size)\n"
371 " --level= -l : 0, raid0, or linear\n"
372 " --raid-devices= -n : number of active devices in array\n"
373 " --bitmap-chunk= : bitmap chunksize in Kilobytes.\n"
374 " --delay= -d : bitmap update delay in seconds.\n"
377 char Help_assemble
[] =
378 "Usage: mdadm --assemble device options...\n"
379 " mdadm --assemble --scan options...\n"
381 "This usage assembles one or more raid arrays from pre-existing\n"
383 "For each array, mdadm needs to know the md device, the identity of\n"
384 "the array, and a number of sub devices. These can be found in a number\n"
387 "The md device is either given on the command line or is found listed\n"
388 "in the config file. The array identity is determined either from the\n"
389 "--uuid or --super-minor commandline arguments, from the config file,\n"
390 "or from the first component device on the command line.\n"
392 "The different combinations of these are as follows:\n"
393 " If the --scan option is not given, then only devices and identities\n"
394 " listed on the command line are considered.\n"
395 " The first device will be the array device, and the remainder will be\n"
396 " examined when looking for components.\n"
397 " If an explicit identity is given with --uuid or --super-minor, then\n"
398 " only devices with a superblock which matches that identity is considered,\n"
399 " otherwise every device listed is considered.\n"
401 " If the --scan option is given, and no devices are listed, then\n"
402 " every array listed in the config file is considered for assembly.\n"
403 " The identity of candidate devices are determined from the config file.\n"
405 " If the --scan option is given as well as one or more devices, then\n"
406 " Those devices are md devices that are to be assembled. Their identity\n"
407 " and components are determined from the config file.\n"
409 " If mdadm can not find all of the components for an array, it will assemble\n"
410 " it but not activate it unless --run or --scan is given. To preserve this\n"
411 " behaviour even with --scan, add --no-degraded. Note that \"all of the\n"
412 " components\" means as many as were present the last time the array was running\n"
413 " as recorded in the superblock. If the array was already degraded, and\n"
414 " the missing device is not a new problem, it will still be assembled. It\n"
415 " is only newly missing devices that cause the array not to be started.\n"
417 "Options that are valid with --assemble (-A) are:\n"
418 " --bitmap= : bitmap file to use wit the array\n"
419 " --uuid= -u : uuid of array to assemble. Devices which don't\n"
420 " have this uuid are excluded\n"
421 " --super-minor= -m : minor number to look for in super-block when\n"
422 " choosing devices to use.\n"
423 " --name= -N : Array name to look for in super-block.\n"
424 " --config= -c : config file\n"
425 " --scan -s : scan config file for missing information\n"
426 " --run -R : Try to start the array even if not enough devices\n"
427 " for a full array are present\n"
428 " --force -f : Assemble the array even if some superblocks appear\n"
429 " : out-of-date. This involves modifying the superblocks.\n"
430 " --update= -U : Update superblock: try '-A --update=?' for option list.\n"
431 " --no-degraded : Assemble but do not start degraded arrays.\n"
435 "Usage: mdadm arraydevice options component devices...\n"
437 "This usage is for managing the component devices within an array.\n"
438 "The --manage option is not needed and is assumed if the first argument\n"
439 "is a device name or a management option.\n"
440 "The first device listed will be taken to be an md array device, and\n"
441 "subsequent devices are (potential) components of that array.\n"
443 "Options that are valid with management mode are:\n"
444 " --add -a : hotadd subsequent devices to the array\n"
445 " --remove -r : remove subsequent devices, which must not be active\n"
446 " --fail -f : mark subsequent devices a faulty\n"
447 " --set-faulty : same as --fail\n"
448 " --run -R : start a partially built array\n"
449 " --stop -S : deactivate array, releasing all resources\n"
450 " --readonly -o : mark array as readonly\n"
451 " --readwrite -w : mark array as readwrite\n"
455 "Usage: mdadm misc_option devices...\n"
457 "This usage is for performing some task on one or more devices, which\n"
458 "may be arrays or components, depending on the task.\n"
459 "The --misc option is not needed (though it is allowed) and is assumed\n"
460 "if the first argument in a misc option.\n"
462 "Options that are valid with the miscellaneous mode are:\n"
463 " --query -Q : Display general information about how a\n"
464 " device relates to the md driver\n"
465 " --detail -D : Display details of an array\n"
466 " --examine -E : Examine superblock on an array component\n"
467 " --examine-bitmap -X: Display contents of a bitmap file\n"
468 " --zero-superblock : erase the MD superblock from a device.\n"
469 " --run -R : start a partially built array\n"
470 " --stop -S : deactivate array, releasing all resources\n"
471 " --readonly -o : mark array as readonly\n"
472 " --readwrite -w : mark array as readwrite\n"
473 " --test -t : exit status 0 if ok, 1 if degrade, 2 if dead, 4 if missing\n"
474 " --wait -W : wait for resync/rebuild/recovery to finish\n"
477 char Help_monitor
[] =
478 "Usage: mdadm --monitor options devices\n"
480 "This usage causes mdadm to monitor a number of md arrays by periodically\n"
481 "polling their status and acting on any changes.\n"
482 "If any devices are listed then those devices are monitored, otherwise\n"
483 "all devices listed in the config file are monitored.\n"
484 "The address for mailing advisories to, and the program to handle\n"
485 "each change can be specified in the config file or on the command line.\n"
486 "If no mail address or program are specified, then mdadm reports all\n"
487 "state changes to stdout.\n"
489 "Options that are valid with the monitor (-F --follow) mode are:\n"
490 " --mail= -m : Address to mail alerts of failure to\n"
491 " --program= -p : Program to run when an event is detected\n"
492 " --alert= : same as --program\n"
493 " --delay= -d : seconds of delay between polling state. default=60\n"
494 " --config= -c : specify a different config file\n"
495 " --scan -s : find mail-address/program in config file\n"
496 " --daemonise -f : Fork and continue in child, parent exits\n"
497 " --pid-file= -i : In daemon mode write pid to specified file instead of stdout\n"
498 " --oneshot -1 : Check for degraded arrays, then exit\n"
499 " --test -t : Generate a TestMessage event against each array at startup\n"
503 "Usage: mdadm --grow device options\n"
505 "This usage causes mdadm to attempt to reconfigure a running array.\n"
506 "This is only possibly if the kernel being used supports a particular\n"
507 "reconfiguration. This version only supports changing the number of\n"
508 "devices in a RAID1, and changing the active size of all devices in\n"
511 "Options that are valid with the grow (-G --grow) mode are:\n"
512 " --size= -z : Change the active size of devices in an array.\n"
513 " : This is useful if all devices have been replaced\n"
514 " : with larger devices.\n"
515 " --raid-disks= -n : Change the number of active devices in a RAID1\n"
520 "Usage: mdadm --incremental [-Rqrs] device\n"
522 "This usage allows for incremental assembly of md arrays. Devices can be\n"
523 "added one at a time as they are discovered. Once an array has all expected\n"
524 "devices, it will be started.\n"
526 "Options that are valid with incremental assembly (-I --incremental) more are:\n"
527 " --run -R : run arrays as soon as a minimal number of devices are\n"
528 " : present rather than waiting for all expected.\n"
529 " --quiet -q : Don't print any information messages, just errors.\n"
530 " --rebuild -r : Rebuild the 'map' file that mdadm uses for tracking\n"
531 " : partial arrays.\n"
532 " --scan -s : Use with -R to start any arrays that have the minimal\n"
533 " : required number of devices, but are not yet started.\n"
537 "The /etc/mdadm.conf config file:\n\n"
538 " The config file contains, apart from blank lines and comment lines that\n"
539 " start with a hash(#), four sorts of configuration lines: array lines, \n"
540 " device lines, mailaddr lines and program lines.\n"
541 " Each configuration line is constructed of a number of space separated\n"
542 " words, and can be continued on subsequent physical lines by indenting\n"
545 " A device line starts with the word 'device' and then has a number of words\n"
546 " which identify devices. These words should be names of devices in the\n"
547 " filesystem, and can contain wildcards. There can be multiple words or each\n"
548 " device line, and multiple device lines. All devices so listed are checked\n"
549 " for relevant super blocks when assembling arrays.\n"
551 " An array line start with the word 'array'. This is followed by the name of\n"
552 " the array device in the filesystem, e.g. '/dev/md2'. Subsequent words\n"
553 " describe the identity of the array, used to recognise devices to include in the\n"
554 " array. The identity can be given as a UUID with a word starting 'uuid=', or\n"
555 " as a minor-number stored in the superblock using 'super-minor=', or as a list\n"
556 " of devices. This is given as a comma separated list of names, possibly\n"
557 " containing wildcards, preceded by 'devices='. If multiple critea are given,\n"
558 " than a device must match all of them to be considered.\n"
560 " A mailaddr line starts with the word 'mailaddr' and should contain exactly\n"
561 " one Email address. 'mdadm --monitor --scan' will send alerts of failed drives\n"
562 " to this Email address."
564 " A program line starts with the word 'program' and should contain exactly\n"
565 " one program name. 'mdadm --monitor --scan' will run this program when any\n"
566 " event is detected.\n"
571 /* name/number mappings */
573 mapping_t r5layout
[] = {
574 { "left-asymmetric", 0},
575 { "right-asymmetric", 1},
576 { "left-symmetric", 2},
577 { "right-symmetric", 3},
610 mapping_t modes
[] = {
611 { "assemble", ASSEMBLE
},
616 { "monitor", MONITOR
},
618 { "incremental", INCREMENTAL
},
621 mapping_t faultylayout
[] = {
622 { "write-transient", WriteTransient
},
623 { "wt", WriteTransient
},
624 { "read-transient", ReadTransient
},
625 { "rt", ReadTransient
},
626 { "write-persistent", WritePersistent
},
627 { "wp", WritePersistent
},
628 { "read-persistent", ReadPersistent
},
629 { "rp", ReadPersistent
},
630 { "write-all", WriteAll
},
632 { "read-fixable", ReadFixable
},
633 { "rf", ReadFixable
},
635 { "clear", ClearErrors
},
636 { "flush", ClearFaults
},
637 { "none", ClearErrors
},
638 { "default", ClearErrors
},