GMIRROR(8)
π NAME π
okay so bestie, gmirror β like, the gmirror(8) manual page β is the control utility for mirrored devices. that's the whole vibe. π
β¨ SYNOPSIS β¨
to compile GEOM_MIRROR into your kernel, add these lines to your kernel configuration file:
options GEOM_MIRROR
alternatively, to load the GEOM_MIRROR module at boot time, add this line to your loader.conf(5):
geom_mirror_load="YES"
usage of the gmirror utility is literally this, no cap:
gmirror label [-Fhnv] [-b balance] [-s slice] name prov ...
gmirror clear [-v] prov ...
gmirror create [-Fnv] [-b balance] [-s slice] name prov ...
gmirror configure [-adfFhnv] [-b balance] [-s slice] name
gmirror configure [-v] -p priority name prov
gmirror rebuild [-v] name prov ...
gmirror resize [-v] [-s size] name
gmirror insert [-hiv] [-p priority] name prov ...
gmirror remove [-v] name prov ...
gmirror activate [-v] name prov ...
gmirror deactivate [-v] name prov ...
gmirror destroy [-fv] name ...
gmirror forget [-v] name ...
gmirror stop [-fv] name ...
gmirror dump prov ...
gmirror list
gmirror status
gmirror load
gmirror unload
π¦ DESCRIPTION π¦
the gmirror utility is used for mirror (RAID1) configurations. after a mirror's creation, all components are detected and configured automatically. all operations like failure detection, stale component detection, rebuild of stale components, etc. are also done automatically. the gmirror utility uses on-disk metadata (stored in the provider's last sector) to store all needed information. since the last sector is used for this purpose, it is possible to place a root file system on a mirror. iconic behavior, fr fr. β¨
the first argument to gmirror indicates an action to be performed:
π·οΈ label
create a mirror. the order of components is important, because a component's priority is based on its position (starting from 0 to 255). the component with the biggest priority is used by the prefer balance algorithm and is also used as a master component when resynchronization is needed, e.g. after a power failure when the device was open for writing.
Additional options include:
-b balanceβ specifies balance algorithm to use, one of:loadβ read from the component with the lowest load. this is the default balance algorithm.preferβ read from the component with the biggest priority.round-robinβ use round-robin algorithm when choosing component to read.splitβ split read requests, which are bigger than or equal to slice size onNpieces, whereNis the number of active components.
-Fβ do not synchronize after a power failure or system crash. assumes device is in consistent state.-hβ hardcode providers' names in metadata.-nβ turn off autosynchronization of stale components.-s sliceβ when using thesplitbalance algorithm and an I/O READ request is bigger than or equal to this value, the I/O request will be split intoNpieces, whereNis the number of active components. defaults to4096bytes.
π§Ή clear
clear metadata on the given providers.
π create
similar to label, but creates mirror without storing on-disk metadata in last sector. this special "manual" operation mode assumes some external control to manage mirror detection after reboot, device hot-plug and other external events.
π οΈ configure
configure the given device.
Additional options include:
-aβ turn on autosynchronization of stale components.-b balanceβ specifies balance algorithm to use.-dβ do not hardcode providers' names in metadata.-fβ synchronize device after a power failure or system crash.-Fβ do not synchronize after a power failure or system crash. assumes device is in consistent state.-hβ hardcode providers' names in metadata.-nβ turn off autosynchronization of stale components.-p priorityβ specifies priority for the given componentprov.-s sliceβ specifies slice size forsplitbalance algorithm.
π rebuild
rebuild the given mirror components forcibly. if autosynchronization was not turned off for the given device, this command should be unnecessary.
π resize
change the size of the given mirror.
Additional options include:
-s sizeβ new size of the mirror is expressed in logical block numbers. this option can be omitted, then it will be automatically calculated to maximum available size.
β insert
add the given component(s) to the existing mirror.
Additional options include:
-hβ hardcode providers' names in metadata.-iβ mark component(s) as inactive immediately after insertion.-p priorityβ specifies priority of the given component(s).
β remove
remove the given component(s) from the mirror and clear metadata on it.
π activate
activate the given component(s), which were marked as inactive before.
π deactivate
mark the given component(s) as inactive, so it will not be automatically connected to the mirror.
π₯ destroy
stop the given mirror and clear metadata on all its components.
Additional options include:
-fβ stop the given mirror even if it is opened.
π«₯ forget
forget about components which are not connected. this command is useful when a disk has failed and cannot be reconnected, preventing the remove command from being used to remove it.
π stop
stop the given mirror.
Additional options include:
-fβ stop the given mirror even if it is opened.
π¦ dump
dump metadata stored on the given providers.
π list
see geom(8).
π status
see geom(8).
β¬οΈ load
see geom(8).
β¬οΈ unload
see geom(8).
Additional options include:
-vβ be more verbose.
π EXIT STATUS π
exit status is 0 on success, and 1 if the command fails. periodt.
πΈ EXAMPLES πΈ
use 3 disks to setup a mirror. choose split balance algorithm, split only requests which are bigger than or equal to 2kB. create file system, mount it, then unmount it and stop device:
gmirror label -v -b split -s 2048 data da0 da1 da2
newfs /dev/mirror/data
mount /dev/mirror/data /mnt
...
umount /mnt
gmirror stop data
gmirror unload
create a mirror on disk with valid data (note that the last sector of the disk will be overwritten). add another disk to this mirror, so it will be synchronized with existing disk:
gmirror label -v -b round-robin data da0
gmirror insert data da1
create a mirror, but do not use automatic synchronization feature. add another disk and rebuild it:
gmirror label -v -n -b load data da0 da1
gmirror insert data da2
gmirror rebuild data da2
one disk failed. replace it with a brand new one:
gmirror forget data
gmirror insert data da1
create a mirror, deactivate one component, do the backup and connect it again. it will not be resynchronized, if there is no need to do so (there were no writes in the meantime):
gmirror label data da0 da1
gmirror deactivate data da1
dd if=/dev/da1 of=/backup/data.img bs=1m
gmirror activate data da1
ποΈ SYSCTL VARIABLES ποΈ
the following sysctl(8) variables can be used to configure behavior for all mirrors. lowkey important, bestie.
kern.geom.mirror.debug
control the verbosity of kernel logging related to mirrors. a value larger than 0 will enable debug logging.
kern.geom.mirror.timeout
the amount of time, in seconds, to wait for all copies of a mirror to appear before starting the mirror. disks that appear after the mirror has been started are not automatically added to the mirror.
kern.geom.mirror.idletime
the amount of time, in seconds, which must elapse after the last write to a mirror before that mirror is marked clean. clean mirrors do not need to be synchronized after a power failure or system crash.
small value warning π«Ά a small value may result in frequent overwrites of the disks' metadata sectors, and thus may reduce the longevity of the disks.
kern.geom.mirror.disconnect_on_failure
determine whether a disk is automatically removed from its mirror when an I/O request to that disk fails.
kern.geom.mirror.sync_requests
the number of parallel I/O requests used while synchronizing a mirror. this parameter may only be configured as a loader.conf(5) tunable.
kern.geom.mirror.sync_update_period
the period, in seconds, at which a synchronizing mirror's metadata is updated. periodic updates are used to record a synchronization's progress so that an interrupted synchronization may be resumed starting at the recorded offset, rather than at the beginning. a smaller value results in more accurate progress tracking, but also increases the number of non-sequential writes to the disk being synchronized. if the sysctl value is 0, no updates are performed until the synchronization is complete.
π¨ NOTES π¨ <small>(aka the kernel-dump lore, listen up)</small>
Okay bestie, so here's the tea β β dumping your kernel to gmirror providers? It's possible, like, genuinely doable, but there are some conditions that have to be met and you cannot skip them, no cap.
First of all (and this is the big one): a kernel dump will go only to one component, and gmirror always chooses the component with the highest priority. That's just how it is, periodt. π
Reading a dump from the mirror on boot will only work if the prefer balance algorithm is used β that way gmirror will read only from the component with the highest priority. Iconic, honestly. β¨
But if you use a different balance algorithm, you should create an rc(8) script that sets the balance algorithm to prefer, for example with the following command:
gmirror configure -b prefer data
Make sure that rcorder(8) schedules the new script before savecore(8) β like, do not skip this step, it's giving load-bearing. π₯
The desired balance algorithm can be restored later on by placing the following command in rc.local(8):
gmirror configure -b round-robin data
And now for the messy part, buckle up π:
- The decision of which component to choose for dumping is made when
dumpon(8)is called. Like, that's the moment, no takebacks. - If on the next boot a component with a higher priority will be available, the
preferalgorithm will choose to read from it andsavecore(8)will find nothing. π - If on the next boot a component with the highest priority will be synchronized, the
preferbalance algorithm will read from the next one, thus will find nothing there either. π
So yeah, priorities matter, timing matters, and savecore(8) is out here just vibing and finding nothing if you get it wrong. Choose wisely, bestie. π«Ά
π SEE ALSO π
Go read these, they're literally the supporting cast and they all ate π:
π HISTORY π
The gmirror utility appeared in FreeBSD 5.3. Vintage. Retro. A whole elder statesman of a utility and we respect her for it. πΈ
π AUTHORS π
Pawel Jakub Dawidek <pjd@FreeBSD.org> β main character energy fr fr, thank you for your service π«‘π
π BUGS π
The known gripes, laid out honestly, because we don't do censorship here:
- There should be a way to change a component's priority inside a running mirror. Currently? Nope. π
- There should be a section with an implementation description. It's just... not there. π
πΈ okay that's the whole page, you made it, I'm so proud of you π«Ά This one's the Debian build of the page, version check done on January 23, 2025 β go forth and mirror responsibly, babe π β¨π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms