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"
121 utility is used for mirror (RAID1) configurations.
122 After a mirror's creation, all components are detected and configured
124 All operations like failure detection, stale component detection, rebuild
125 of stale components, etc.\& are also done automatically.
128 utility uses on-disk metadata (stored in the provider's last sector) to store all needed
130 Since the last sector is used for this purpose, it is possible to place a root
131 file system on a mirror.
133 The first argument to
135 indicates an action to be performed:
136 .Bl -tag -width ".Cm deactivate"
139 The order of components is important, because a component's priority is based on its position
140 (starting from 0 to 255).
141 The component with the biggest priority is used by the
144 and is also used as a master component when resynchronization is needed,
145 e.g.\& after a power failure when the device was open for writing.
147 Additional options include:
148 .Bl -tag -width ".Fl b Ar balance"
150 Specifies balance algorithm to use, one of:
151 .Bl -tag -width ".Cm round-robin"
153 Read from the component with the lowest load.
154 This is the default balance algorithm.
156 Read from the component with the biggest priority.
158 Use round-robin algorithm when choosing component to read.
160 Split read requests, which are bigger than or equal to slice size on N pieces,
161 where N is the number of active components.
164 Do not synchronize after a power failure or system crash.
165 Assumes device is in consistent state.
167 Hardcode providers' names in metadata.
169 Turn off autosynchronization of stale components.
173 balance algorithm and an I/O READ request is bigger than or equal to this value,
174 the I/O request will be split into N pieces, where N is the number of active
176 Defaults to 4096 bytes.
179 Clear metadata on the given providers.
183 but creates mirror without storing on-disk metadata in last sector.
184 This special "manual" operation mode assumes some external control to manage
185 mirror detection after reboot, device hot-plug and other external events.
187 Configure the given device.
189 Additional options include:
190 .Bl -tag -width ".Fl p Ar priority"
192 Turn on autosynchronization of stale components.
194 Specifies balance algorithm to use.
196 Do not hardcode providers' names in metadata.
198 Synchronize device after a power failure or system crash.
200 Do not synchronize after a power failure or system crash.
201 Assumes device is in consistent state.
203 Hardcode providers' names in metadata.
205 Turn off autosynchronization of stale components.
207 Specifies priority for the given component
210 Specifies slice size for
215 Rebuild the given mirror components forcibly.
216 If autosynchronization was not turned off for the given device, this command
217 should be unnecessary.
219 Change the size of the given mirror.
221 Additional options include:
222 .Bl -tag -width ".Fl s Ar size"
224 New size of the mirror is expressed in logical block numbers.
225 This option can be omitted, then it will be automatically calculated to
226 maximum available size.
229 Add the given component(s) to the existing mirror.
231 Additional options include:
232 .Bl -tag -width ".Fl p Ar priority"
234 Hardcode providers' names in metadata.
236 Mark component(s) as inactive immediately after insertion.
238 Specifies priority of the given component(s).
241 Remove the given component(s) from the mirror and clear metadata on it.
243 Activate the given component(s), which were marked as inactive before.
245 Mark the given component(s) as inactive, so it will not be automatically
246 connected to the mirror.
248 Stop the given mirror and clear metadata on all its components.
250 Additional options include:
251 .Bl -tag -width ".Fl f"
253 Stop the given mirror even if it is opened.
256 Forget about components which are not connected.
257 This command is useful when a disk has failed and cannot be reconnected, preventing the
259 command from being used to remove it.
261 Stop the given mirror.
263 Additional options include:
264 .Bl -tag -width ".Fl f"
266 Stop the given mirror even if it is opened.
269 Dump metadata stored on the given providers.
284 Additional options include:
285 .Bl -tag -width ".Fl v"
290 Exit status is 0 on success, and 1 if the command fails.
292 Use 3 disks to setup a mirror.
293 Choose split balance algorithm, split only
294 requests which are bigger than or equal to 2kB.
296 mount it, then unmount it and stop device:
297 .Bd -literal -offset indent
298 gmirror label -v -b split -s 2048 data da0 da1 da2
299 newfs /dev/mirror/data
300 mount /dev/mirror/data /mnt
307 Create a mirror on disk with valid data (note that the last sector of the disk
308 will be overwritten).
309 Add another disk to this mirror,
310 so it will be synchronized with existing disk:
311 .Bd -literal -offset indent
312 gmirror label -v -b round-robin data da0
313 gmirror insert data da1
316 Create a mirror, but do not use automatic synchronization feature.
317 Add another disk and rebuild it:
318 .Bd -literal -offset indent
319 gmirror label -v -n -b load data da0 da1
320 gmirror insert data da2
321 gmirror rebuild data da2
325 Replace it with a brand new one:
326 .Bd -literal -offset indent
328 gmirror insert data da1
331 Create a mirror, deactivate one component, do the backup and connect it again.
332 It will not be resynchronized, if there is no need to do so (there were no writes in
334 .Bd -literal -offset indent
335 gmirror label data da0 da1
336 gmirror deactivate data da1
337 dd if=/dev/da1 of=/backup/data.img bs=1m
338 gmirror activate data da1
343 variables can be used to configure behavior for all mirrors.
344 .Bl -tag -width indent
345 .It Va kern.geom.mirror.debug
346 Control the verbosity of kernel logging related to mirrors.
347 A value larger than 0 will enable debug logging.
348 .It Va kern.geom.mirror.timeout
349 The amount of time, in seconds, to wait for all copies of a mirror to
350 appear before starting the mirror.
351 Disks that appear after the mirror has been started are not automatically
353 .It Va kern.geom.mirror.idletime
354 The amount of time, in seconds, which must elapse after the last write to
355 a mirror before that mirror is marked clean.
356 Clean mirrors do not need to be synchronized after a power failure or
358 A small value may result in frequent overwrites of the disks' metadata
359 sectors, and thus may reduce the longevity of the disks.
360 .It Va kern.geom.mirror.disconnect_on_failure
361 Determine whether a disk is automatically removed from its mirror when an
362 I/O request to that disk fails.
363 .It Va kern.geom.mirror.sync_requests
364 The number of parallel I/O requests used while synchronizing a mirror.
365 This parameter may only be configured as a
368 .It Va kern.geom.mirror.sync_update_period
369 The period, in seconds, at which a synchronizing mirror's metadata is
371 Periodic updates are used to record a synchronization's progress so that
372 an interrupted synchronization may be resumed starting at the recorded
373 offset, rather than at the beginning.
374 A smaller value results in more accurate progress tracking, but also
375 increases the number of non-sequential writes to the disk being synchronized.
376 If the sysctl value is 0, no updates are performed until the synchronization
380 Doing kernel dumps to
382 providers is possible, but some conditions have to be met.
383 First of all, a kernel dump will go only to one component and
385 always chooses the component with the highest priority.
386 Reading a dump from the mirror on boot will only work if the
388 balance algorithm is used (that way
390 will read only from the component with the highest priority).
391 If you use a different balance algorithm, you should add:
392 .Bd -literal -offset indent
393 gmirror configure -b prefer data
399 .Bd -literal -offset indent
400 gmirror configure -b round-robin data
406 The decision which component to choose for dumping is made when
409 If on the next boot a component with a higher priority will be available,
410 the prefer algorithm will choose to read from it and
413 If on the next boot a component with the highest priority will be synchronized,
414 the prefer balance algorithm will read from the next one, thus will find nothing
432 .An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org
434 There should be a way to change a component's priority inside a running mirror.
436 There should be a section with an implementation description.