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