]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/geom/class/mirror/gmirror.8
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / sbin / geom / class / mirror / gmirror.8
1 .\" Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd December 31, 2006
28 .Dt GMIRROR 8
29 .Os
30 .Sh NAME
31 .Nm gmirror
32 .Nd "control utility for mirrored devices"
33 .Sh SYNOPSIS
34 .Nm
35 .Cm label
36 .Op Fl hnv
37 .Op Fl b Ar balance
38 .Op Fl s Ar slice
39 .Ar name
40 .Ar prov ...
41 .Nm
42 .Cm clear
43 .Op Fl v
44 .Ar prov ...
45 .Nm
46 .Cm configure
47 .Op Fl adhnv
48 .Op Fl b Ar balance
49 .Op Fl s Ar slice
50 .Ar name
51 .Nm
52 .Cm rebuild
53 .Op Fl v
54 .Ar name
55 .Ar prov ...
56 .Nm
57 .Cm insert
58 .Op Fl hiv
59 .Op Fl p Ar priority
60 .Ar name
61 .Ar prov ...
62 .Nm
63 .Cm remove
64 .Op Fl v
65 .Ar name
66 .Ar prov ...
67 .Nm
68 .Cm activate
69 .Op Fl v
70 .Ar name
71 .Ar prov ...
72 .Nm
73 .Cm deactivate
74 .Op Fl v
75 .Ar name
76 .Ar prov ...
77 .Nm
78 .Cm forget
79 .Op Fl v
80 .Ar name ...
81 .Nm
82 .Cm stop
83 .Op Fl fv
84 .Ar name ...
85 .Nm
86 .Cm dump
87 .Ar prov ...
88 .Nm
89 .Cm list
90 .Nm
91 .Cm status
92 .Nm
93 .Cm load
94 .Nm
95 .Cm unload
96 .Sh DESCRIPTION
97 The
98 .Nm
99 utility is used for mirror (RAID1) configurations.
100 After a mirror's creation, all components are detected and configured
101 automatically.
102 All operations like failure detection, stale component detection, rebuild
103 of stale components, etc.\& are also done automatically.
104 The
105 .Nm
106 utility uses on-disk metadata (stored in the provider's last sector) to store all needed
107 information.
108 Since the last sector is used for this purpose, it is possible to place a root
109 file system on a mirror.
110 .Pp
111 The first argument to
112 .Nm
113 indicates an action to be performed:
114 .Bl -tag -width ".Cm deactivate"
115 .It Cm label
116 Create a mirror.
117 The order of components is important, because a component's priority is based on its position
118 (starting from 0).
119 The component with the biggest priority is used by the
120 .Cm prefer
121 balance algorithm
122 and is also used as a master component when resynchronization is needed,
123 e.g.\& after a power failure when the device was open for writing.
124 .Pp
125 Additional options include:
126 .Bl -tag -width ".Fl b Ar balance"
127 .It Fl b Ar balance
128 Specifies balance algorithm to use, one of:
129 .Bl -tag -width ".Cm round-robin"
130 .It Cm load
131 Read from the component with the lowest load.
132 .It Cm prefer
133 Read from the component with the biggest priority.
134 .It Cm round-robin
135 Use round-robin algorithm when choosing component to read.
136 .It Cm split
137 Split read requests, which are bigger than or equal to slice size on N pieces,
138 where N is the number of active components.
139 This is the default balance algorithm.
140 .El
141 .It Fl h
142 Hardcode providers' names in metadata.
143 .It Fl n
144 Turn off autosynchronization of stale components.
145 .It Fl s Ar slice
146 When using the
147 .Cm split
148 balance algorithm and an I/O READ request is bigger than or equal to this value,
149 the I/O request will be split into N pieces, where N is the number of active
150 components.
151 Defaults to 4096 bytes.
152 .El
153 .It Cm clear
154 Clear metadata on the given providers.
155 .It Cm configure
156 Configure the given device.
157 .Pp
158 Additional options include:
159 .Bl -tag -width ".Fl b Ar balance"
160 .It Fl a
161 Turn on autosynchronization of stale components.
162 .It Fl b Ar balance
163 Specifies balance algorithm to use.
164 .It Fl d
165 Do not hardcode providers' names in metadata.
166 .It Fl h
167 Hardcode providers' names in metadata.
168 .It Fl n
169 Turn off autosynchronization of stale components.
170 .It Fl s Ar slice
171 Specifies slice size for
172 .Cm split
173 balance algorithm.
174 .El
175 .It Cm rebuild
176 Rebuild the given mirror components forcibly.
177 If autosynchronization was not turned off for the given device, this command
178 should be unnecessary.
179 .It Cm insert
180 Add the given component(s) to the existing mirror.
181 .Pp
182 Additional options include:
183 .Bl -tag -width ".Fl p Ar priority"
184 .It Fl h
185 Hardcode providers' names in metadata.
186 .It Fl i
187 Mark component(s) as inactive immediately after insertion.
188 .It Fl p Ar priority
189 Specifies priority of the given component(s).
190 .El
191 .It Cm remove
192 Remove the given component(s) from the mirror and clear metadata on it.
193 .It Cm activate
194 Activate the given component(s), which were marked as inactive before.
195 .It Cm deactivate
196 Mark the given component(s) as inactive, so it will not be automatically
197 connected to the mirror.
198 .It Cm forget
199 Forget about components which are not connected.
200 This command is useful when a disk has failed and cannot be reconnected, preventing the
201 .Cm remove
202 command from being used to remove it.
203 .It Cm stop
204 Stop the given mirror.
205 .Pp
206 Additional options include:
207 .Bl -tag -width ".Fl f"
208 .It Fl f
209 Stop the given mirror even if it is opened.
210 .El
211 .It Cm dump
212 Dump metadata stored on the given providers.
213 .It Cm list
214 See
215 .Xr geom 8 .
216 .It Cm status
217 See
218 .Xr geom 8 .
219 .It Cm load
220 See
221 .Xr geom 8 .
222 .It Cm unload
223 See
224 .Xr geom 8 .
225 .El
226 .Pp
227 Additional options include:
228 .Bl -tag -width ".Fl v"
229 .It Fl v
230 Be more verbose.
231 .El
232 .Sh EXIT STATUS
233 Exit status is 0 on success, and 1 if the command fails.
234 .Sh EXAMPLES
235 Use 3 disks to setup a mirror.
236 Choose split balance algorithm, split only
237 requests which are bigger than or equal to 2kB.
238 Create file system,
239 mount it, then unmount it and stop device:
240 .Bd -literal -offset indent
241 gmirror label -v -b split -s 2048 data da0 da1 da2
242 newfs /dev/mirror/data
243 mount /dev/mirror/data /mnt
244 \&...
245 umount /mnt
246 gmirror stop data
247 gmirror unload
248 .Ed
249 .Pp
250 Create a mirror on disk with valid data (note that the last sector of the disk
251 will be overwritten).
252 Add another disk to this mirror,
253 so it will be synchronized with existing disk:
254 .Bd -literal -offset indent
255 gmirror label -v -b round-robin data da0
256 gmirror insert data da1
257 .Ed
258 .Pp
259 Create a mirror, but do not use automatic synchronization feature.
260 Add another disk and rebuild it:
261 .Bd -literal -offset indent
262 gmirror label -v -n -b load data da0 da1
263 gmirror insert data da2
264 gmirror rebuild data da2
265 .Ed
266 .Pp
267 One disk failed.
268 Replace it with a brand new one:
269 .Bd -literal -offset indent
270 gmirror forget data
271 gmirror insert data da1
272 .Ed
273 .Pp
274 Create a mirror, deactivate one component, do the backup and connect it again.
275 It will not be resynchronized, if there is no need to do so (there were no writes in
276 the meantime):
277 .Bd -literal -offset indent
278 gmirror label data da0 da1
279 gmirror deactivate data da1
280 dd if=/dev/da1 of=/backup/data.img bs=1m
281 gmirror activate data da1
282 .Ed
283 .Sh NOTES
284 Doing kernel dumps to
285 .Nm
286 providers.
287 .Pp
288 This is possible, but some conditions have to be met.
289 First of all, a kernel dump will go only to one component and
290 .Nm
291 always chooses the component with the highest priority.
292 Reading a dump from the mirror on boot will only work if the
293 .Cm prefer
294 balance algorithm is used (that way
295 .Nm
296 will read only from the component with the highest priority).
297 If you use a different balance algorithm, you should add:
298 .Bd -literal -offset indent
299 gmirror configure -b prefer data
300 .Ed
301 .Pp
302 to the
303 .Pa /etc/rc.early
304 script and:
305 .Bd -literal -offset indent
306 gmirror configure -b round-robin data
307 .Ed
308 .Pp
309 to the
310 .Pa /etc/rc.local
311 script.
312 The decision which component to choose for dumping is made when
313 .Xr dumpon 8
314 is called.
315 If on the next boot a component with a higher priority will be available,
316 the prefer algorithm will choose to read from it and
317 .Xr savecore 8
318 will find nothing.
319 If on the next boot a component with the highest priority will be synchronized,
320 the prefer balance algorithm will read from the next one, thus will find nothing
321 there.
322 .Sh SEE ALSO
323 .Xr geom 4 ,
324 .Xr dumpon 8 ,
325 .Xr geom 8 ,
326 .Xr mount 8 ,
327 .Xr newfs 8 ,
328 .Xr savecore 8 ,
329 .Xr umount 8 ,
330 .Xr vinum 8
331 .Sh HISTORY
332 The
333 .Nm
334 utility appeared in
335 .Fx 5.3 .
336 .Sh AUTHORS
337 .An Pawel Jakub Dawidek Aq pjd@FreeBSD.org
338 .Sh BUGS
339 There should be a way to change a component's priority inside a running mirror.
340 .Pp
341 There should be a section with an implementation description.
342 .Pp
343 Documentation for sysctls
344 .Va kern.geom.mirror.*
345 is missing.