]>
Commit | Line | Data |
---|---|---|
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 | ||
32 | char Version[] = "mdctl - v0.2 - 06 June 2001\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 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 | ||
81 | char short_options[]="-ABCDEhVvc:l:p:n:x:u:c:sarfRSow"; | |
82 | struct 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'}, | |
89 | /* after those will normally come the name of the md device */ | |
90 | {"help", 0, 0, 'h'}, | |
91 | {"version", 0, 0, 'V'}, | |
92 | {"verbose", 0, 0, 'v'}, | |
93 | ||
94 | /* For create or build: */ | |
95 | {"chunk", 1, 0, 'c'}, | |
96 | {"rounding", 1, 0, 'c'}, /* for linear, chunk is really a rounding number */ | |
97 | {"level", 1, 0, 'l'}, /* 0,1,4,5,linear */ | |
98 | {"parity", 1, 0, 'p'}, /* {left,right}-{a,}symetric */ | |
99 | {"layout", 1, 0, 'p'}, | |
100 | {"raid-disks",1, 0, 'n'}, | |
101 | {"spare-disks",1,0, 'x'}, | |
102 | ||
103 | /* For assemble */ | |
104 | {"uuid", 1, 0, 'u'}, | |
105 | {"config", 1, 0, 'c'}, | |
106 | {"scan", 0, 0, 's'}, | |
107 | {"force", 0, 0, 'f'}, | |
108 | /* Management */ | |
109 | {"add", 0, 0, 'a'}, | |
110 | {"remove", 0, 0, 'r'}, | |
111 | {"fail", 0, 0, 'f'}, | |
112 | {"set-faulty",0, 0, 'f'}, | |
113 | {"run", 0, 0, 'R'}, | |
114 | {"stop", 0, 0, 'S'}, | |
115 | {"readonly", 0, 0, 'o'}, | |
116 | {"readwrite", 0, 0, 'w'}, | |
117 | ||
118 | {0, 0, 0, 0} | |
119 | }; | |
120 | ||
121 | char Usage[] = | |
122 | "Usage: mdctl --help\n" | |
123 | " for help\n" | |
124 | ; | |
125 | ||
126 | char Help[] = | |
127 | "Usage: mdctl --create device options...\n" | |
128 | " mdctl --assemble device options...\n" | |
129 | " mdctl --build device options...\n" | |
130 | " mdctl --detail device\n" | |
131 | " mdctl --examine device\n" | |
132 | " mdctl device options...\n" | |
133 | " mdctl is used for controlling Linux md devices (aka RAID arrays)\n" | |
134 | " For detail help on major modes use, e.g.\n" | |
135 | " mdctl --assemble --help\n" | |
136 | "\n" | |
137 | "Any parameter that does not start with '-' is treated as a device name\n" | |
138 | "The first such name is normally the name of an md device. Subsequent\n" | |
139 | "names are names of component devices." | |
140 | "\n" | |
141 | "Available options are:\n" | |
142 | " --create -C : Create a new array\n" | |
143 | " --assemble -A : Assemble an existing array\n" | |
144 | " --build -B : Build a legacy array without superblock\n" | |
145 | " --detail -D : Print detail of a given md array\n" | |
146 | " --examine -E : Print content of md superblock on device\n" | |
147 | " --help -h : This help message or, after above option,\n" | |
148 | " mode specific help message\n" | |
149 | " --version -V : Print version information for mdctl\n" | |
150 | " --verbose -v : Be more verbose about what is happening\n" | |
151 | "\n" | |
152 | " For create or build:\n" | |
153 | " --chunk= -c : chunk size of kibibytes\n" | |
154 | " --rounding= : rounding factor for linear array (==chunck size)\n" | |
155 | " --level= -l : raid level: 0,1,4,5,linear. 0 or linear for build\n" | |
156 | " --paritiy= -p : raid5 parity algorith: {left,right}-{,a}symmetric\n" | |
157 | " --layout= : same as --parity\n" | |
158 | " --raid-disks= -n : number of active devices in array\n" | |
159 | " --spare-disks= -x : number of spares (eXtras) to allow space for\n" | |
160 | "\n" | |
161 | " For assemble:\n" | |
162 | " --uuid= -u : uuid of array to assemble. Devices which don't\n" | |
163 | " have this uuid are excluded\n" | |
164 | " --config= -c : config file\n" | |
165 | " --scan -s : scan config file for missing information\n" | |
166 | " --force -f : Assemble the array even if some superblocks appear out-of-date\n" | |
167 | "\n" | |
168 | " General management:\n" | |
169 | " --add -a : add, or hotadd subsequent devices\n" | |
170 | " --remove -r : remove subsequent devices\n" | |
171 | " --fail -f : mark subsequent devices a faulty\n" | |
172 | " --set-faulty : same as --fail\n" | |
173 | " --run -R : start a partially built array\n" | |
174 | " --stop -S : deactive array, releasing all resources\n" | |
175 | " --readonly -o : mark array as readonly\n" | |
176 | " --readwrite -w : mark array as readwrite\n" | |
177 | ; | |
178 | ||
179 | ||
180 | char Help_create[] = | |
181 | "Usage: mdctl --create device -chunk=X --level=Y --raid-disks=Z devices\n" | |
182 | "\n" | |
183 | " This usage will initialise a new md array and possibly associate some\n" | |
184 | " devices with it. If enough devices are given to complete the array,\n" | |
185 | " the array will be activated. Otherwise it will be left inactive\n" | |
186 | " to be competed and activated by subsequent management commands.\n" | |
187 | "\n" | |
188 | " As devices are added, they are checked to see if they contain\n" | |
189 | " raid superblock or filesystems. They are also check to see if\n" | |
190 | " the variance in device size exceeds 1%.\n" | |
191 | " If any discrepancy is found, the array will not automatically\n" | |
192 | " be run, though the presence of a '--run' can override this\n" | |
193 | " caution.\n" | |
194 | "\n" | |
195 | " The General management options that are valid with --create are:\n" | |
196 | " --run : insist of running the array even if not all devices\n" | |
197 | " are present or some look odd.\n" | |
198 | " --readonly: start the array readonly - not supported yet.\n" | |
199 | "\n" | |
200 | ; | |
201 | ||
202 | char Help_build[] = | |
203 | "Usage: mdctl --build device -chunk=X --level=Y --raid-disks=Z devices\n" | |
204 | "\n" | |
205 | " This usage is similar to --create. The difference is that it creates\n" | |
206 | " a legacy array with a superblock. With these arrays there is no\n" | |
207 | " different between initially creating the array and subsequently\n" | |
208 | " assembling the array, except that hopefully there is useful data\n" | |
209 | " there in the second case.\n" | |
210 | "\n" | |
211 | " The level may only be 0 or linear.\n" | |
212 | " All devices must be listed and the array will be started once complete.\n" | |
213 | ; | |
214 | ||
215 | char Help_assemble[] = | |
216 | "Usage: mdctl --assemble device options...\n" | |
217 | " mdctl --assemble --scan options...\n" | |
218 | "\n" | |
219 | "This usage assembles one or more raid arrays from pre-existing\n" | |
220 | "components.\n" | |
221 | "For each array, mdctl needs to know the md device, the uuid, and\n" | |
222 | "a number of sub devices. These can be found in a number of ways.\n" | |
223 | "\n" | |
224 | "The md device is either given before --scan or is found from the\n" | |
225 | "config file. In the latter case, multiple md devices can be started\n" | |
226 | "with a single mdctl command.\n" | |
227 | "\n" | |
228 | "The uuid can be given with the --uuid option, or can be found in\n" | |
229 | "in the config file, or will be taken from the super block on the first\n" | |
230 | "subdevice listed on the command line or in a subsequent --add command.\n" | |
231 | "\n" | |
232 | "Devices can be given on the --assemble command line, on subsequent\n" | |
233 | "'mdctl --add' command lines, or from the config file. Only devices\n" | |
234 | "which have an md superblock which contains the right uuid will be\n" | |
235 | "considered for any device.\n" | |
236 | "\n" | |
237 | "The config file is only used if explicitly named with --config or\n" | |
238 | "requested with --scan. In the later case, '/etc/md.conf' is used.\n" | |
239 | "\n" | |
240 | "If --scan is not given, then the config file will only be used\n" | |
241 | "to find uuids for md arrays.\n" | |
242 | "\n" | |
243 | "The format of the config file is:\n" | |
244 | " not yet documented\n" | |
245 | "\n" | |
246 | ; |