]> git.ipfire.org Git - thirdparty/mdadm.git/blame - ReadMe.c
mdadm-0.7.1
[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
56eb10c0 32char Version[] = Name " - v0.7.1 - 8 March 2002\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/*
9a9dab36 61 * mdadm has 4 major modes of operation:
64c4757e
NB
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
9a9dab36 69 * or can be searched for. mdadm (optionally) check that the components
64c4757e
NB
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 odd bits an pieces like hotadd, hotremove, setfaulty,
76 * stop, readonly,readwrite
77 * If an array is only partially setup by the Create/Assemble/Build
78 * command, subsequent Manage commands can finish the job.
79 */
80
cd29a5c8 81char short_options[]="-ABCDEFhVvbc:l:p:m:n:x:u:c:d:z:sarfRSow";
64c4757e
NB
82struct option long_options[] = {
83 {"manage", 0, 0, '@'},
84 {"assemble", 0, 0, 'A'},
85 {"build", 0, 0, 'B'},
86 {"create", 0, 0, 'C'},
87 {"detail", 0, 0, 'D'},
88 {"examine", 0, 0, 'E'},
52826846 89 {"follow", 0, 0, 'F'},
9a9dab36
NB
90 {"grow", 0, 0, 'G'}, /* not yet implemented */
91 {"zero-superblock", 0, 0, 'H'},
52826846
NB
92
93 /* synonyms */
94 {"monitor", 0, 0, 'F'},
95
64c4757e
NB
96 /* after those will normally come the name of the md device */
97 {"help", 0, 0, 'h'},
98 {"version", 0, 0, 'V'},
99 {"verbose", 0, 0, 'v'},
100
101 /* For create or build: */
102 {"chunk", 1, 0, 'c'},
103 {"rounding", 1, 0, 'c'}, /* for linear, chunk is really a rounding number */
104 {"level", 1, 0, 'l'}, /* 0,1,4,5,linear */
105 {"parity", 1, 0, 'p'}, /* {left,right}-{a,}symetric */
106 {"layout", 1, 0, 'p'},
107 {"raid-disks",1, 0, 'n'},
108 {"spare-disks",1,0, 'x'},
682c7051 109 {"size" ,1, 0, 'z'},
64c4757e
NB
110
111 /* For assemble */
112 {"uuid", 1, 0, 'u'},
52826846 113 {"super-minor",1,0, 'm'},
64c4757e
NB
114 {"config", 1, 0, 'c'},
115 {"scan", 0, 0, 's'},
116 {"force", 0, 0, 'f'},
117 /* Management */
118 {"add", 0, 0, 'a'},
119 {"remove", 0, 0, 'r'},
120 {"fail", 0, 0, 'f'},
121 {"set-faulty",0, 0, 'f'},
122 {"run", 0, 0, 'R'},
123 {"stop", 0, 0, 'S'},
124 {"readonly", 0, 0, 'o'},
125 {"readwrite", 0, 0, 'w'},
52826846 126
cd29a5c8
NB
127 /* For Detail/Examine */
128 {"brief", 0, 0, 'b'},
129
52826846
NB
130 /* For Follow/monitor */
131 {"mail", 1, 0, 'm'},
132 {"program", 1, 0, 'p'},
133 {"alert", 1, 0, 'p'},
134 {"delay", 1, 0, 'd'},
135
64c4757e
NB
136
137 {0, 0, 0, 0}
138};
139
140char Usage[] =
9a9dab36 141"Usage: mdadm --help\n"
64c4757e
NB
142" for help\n"
143;
144
145char Help[] =
9a9dab36
NB
146"Usage: mdadm --create device options...\n"
147" mdadm --assemble device options...\n"
148" mdadm --build device options...\n"
149" mdadm --detail device\n"
150" mdadm --examine device\n"
151" mdadm --follow options...\n"
152" mdadm device options...\n"
153" mdadm is used for controlling Linux md devices (aka RAID arrays)\n"
64c4757e 154" For detail help on major modes use, e.g.\n"
9a9dab36 155" mdadm --assemble --help\n"
64c4757e
NB
156"\n"
157"Any parameter that does not start with '-' is treated as a device name\n"
158"The first such name is normally the name of an md device. Subsequent\n"
159"names are names of component devices."
160"\n"
161"Available options are:\n"
162" --create -C : Create a new array\n"
163" --assemble -A : Assemble an existing array\n"
164" --build -B : Build a legacy array without superblock\n"
165" --detail -D : Print detail of a given md array\n"
166" --examine -E : Print content of md superblock on device\n"
52826846
NB
167" --follow -F : Follow (monitor) any changes to devices and respond to them\n"
168" --monitor : same as --follow\n"
169"\n"
64c4757e
NB
170" --help -h : This help message or, after above option,\n"
171" mode specific help message\n"
9a9dab36 172" --version -V : Print version information for mdadm\n"
64c4757e
NB
173" --verbose -v : Be more verbose about what is happening\n"
174"\n"
175" For create or build:\n"
176" --chunk= -c : chunk size of kibibytes\n"
177" --rounding= : rounding factor for linear array (==chunck size)\n"
178" --level= -l : raid level: 0,1,4,5,linear. 0 or linear for build\n"
179" --paritiy= -p : raid5 parity algorith: {left,right}-{,a}symmetric\n"
180" --layout= : same as --parity\n"
181" --raid-disks= -n : number of active devices in array\n"
cd29a5c8 182" --spare-disks= -x : number of spares (eXtras) devices in initial array\n"
682c7051 183" --size= -z : Size (in K) of each drive in RAID1/4/5 - optional\n"
52826846
NB
184" --force -f : Honour devices as listed on command line. Don't\n"
185" : insert a missing drive for RAID5.\n"
64c4757e
NB
186"\n"
187" For assemble:\n"
188" --uuid= -u : uuid of array to assemble. Devices which don't\n"
189" have this uuid are excluded\n"
52826846
NB
190" --super-minor= -m : minor number to look for in super-block when\n"
191" choosing devices to use.\n"
64c4757e
NB
192" --config= -c : config file\n"
193" --scan -s : scan config file for missing information\n"
194" --force -f : Assemble the array even if some superblocks appear out-of-date\n"
195"\n"
cd29a5c8
NB
196" For detail or examine:\n"
197" --brief -b : Just print device name and UUID\n"
198"\n"
52826846
NB
199" For follow/monitor:\n"
200" --mail= -m : Address to mail alerts of failure to\n"
201" --program= -p : Program to run when an event is detected\n"
202" --alert= : same as --program\n"
203" --delay= -d : seconds of delay between polling state. default=60\n"
204"\n"
64c4757e
NB
205" General management:\n"
206" --add -a : add, or hotadd subsequent devices\n"
207" --remove -r : remove subsequent devices\n"
208" --fail -f : mark subsequent devices a faulty\n"
209" --set-faulty : same as --fail\n"
210" --run -R : start a partially built array\n"
211" --stop -S : deactive array, releasing all resources\n"
212" --readonly -o : mark array as readonly\n"
213" --readwrite -w : mark array as readwrite\n"
9a9dab36 214" --zero-superblock : erase the MD superblock from a device.\n"
64c4757e
NB
215;
216
217
218char Help_create[] =
9a9dab36 219"Usage: mdadm --create device -chunk=X --level=Y --raid-disks=Z devices\n"
64c4757e
NB
220"\n"
221" This usage will initialise a new md array and possibly associate some\n"
222" devices with it. If enough devices are given to complete the array,\n"
223" the array will be activated. Otherwise it will be left inactive\n"
52826846 224" to be completed and activated by subsequent management commands.\n"
64c4757e
NB
225"\n"
226" As devices are added, they are checked to see if they contain\n"
52826846 227" raid superblocks or filesystems. They are also check to see if\n"
64c4757e
NB
228" the variance in device size exceeds 1%.\n"
229" If any discrepancy is found, the array will not automatically\n"
230" be run, though the presence of a '--run' can override this\n"
231" caution.\n"
232"\n"
682c7051
NB
233" If the --size option is given, it is not necessary to list any subdevices\n"
234" in this command. They can be added later, before a --run.\n"
235" If no --size is given, the apparent size of the smallest drive given\n"
236" is used.\n"
237"\n"
64c4757e
NB
238" The General management options that are valid with --create are:\n"
239" --run : insist of running the array even if not all devices\n"
240" are present or some look odd.\n"
241" --readonly: start the array readonly - not supported yet.\n"
242"\n"
243;
244
245char Help_build[] =
9a9dab36 246"Usage: mdadm --build device -chunk=X --level=Y --raid-disks=Z devices\n"
64c4757e
NB
247"\n"
248" This usage is similar to --create. The difference is that it creates\n"
249" a legacy array with a superblock. With these arrays there is no\n"
250" different between initially creating the array and subsequently\n"
251" assembling the array, except that hopefully there is useful data\n"
252" there in the second case.\n"
253"\n"
254" The level may only be 0 or linear.\n"
255" All devices must be listed and the array will be started once complete.\n"
256;
257
258char Help_assemble[] =
9a9dab36
NB
259"Usage: mdadm --assemble device options...\n"
260" mdadm --assemble --scan options...\n"
64c4757e
NB
261"\n"
262"This usage assembles one or more raid arrays from pre-existing\n"
263"components.\n"
9a9dab36 264"For each array, mdadm needs to know the md device, the identify of\n"
52826846
NB
265"the array, and a number of sub devices. These can be found in a number\n"
266"of ways.\n"
267"\n"
268"The md device is either given on the command line or is found listed\n"
269"in the config file. The array identity is determined either from the\n"
270"--uuid or --super-minor commandline arguments, or from the config file,\n"
271"or from the first component device on the command line.\n"
64c4757e 272"\n"
52826846
NB
273"The different combinations of these are as follows:\n"
274" If the --scan option is not given, then only devices and identities\n"
275" listed on the command line are considered.\n"
276" The first device will be the array devices, and the remainder will\n"
277" examined when looking for components.\n"
278" If an explicit identity is given with --uuid or --super-minor, then\n"
279" Each device with a superblock which matches that identity is considered,\n"
280" otherwise every device listed is considered.\n"
64c4757e 281"\n"
52826846
NB
282" If the --scan option is given, and no devices are listed, then\n"
283" every array listed in the config file is considered for assembly.\n"
284" The identity can candidate devices are determined from the config file.\n"
64c4757e 285"\n"
52826846
NB
286" If the --scan option is given as well as one or more devices, then\n"
287" Those devices are md devices that are to be assembled. Their identity\n"
288" and components are determined from the config file.\n"
64c4757e 289"\n"
52826846
NB
290"The config file contains, apart from blank lines and comment lines that\n"
291"start with a has, two sorts of configuration lines, array lines and\n"
292"device lines.\n"
293"Each configuration line is constructed of a number of space separated\n"
294"words, and can be continued on subsequent physical lines by indenting\n"
295"those lines.\n"
64c4757e 296"\n"
52826846
NB
297"A device line starts with the word 'device' and then has a number of words\n"
298"which identify devices. These words should be names of devices in the filesystem,\n"
299"and can contain wildcards. There can be multiple words or each device line,\n"
300"and multiple device lines. All devices so listed are checked for relevant\n"
301"super blocks when assembling arrays.\n"
64c4757e 302"\n"
52826846
NB
303"An array line start with the word 'array'. This is followed by the name of\n"
304"the array device in the filesystem, e.g. '/dev/md2'. Subsequent words\n"
305"describe the identity of the array, used to recognise devices to include in the\n"
306"array. The identity can be given as a UUID with a word starting 'uuid=', or\n"
307"as a minor-number stored in the superblock using 'super-minor=', or as a list\n"
308"of devices. This is given as a comma separated list of names, possibly containing\n"
309"wildcards, preceeded by 'devices='. If multiple critea are given, than a device\n"
310"must match all of them to be considered.\n"
64c4757e
NB
311"\n"
312;
682c7051
NB
313
314
315/* name/number mappings */
316
317mapping_t r5layout[] = {
cd29a5c8
NB
318 { "left-asymmetric", 0},
319 { "right-asymmetric", 1},
320 { "left-symmetric", 2},
321 { "right-symmetric", 3},
682c7051
NB
322
323 { "default", 2},
324 { "la", 0},
325 { "ra", 1},
326 { "ls", 2},
327 { "rs", 3},
328 { NULL, 0}
329};
330
331mapping_t pers[] = {
332 { "linear", -1},
333 { "raid0", 0},
334 { "0", 0},
335 { "stripe", 0},
336 { "raid1", 1},
337 { "1", 1},
338 { "mirror", 1},
339 { "raid4", 4},
340 { "4", 4},
341 { "raid5", 5},
342 { "5", 5},
343 { NULL, 0}
344};