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