]> git.ipfire.org Git - thirdparty/mdadm.git/blame - ReadMe.c
mdadm-1.1.0
[thirdparty/mdadm.git] / ReadMe.c
CommitLineData
64c4757e 1/*
9a9dab36 2 * mdadm - manage Linux "md" devices aka RAID arrays.
64c4757e 3 *
cd29a5c8 4 * Copyright (C) 2001-2002 Neil Brown <neilb@cse.unsw.edu.au>
64c4757e
NB
5 *
6 *
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.
11 *
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.
16 *
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
20 *
21 * Author: Neil Brown
22 * Email: <neilb@cse.unsw.edu.au>
23 * Paper: Neil Brown
24 * School of Computer Science and Engineering
25 * The University of New South Wales
26 * Sydney, 2052
27 * Australia
28 */
29
9a9dab36 30#include "mdadm.h"
64c4757e 31
d013a55e 32char Version[] = Name " - v1.1.0 - 3 Mar 2003\n";
64c4757e
NB
33/*
34 * File: ReadMe.c
35 *
36 * This file contains general comments about the implementation
9a9dab36 37 * and the various usage messages that can be displayed by mdadm
64c4757e 38 *
9a9dab36 39 * mdadm is a single program that can be used to control Linux md devices.
64c4757e
NB
40 * It is intended to provide all the functionality of the mdtools and
41 * raidtools but with a very different interface.
9a9dab36 42 * mdadm can perform all functions without a configuration file.
64c4757e
NB
43 * There is the option of using a configuration file, but not in the same
44 * way that raidtools uses one
45 * raidtools uses a configuration file to describe how to create a RAID
46 * array, and also uses this file partially to start a previously
47 * created RAID array. Further, raidtools requires the configuration
48 * file for such things as stopping a raid array which needs to know
49 * nothing about the array.
50 *
9a9dab36 51 * The configuration file that can be used by mdadm lists two
64c4757e
NB
52 * different things:
53 * 1/ a mapping from uuid to md device to identify which arrays are
54 * expect and what names (numbers) they should be given
55 * 2/ a list of devices that should be scanned for md sub-devices
56 *
57 *
58 */
59
60/*
e0d19036 61 * mdadm has 6 major modes of operation:
64c4757e 62 * 1/ Create
5787fa49 63 * This mode is used to create a new array with a superblock
64c4757e
NB
64 * It can progress in several step create-add-add-run
65 * or it can all happen with one command
66 * 2/ Assemble
67 * This mode is used to assemble the parts of a previously created
68 * array into an active array. Components can be explicitly given
9a9dab36 69 * or can be searched for. mdadm (optionally) check that the components
5787fa49 70 * do form a bona-fide array, and can, on request, fiddle superblock
64c4757e
NB
71 * version numbers so as to assemble a faulty array.
72 * 3/ Build
73 * This is for building legacy arrays without superblocks
74 * 4/ Manage
e0d19036
NB
75 * This is for doing something to one or more devices
76 * in an array, such as add,remove,fail.
77 * run/stop/readonly/readwrite are also available
78 * 5/ Misc
79 * This is for doing things to individual devices.
80 * They might be parts of an array so
81 * zero-superblock, examine might be appropriate
82 * They might be md arrays so
83 * run,stop,rw,ro,detail might be appropriate
84 * Also query will treat it as either
85 * 6/ Monitor
86 * This mode never exits but just monitors arrays and reports changes.
64c4757e
NB
87 */
88
5787fa49 89char short_options[]="-ABCDEFGQhVvbc:l:p:m:n:x:u:c:d:z:U:sarfRSow";
64c4757e
NB
90struct option long_options[] = {
91 {"manage", 0, 0, '@'},
e0d19036 92 {"misc", 0, 0, '#'},
64c4757e
NB
93 {"assemble", 0, 0, 'A'},
94 {"build", 0, 0, 'B'},
95 {"create", 0, 0, 'C'},
96 {"detail", 0, 0, 'D'},
97 {"examine", 0, 0, 'E'},
52826846 98 {"follow", 0, 0, 'F'},
9a9dab36 99 {"grow", 0, 0, 'G'}, /* not yet implemented */
e0d19036
NB
100 {"zero-superblock", 0, 0, 'K'}, /* deliberately no a short_option */
101 {"query", 0, 0, 'Q'},
52826846
NB
102
103 /* synonyms */
104 {"monitor", 0, 0, 'F'},
105
64c4757e
NB
106 /* after those will normally come the name of the md device */
107 {"help", 0, 0, 'h'},
108 {"version", 0, 0, 'V'},
109 {"verbose", 0, 0, 'v'},
110
111 /* For create or build: */
112 {"chunk", 1, 0, 'c'},
113 {"rounding", 1, 0, 'c'}, /* for linear, chunk is really a rounding number */
114 {"level", 1, 0, 'l'}, /* 0,1,4,5,linear */
5787fa49 115 {"parity", 1, 0, 'p'}, /* {left,right}-{a,}symmetric */
64c4757e
NB
116 {"layout", 1, 0, 'p'},
117 {"raid-disks",1, 0, 'n'},
b83d95f3 118 {"raid-devices",1, 0, 'n'},
64c4757e 119 {"spare-disks",1,0, 'x'},
b83d95f3 120 {"spare-devices",1,0, 'x'},
682c7051 121 {"size" ,1, 0, 'z'},
64c4757e
NB
122
123 /* For assemble */
124 {"uuid", 1, 0, 'u'},
52826846 125 {"super-minor",1,0, 'm'},
64c4757e
NB
126 {"config", 1, 0, 'c'},
127 {"scan", 0, 0, 's'},
128 {"force", 0, 0, 'f'},
5787fa49 129 {"update", 1, 0, 'U'},
64c4757e
NB
130 /* Management */
131 {"add", 0, 0, 'a'},
132 {"remove", 0, 0, 'r'},
133 {"fail", 0, 0, 'f'},
134 {"set-faulty",0, 0, 'f'},
135 {"run", 0, 0, 'R'},
136 {"stop", 0, 0, 'S'},
137 {"readonly", 0, 0, 'o'},
138 {"readwrite", 0, 0, 'w'},
52826846 139
cd29a5c8
NB
140 /* For Detail/Examine */
141 {"brief", 0, 0, 'b'},
bd526cee 142 {"sparc2.2", 0, 0, 22},
cd29a5c8 143
52826846
NB
144 /* For Follow/monitor */
145 {"mail", 1, 0, 'm'},
146 {"program", 1, 0, 'p'},
147 {"alert", 1, 0, 'p'},
148 {"delay", 1, 0, 'd'},
d013a55e
NB
149 {"daemonise", 1, 0, 'f'},
150 {"daemonize", 1, 0, 'f'},
52826846 151
64c4757e
NB
152
153 {0, 0, 0, 0}
154};
155
156char Usage[] =
9a9dab36 157"Usage: mdadm --help\n"
64c4757e
NB
158" for help\n"
159;
160
161char Help[] =
9a9dab36
NB
162"Usage: mdadm --create device options...\n"
163" mdadm --assemble device options...\n"
164" mdadm --build device options...\n"
e0d19036
NB
165" mdadm --manage device options...\n"
166" mdadm --misc options... devices\n"
167" mdadm --monitor options...\n"
9a9dab36 168" mdadm device options...\n"
5787fa49 169" mdadm is used for building, managing, and monitoring\n"
e0d19036
NB
170" Linux md devices (aka RAID arrays)\n"
171" For detail help on the above major modes use --help after the mode\n"
172" e.g.\n"
9a9dab36 173" mdadm --assemble --help\n"
64c4757e
NB
174"\n"
175"Any parameter that does not start with '-' is treated as a device name\n"
e0d19036
NB
176"The first such name is often the name of an md device. Subsequent\n"
177"names are often names of component devices."
52826846 178"\n"
e0d19036 179"Some common options are:\n"
64c4757e
NB
180" --help -h : This help message or, after above option,\n"
181" mode specific help message\n"
9a9dab36 182" --version -V : Print version information for mdadm\n"
64c4757e 183" --verbose -v : Be more verbose about what is happening\n"
e0d19036
NB
184" --brief -b : Be less verbose, more brief\n"
185" --force -f : Override normal checks and be more forceful\n"
186"\n"
187" --assemble -A : Assemble an array\n"
188" --build -B : Build a legacy array\n"
189" --create -C : Create a new array\n"
190" --detail -D : Display details of an array\n"
5787fa49 191" --examine -E : Examine superblock on an array component\n"
e0d19036
NB
192" --monitor -F : monitor (follow) some arrays\n"
193" --query -Q : Display general information about how a\n"
194" device relates to the md driver\n"
195;
196/*
64c4757e
NB
197"\n"
198" For create or build:\n"
199" --chunk= -c : chunk size of kibibytes\n"
5787fa49 200" --rounding= : rounding factor for linear array (==chunk size)\n"
c913b90e 201" --level= -l : raid level: 0,1,4,5,linear,mp. 0 or linear for build\n"
5787fa49 202" --parity= -p : raid5 parity algorithm: {left,right}-{,a}symmetric\n"
64c4757e 203" --layout= : same as --parity\n"
b83d95f3
NB
204" --raid-devices= -n : number of active devices in array\n"
205" --spare-devices= -x: number of spares (eXtras) devices in initial array\n"
682c7051 206" --size= -z : Size (in K) of each drive in RAID1/4/5 - optional\n"
52826846
NB
207" --force -f : Honour devices as listed on command line. Don't\n"
208" : insert a missing drive for RAID5.\n"
64c4757e
NB
209"\n"
210" For assemble:\n"
211" --uuid= -u : uuid of array to assemble. Devices which don't\n"
212" have this uuid are excluded\n"
52826846
NB
213" --super-minor= -m : minor number to look for in super-block when\n"
214" choosing devices to use.\n"
64c4757e
NB
215" --config= -c : config file\n"
216" --scan -s : scan config file for missing information\n"
217" --force -f : Assemble the array even if some superblocks appear out-of-date\n"
5787fa49 218" --update= -U : Update superblock: either sparc2.2 or super-minor\n"
64c4757e 219"\n"
cd29a5c8
NB
220" For detail or examine:\n"
221" --brief -b : Just print device name and UUID\n"
222"\n"
52826846
NB
223" For follow/monitor:\n"
224" --mail= -m : Address to mail alerts of failure to\n"
225" --program= -p : Program to run when an event is detected\n"
226" --alert= : same as --program\n"
227" --delay= -d : seconds of delay between polling state. default=60\n"
228"\n"
64c4757e
NB
229" General management:\n"
230" --add -a : add, or hotadd subsequent devices\n"
231" --remove -r : remove subsequent devices\n"
232" --fail -f : mark subsequent devices a faulty\n"
233" --set-faulty : same as --fail\n"
234" --run -R : start a partially built array\n"
5787fa49 235" --stop -S : deactivate array, releasing all resources\n"
64c4757e
NB
236" --readonly -o : mark array as readonly\n"
237" --readwrite -w : mark array as readwrite\n"
9a9dab36 238" --zero-superblock : erase the MD superblock from a device.\n"
64c4757e 239;
e0d19036 240*/
64c4757e
NB
241
242char Help_create[] =
b83d95f3 243"Usage: mdadm --create device -chunk=X --level=Y --raid-devices=Z devices\n"
64c4757e 244"\n"
e0d19036 245" This usage will initialise a new md array and associate some\n"
64c4757e
NB
246" devices with it. If enough devices are given to complete the array,\n"
247" the array will be activated. Otherwise it will be left inactive\n"
52826846 248" to be completed and activated by subsequent management commands.\n"
64c4757e 249"\n"
e0d19036
NB
250" As devices are added, they are checked to see if they already contain\n"
251" raid superblocks or filesystems. They are also checked to see if\n"
64c4757e
NB
252" the variance in device size exceeds 1%.\n"
253" If any discrepancy is found, the array will not automatically\n"
254" be run, though the presence of a '--run' can override this\n"
255" caution.\n"
256"\n"
e0d19036
NB
257" If the --size option is given then only that many kilobytes of each\n"
258" device is used, no matter how big each device is.\n"
682c7051 259" If no --size is given, the apparent size of the smallest drive given\n"
e0d19036
NB
260" is used for raid level 1 and greater, and the full device is used for\n"
261" other levels.\n"
682c7051 262"\n"
e0d19036
NB
263" Options that are valid with --create (-C) are:\n"
264" --chunk= -c : chunk size of kibibytes\n"
5787fa49 265" --rounding= : rounding factor for linear array (==chunk size)\n"
e0d19036 266" --level= -l : raid level: 0,1,4,5,linear,multipath and synonyms\n"
5787fa49 267" --parity= -p : raid5 parity algorithm: {left,right}-{,a}symmetric\n"
e0d19036 268" --layout= : same as --parity\n"
b83d95f3
NB
269" --raid-devices= -n : number of active devices in array\n"
270" --spare-devices= -x: number of spares (eXtras) devices in initial array\n"
e0d19036
NB
271" --size= -z : Size (in K) of each drive in RAID1/4/5 - optional\n"
272" --force -f : Honour devices as listed on command line. Don't\n"
273" : insert a missing drive for RAID5.\n"
274" --run : insist of running the array even if not all\n"
275" : devices are present or some look odd.\n"
276" --readonly : start the array readonly - not supported yet.\n"
64c4757e
NB
277"\n"
278;
279
280char Help_build[] =
b83d95f3 281"Usage: mdadm --build device -chunk=X --level=Y --raid-devices=Z devices\n"
64c4757e
NB
282"\n"
283" This usage is similar to --create. The difference is that it creates\n"
e0d19036 284" a legacy array without a superblock. With these arrays there is no\n"
64c4757e
NB
285" different between initially creating the array and subsequently\n"
286" assembling the array, except that hopefully there is useful data\n"
287" there in the second case.\n"
288"\n"
e0d19036 289" The level may only be 0, raid0, or linear.\n"
64c4757e 290" All devices must be listed and the array will be started once complete.\n"
e0d19036
NB
291" Options that are valid with --build (-B) are:\n"
292" --chunk= -c : chunk size of kibibytes\n"
5787fa49 293" --rounding= : rounding factor for linear array (==chunk size)\n"
e0d19036 294" --level= -l : 0, raid0, or linear\n"
b83d95f3 295" --raid-devices= -n : number of active devices in array\n"
64c4757e
NB
296;
297
298char Help_assemble[] =
9a9dab36
NB
299"Usage: mdadm --assemble device options...\n"
300" mdadm --assemble --scan options...\n"
64c4757e
NB
301"\n"
302"This usage assembles one or more raid arrays from pre-existing\n"
303"components.\n"
e0d19036 304"For each array, mdadm needs to know the md device, the identity of\n"
52826846
NB
305"the array, and a number of sub devices. These can be found in a number\n"
306"of ways.\n"
307"\n"
308"The md device is either given on the command line or is found listed\n"
309"in the config file. The array identity is determined either from the\n"
e0d19036 310"--uuid or --super-minor commandline arguments, from the config file,\n"
52826846 311"or from the first component device on the command line.\n"
64c4757e 312"\n"
52826846
NB
313"The different combinations of these are as follows:\n"
314" If the --scan option is not given, then only devices and identities\n"
315" listed on the command line are considered.\n"
e0d19036 316" The first device will be the array device, and the remainder will be\n"
52826846
NB
317" examined when looking for components.\n"
318" If an explicit identity is given with --uuid or --super-minor, then\n"
e0d19036 319" only devices with a superblock which matches that identity is considered,\n"
52826846 320" otherwise every device listed is considered.\n"
64c4757e 321"\n"
52826846
NB
322" If the --scan option is given, and no devices are listed, then\n"
323" every array listed in the config file is considered for assembly.\n"
e0d19036 324" The identity of candidate devices are determined from the config file.\n"
64c4757e 325"\n"
52826846
NB
326" If the --scan option is given as well as one or more devices, then\n"
327" Those devices are md devices that are to be assembled. Their identity\n"
328" and components are determined from the config file.\n"
64c4757e 329"\n"
e0d19036
NB
330"Options that are valid with --assemble (-A) are:\n"
331" --uuid= -u : uuid of array to assemble. Devices which don't\n"
332" have this uuid are excluded\n"
333" --super-minor= -m : minor number to look for in super-block when\n"
334" choosing devices to use.\n"
335" --config= -c : config file\n"
336" --scan -s : scan config file for missing information\n"
337" --run -R : Try to start the array even if not enough devices\n"
338" for a full array are present\n"
339" --force -f : Assemble the array even if some superblocks appear\n"
340" : out-of-date. This involves modifying the superblocks.\n"
5787fa49 341" --update= -U : Update superblock: either sparc2.2 or super-minor\n"
e0d19036
NB
342;
343
344char Help_manage[] =
345"Usage: mdadm arraydevice options component devices...\n"
346"\n"
347"This usage is for managing the component devices within an array.\n"
348"The --manage option is not needed and is assumed if the first argument\n"
349"is a device name or a management option.\n"
350"The first device listed will be taken to be an md array device, and\n"
351"subsequent devices are (potential) components of that array.\n"
352"\n"
353"Options that are valid with management mode are:\n"
354" --add -a : hotadd subsequent devices to the array\n"
355" --remove -r : remove subsequent devices, which must not be active\n"
356" --fail -f : mark subsequent devices a faulty\n"
357" --set-faulty : same as --fail\n"
358" --run -R : start a partially built array\n"
5787fa49 359" --stop -S : deactivate array, releasing all resources\n"
e0d19036
NB
360" --readonly -o : mark array as readonly\n"
361" --readwrite -w : mark array as readwrite\n"
362;
363
364char Help_misc[] =
365"Usage: mdadm misc_option devices...\n"
366"\n"
367"This usage is for performing some task on one or more devices, which\n"
368"may be arrays or components, depending on the task.\n"
369"The --misc option is not needed (though it is allowed) and is assumed\n"
370"if the first argument in a misc option.\n"
371"\n"
372"Options that are valid with the miscellaneous mode are:\n"
373" --query -Q : Display general information about how a\n"
374" device relates to the md driver\n"
375" --detail -D : Display details of an array\n"
5787fa49 376" --examine -E : Examine superblock on an array component\n"
e0d19036
NB
377" --zero-superblock : erase the MD superblock from a device.\n"
378" --run -R : start a partially built array\n"
5787fa49 379" --stop -S : deactivate array, releasing all resources\n"
e0d19036
NB
380" --readonly -o : mark array as readonly\n"
381" --readwrite -w : mark array as readwrite\n"
382;
383
384char Help_monitor[] =
385"Usage: mdadm --monitor options devices\n"
386"\n"
387"This usage causes mdadm to monitor a number of md arrays by periodically\n"
388"polling their status and acting on any changes.\n"
389"If any devices are listed then those devices are monitored, otherwise\n"
390"all devices listed in the config file are monitored.\n"
391"The address for mailing advisories to, and the program to handle\n"
392"each change can be specified in the config file or on the command line.\n"
393"If no mail address or program are specified, then mdadm reports all\n"
394"state changes to stdout.\n"
395"\n"
396"Options that are valid with the monitor (--F --follow) mode are:\n"
397" --mail= -m : Address to mail alerts of failure to\n"
398" --program= -p : Program to run when an event is detected\n"
399" --alert= : same as --program\n"
400" --delay= -d : seconds of delay between polling state. default=60\n"
401" --config= -c : specify a different config file\n"
402" --scan -s : find mail-address/program in config file\n"
d013a55e 403" --daemonise -f : Fork and continue in child, parent exits\n"
e0d19036
NB
404;
405
406
407
408
409char Help_config[] =
410"The /etc/mdadm.conf config file:\n\n"
411" The config file contains, apart from blank lines and comment lines that\n"
412" start with a hash(#), four sorts of configuration lines: array lines, \n"
413" device lines, mailaddr lines and program lines.\n"
414" Each configuration line is constructed of a number of space separated\n"
415" words, and can be continued on subsequent physical lines by indenting\n"
416" those lines.\n"
417"\n"
418" A device line starts with the word 'device' and then has a number of words\n"
419" which identify devices. These words should be names of devices in the\n"
420" filesystem, and can contain wildcards. There can be multiple words or each\n"
421" device line, and multiple device lines. All devices so listed are checked\n"
422" for relevant super blocks when assembling arrays.\n"
423"\n"
424" An array line start with the word 'array'. This is followed by the name of\n"
425" the array device in the filesystem, e.g. '/dev/md2'. Subsequent words\n"
426" describe the identity of the array, used to recognise devices to include in the\n"
427" array. The identity can be given as a UUID with a word starting 'uuid=', or\n"
428" as a minor-number stored in the superblock using 'super-minor=', or as a list\n"
429" of devices. This is given as a comma separated list of names, possibly\n"
5787fa49 430" containing wildcards, preceded by 'devices='. If multiple critea are given,\n"
e0d19036
NB
431" than a device must match all of them to be considered.\n"
432"\n"
433" A mailaddr line starts with the word 'mailaddr' and should contain exactly\n"
434" one Email address. 'mdadm --monitor --scan' will send alerts of failed drives\n"
435" to this Email address."
436"\n"
437" A program line starts with the word 'program' and should contain exactly\n"
438" one program name. 'mdadm --monitor --scan' will run this program when any\n"
439" event is detected.\n"
64c4757e
NB
440"\n"
441;
682c7051
NB
442
443
444/* name/number mappings */
445
446mapping_t r5layout[] = {
cd29a5c8
NB
447 { "left-asymmetric", 0},
448 { "right-asymmetric", 1},
449 { "left-symmetric", 2},
450 { "right-symmetric", 3},
682c7051
NB
451
452 { "default", 2},
453 { "la", 0},
454 { "ra", 1},
455 { "ls", 2},
456 { "rs", 3},
457 { NULL, 0}
458};
459
460mapping_t pers[] = {
461 { "linear", -1},
462 { "raid0", 0},
463 { "0", 0},
464 { "stripe", 0},
465 { "raid1", 1},
466 { "1", 1},
467 { "mirror", 1},
468 { "raid4", 4},
469 { "4", 4},
470 { "raid5", 5},
471 { "5", 5},
e0d19036
NB
472 { "multipath", -4},
473 { "mp", -4},
682c7051
NB
474 { NULL, 0}
475};
e0d19036
NB
476
477
478mapping_t modes[] = {
479 { "assemble", ASSEMBLE},
480 { "build", BUILD},
481 { "create", CREATE},
482 { "manage", MANAGE},
483 { "misc", MISC},
484 { "monitor", MONITOR},
485};