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"
109 utility is used for mirror (RAID1) configurations.
110 After a mirror's creation, all components are detected and configured
112 All operations like failure detection, stale component detection, rebuild
113 of stale components, etc.\& are also done automatically.
116 utility uses on-disk metadata (stored in the provider's last sector) to store all needed
118 Since the last sector is used for this purpose, it is possible to place a root
119 file system on a mirror.
121 The first argument to
123 indicates an action to be performed:
124 .Bl -tag -width ".Cm deactivate"
127 The order of components is important, because a component's priority is based on its position
128 (starting from 0 to 255).
129 The component with the biggest priority is used by the
132 and is also used as a master component when resynchronization is needed,
133 e.g.\& after a power failure when the device was open for writing.
135 Additional options include:
136 .Bl -tag -width ".Fl b Ar balance"
138 Specifies balance algorithm to use, one of:
139 .Bl -tag -width ".Cm round-robin"
141 Read from the component with the lowest load.
142 This is the default balance algorithm.
144 Read from the component with the biggest priority.
146 Use round-robin algorithm when choosing component to read.
148 Split read requests, which are bigger than or equal to slice size on N pieces,
149 where N is the number of active components.
152 Do not synchronize after a power failure or system crash.
153 Assumes device is in consistent state.
155 Hardcode providers' names in metadata.
157 Turn off autosynchronization of stale components.
161 balance algorithm and an I/O READ request is bigger than or equal to this value,
162 the I/O request will be split into N pieces, where N is the number of active
164 Defaults to 4096 bytes.
167 Clear metadata on the given providers.
169 Configure the given device.
171 Additional options include:
172 .Bl -tag -width ".Fl p Ar priority"
174 Turn on autosynchronization of stale components.
176 Specifies balance algorithm to use.
178 Do not hardcode providers' names in metadata.
180 Synchronize device after a power failure or system crash.
182 Do not synchronize after a power failure or system crash.
183 Assumes device is in consistent state.
185 Hardcode providers' names in metadata.
187 Turn off autosynchronization of stale components.
189 Specifies priority for the given component
192 Specifies slice size for
197 Rebuild the given mirror components forcibly.
198 If autosynchronization was not turned off for the given device, this command
199 should be unnecessary.
201 Add the given component(s) to the existing mirror.
203 Additional options include:
204 .Bl -tag -width ".Fl p Ar priority"
206 Hardcode providers' names in metadata.
208 Mark component(s) as inactive immediately after insertion.
210 Specifies priority of the given component(s).
213 Remove the given component(s) from the mirror and clear metadata on it.
215 Activate the given component(s), which were marked as inactive before.
217 Mark the given component(s) as inactive, so it will not be automatically
218 connected to the mirror.
220 Stop the given mirror and clear metadata on all its components.
222 Additional options include:
223 .Bl -tag -width ".Fl f"
225 Stop the given mirror even if it is opened.
228 Forget about components which are not connected.
229 This command is useful when a disk has failed and cannot be reconnected, preventing the
231 command from being used to remove it.
233 Stop the given mirror.
235 Additional options include:
236 .Bl -tag -width ".Fl f"
238 Stop the given mirror even if it is opened.
241 Dump metadata stored on the given providers.
256 Additional options include:
257 .Bl -tag -width ".Fl v"
262 Exit status is 0 on success, and 1 if the command fails.
264 Use 3 disks to setup a mirror.
265 Choose split balance algorithm, split only
266 requests which are bigger than or equal to 2kB.
268 mount it, then unmount it and stop device:
269 .Bd -literal -offset indent
270 gmirror label -v -b split -s 2048 data da0 da1 da2
271 newfs /dev/mirror/data
272 mount /dev/mirror/data /mnt
279 Create a mirror on disk with valid data (note that the last sector of the disk
280 will be overwritten).
281 Add another disk to this mirror,
282 so it will be synchronized with existing disk:
283 .Bd -literal -offset indent
284 gmirror label -v -b round-robin data da0
285 gmirror insert data da1
288 Create a mirror, but do not use automatic synchronization feature.
289 Add another disk and rebuild it:
290 .Bd -literal -offset indent
291 gmirror label -v -n -b load data da0 da1
292 gmirror insert data da2
293 gmirror rebuild data da2
297 Replace it with a brand new one:
298 .Bd -literal -offset indent
300 gmirror insert data da1
303 Create a mirror, deactivate one component, do the backup and connect it again.
304 It will not be resynchronized, if there is no need to do so (there were no writes in
306 .Bd -literal -offset indent
307 gmirror label data da0 da1
308 gmirror deactivate data da1
309 dd if=/dev/da1 of=/backup/data.img bs=1m
310 gmirror activate data da1
313 Doing kernel dumps to
317 This is possible, but some conditions have to be met.
318 First of all, a kernel dump will go only to one component and
320 always chooses the component with the highest priority.
321 Reading a dump from the mirror on boot will only work if the
323 balance algorithm is used (that way
325 will read only from the component with the highest priority).
326 If you use a different balance algorithm, you should add:
327 .Bd -literal -offset indent
328 gmirror configure -b prefer data
334 .Bd -literal -offset indent
335 gmirror configure -b round-robin data
341 The decision which component to choose for dumping is made when
344 If on the next boot a component with a higher priority will be available,
345 the prefer algorithm will choose to read from it and
348 If on the next boot a component with the highest priority will be synchronized,
349 the prefer balance algorithm will read from the next one, thus will find nothing
366 .An Pawel Jakub Dawidek Aq pjd@FreeBSD.org
368 There should be a way to change a component's priority inside a running mirror.
370 There should be a section with an implementation description.
372 Documentation for sysctls
373 .Va kern.geom.mirror.*