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