1 .\" Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .Nd "control utility for mirrored devices"
114 utility is used for mirror (RAID1) configurations.
115 After a mirror's creation, all components are detected and configured
117 All operations like failure detection, stale component detection, rebuild
118 of stale components, etc.\& are also done automatically.
121 utility uses on-disk metadata (stored in the provider's last sector) to store all needed
123 Since the last sector is used for this purpose, it is possible to place a root
124 file system on a mirror.
126 The first argument to
128 indicates an action to be performed:
129 .Bl -tag -width ".Cm deactivate"
132 The order of components is important, because a component's priority is based on its position
133 (starting from 0 to 255).
134 The component with the biggest priority is used by the
137 and is also used as a master component when resynchronization is needed,
138 e.g.\& after a power failure when the device was open for writing.
140 Additional options include:
141 .Bl -tag -width ".Fl b Ar balance"
143 Specifies balance algorithm to use, one of:
144 .Bl -tag -width ".Cm round-robin"
146 Read from the component with the lowest load.
147 This is the default balance algorithm.
149 Read from the component with the biggest priority.
151 Use round-robin algorithm when choosing component to read.
153 Split read requests, which are bigger than or equal to slice size on N pieces,
154 where N is the number of active components.
157 Do not synchronize after a power failure or system crash.
158 Assumes device is in consistent state.
160 Hardcode providers' names in metadata.
162 Turn off autosynchronization of stale components.
166 balance algorithm and an I/O READ request is bigger than or equal to this value,
167 the I/O request will be split into N pieces, where N is the number of active
169 Defaults to 4096 bytes.
172 Clear metadata on the given providers.
174 Configure the given device.
176 Additional options include:
177 .Bl -tag -width ".Fl p Ar priority"
179 Turn on autosynchronization of stale components.
181 Specifies balance algorithm to use.
183 Do not hardcode providers' names in metadata.
185 Synchronize device after a power failure or system crash.
187 Do not synchronize after a power failure or system crash.
188 Assumes device is in consistent state.
190 Hardcode providers' names in metadata.
192 Turn off autosynchronization of stale components.
194 Specifies priority for the given component
197 Specifies slice size for
202 Rebuild the given mirror components forcibly.
203 If autosynchronization was not turned off for the given device, this command
204 should be unnecessary.
206 Change the size of the given mirror.
208 Additional options include:
209 .Bl -tag -width ".Fl s Ar size"
211 New size of the mirror is expressed in logical block numbers.
212 This option can be omitted, then it will be automatically calculated to
213 maximum available size.
216 Add the given component(s) to the existing mirror.
218 Additional options include:
219 .Bl -tag -width ".Fl p Ar priority"
221 Hardcode providers' names in metadata.
223 Mark component(s) as inactive immediately after insertion.
225 Specifies priority of the given component(s).
228 Remove the given component(s) from the mirror and clear metadata on it.
230 Activate the given component(s), which were marked as inactive before.
232 Mark the given component(s) as inactive, so it will not be automatically
233 connected to the mirror.
235 Stop the given mirror and clear metadata on all its components.
237 Additional options include:
238 .Bl -tag -width ".Fl f"
240 Stop the given mirror even if it is opened.
243 Forget about components which are not connected.
244 This command is useful when a disk has failed and cannot be reconnected, preventing the
246 command from being used to remove it.
248 Stop the given mirror.
250 Additional options include:
251 .Bl -tag -width ".Fl f"
253 Stop the given mirror even if it is opened.
256 Dump metadata stored on the given providers.
271 Additional options include:
272 .Bl -tag -width ".Fl v"
277 Exit status is 0 on success, and 1 if the command fails.
279 Use 3 disks to setup a mirror.
280 Choose split balance algorithm, split only
281 requests which are bigger than or equal to 2kB.
283 mount it, then unmount it and stop device:
284 .Bd -literal -offset indent
285 gmirror label -v -b split -s 2048 data da0 da1 da2
286 newfs /dev/mirror/data
287 mount /dev/mirror/data /mnt
294 Create a mirror on disk with valid data (note that the last sector of the disk
295 will be overwritten).
296 Add another disk to this mirror,
297 so it will be synchronized with existing disk:
298 .Bd -literal -offset indent
299 gmirror label -v -b round-robin data da0
300 gmirror insert data da1
303 Create a mirror, but do not use automatic synchronization feature.
304 Add another disk and rebuild it:
305 .Bd -literal -offset indent
306 gmirror label -v -n -b load data da0 da1
307 gmirror insert data da2
308 gmirror rebuild data da2
312 Replace it with a brand new one:
313 .Bd -literal -offset indent
315 gmirror insert data da1
318 Create a mirror, deactivate one component, do the backup and connect it again.
319 It will not be resynchronized, if there is no need to do so (there were no writes in
321 .Bd -literal -offset indent
322 gmirror label data da0 da1
323 gmirror deactivate data da1
324 dd if=/dev/da1 of=/backup/data.img bs=1m
325 gmirror activate data da1
328 Doing kernel dumps to
332 This is possible, but some conditions have to be met.
333 First of all, a kernel dump will go only to one component and
335 always chooses the component with the highest priority.
336 Reading a dump from the mirror on boot will only work if the
338 balance algorithm is used (that way
340 will read only from the component with the highest priority).
341 If you use a different balance algorithm, you should add:
342 .Bd -literal -offset indent
343 gmirror configure -b prefer data
349 .Bd -literal -offset indent
350 gmirror configure -b round-robin data
356 The decision which component to choose for dumping is made when
359 If on the next boot a component with a higher priority will be available,
360 the prefer algorithm will choose to read from it and
363 If on the next boot a component with the highest priority will be synchronized,
364 the prefer balance algorithm will read from the next one, thus will find nothing
381 .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org
383 There should be a way to change a component's priority inside a running mirror.
385 There should be a section with an implementation description.
387 Documentation for sysctls
388 .Va kern.geom.mirror.*