xref: /freebsd/lib/geom/label/glabel.8 (revision f5f40dd63bc7acbb5312b26ac1ea1103c12352a6)
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.Dd April 19, 2024
26.Dt GLABEL 8
27.Os
28.Sh NAME
29.Nm glabel
30.Nd "disk labelization control utility"
31.Sh SYNOPSIS
32.Nm
33.Cm create
34.Op Fl v
35.Ar name
36.Ar dev
37.Nm
38.Cm destroy
39.Op Fl fv
40.Ar name ...
41.Nm
42.Cm label
43.Op Fl v
44.Ar name
45.Ar dev
46.Nm
47.Cm stop
48.Op Fl fv
49.Ar name ...
50.Nm
51.Cm clear
52.Op Fl v
53.Ar dev ...
54.Nm
55.Cm dump
56.Ar dev ...
57.Nm
58.Cm refresh
59.Ar dev ...
60.Nm
61.Cm list
62.Nm
63.Cm status
64.Nm
65.Cm load
66.Nm
67.Cm unload
68.Sh DESCRIPTION
69The
70.Nm
71utility is used for GEOM provider labelization.
72A label can be set up on a GEOM provider in two ways:
73.Dq manual
74or
75.Dq automatic .
76When using the
77.Dq manual
78method, no metadata are stored on the devices, so a label has to be configured
79by hand every time it is needed.
80The
81.Dq automatic
82method uses on-disk metadata to store the label and detect it automatically in
83the future.
84.Pp
85This GEOM class also provides volume label detection for file systems.
86Those labels cannot be set with
87.Nm ,
88but must be set with the appropriate file system utility, e.g.\& for UFS
89the file system label is set with
90.Xr tunefs 8 .
91Currently supported file systems are:
92.Pp
93.Bl -bullet -offset indent -compact
94.It
95UFS1 volume names (directory
96.Pa /dev/ufs/ ) .
97.It
98UFS2 volume names (directory
99.Pa /dev/ufs/ ) .
100.It
101UFS1 file system IDs (directory
102.Pa /dev/ufsid/ ) .
103.It
104UFS2 file system IDs (directory
105.Pa /dev/ufsid/ ) .
106.It
107MSDOSFS (FAT12, FAT16, FAT32) (directory
108.Pa /dev/msdosfs/ ) .
109.It
110CD ISO9660 (directory
111.Pa /dev/iso9660/ ) .
112.It
113EXT2FS (directory
114.Pa /dev/ext2fs/ ) .
115.It
116NTFS (directory
117.Pa /dev/ntfs/ ) .
118.It
119Swap Linux (directory
120.Pa /dev/swaplinux/ ) .
121.El
122.Pp
123Support for partition metadata is implemented for:
124.Pp
125.Bl -bullet -offset indent -compact
126.It
127GPT labels (directory
128.Pa /dev/gpt/ ) .
129.It
130GPT UUIDs (directory
131.Pa /dev/gptid/ ) .
132.El
133.Pp
134Generic disk ID strings are exported as labels in the format
135.Pa /dev/diskid/GEOM_CLASS-ident
136e.g.
137.Pa /dev/diskid/DISK-6QG3Z026  .
138.Pp
139Generic labels created and managed solely by
140.Nm
141are created in the
142.Pa /dev/label/
143directory.
144Note that generic, automatic labels occupy some space on the device
145and thus should not be added to a device already containing a file system.
146In particular,
147.Nm
148reserves the last sector of the device to store the label information.
149If the device already contains a file system,
150.Nm
151will overwrite the last sector, possibly damaging the file system, and the
152file system may later overwrite the label sector.
153Instead, create a label before initializing the file system, and initialize
154that file system on the device created by
155.Nm
156under the
157.Pa /dev/label/
158directory.
159Then the file system will correctly account for the space occupied by the
160generic label,
161since the
162.Nm
163device will be one sector smaller than the device from which it was created.
164.Pp
165Note that for all label types, nested GEOM classes will cause additional
166device nodes to be created, with context-specific data appended to their
167names.
168E.g. for every node like
169.Pa /dev/label/bigdisk
170there will be additional entries for any partitions which the device
171contains, like
172.Pa /dev/label/bigdiskp1
173and
174.Pa /dev/label/bigdiskp1a .
175.Pp
176.Nm
177requires write access to a device to create, modify, and destroy
178"automatic" labels.
179It will fail to persist changes if they are applied while a file
180system on the device is currently mounted.
181To ensure that modifications are stored across a reboot, the file system
182needs to be unmounted first.
183If the device holds the system's root file system, entering into
184single user mode and mounting in read-only mode is required to persist
185the change.
186.Pp
187The first argument to
188.Nm
189indicates an action to be performed:
190.Bl -tag -width ".Cm destroy"
191.It Cm create
192Create temporary label
193.Ar name
194for the given provider.
195This is the
196.Dq manual
197method.
198The kernel module
199.Pa geom_label.ko
200will be loaded if it is not loaded already.
201.It Cm label
202Set up a label
203.Ar name
204for the given provider.
205This is the
206.Dq automatic
207method, where metadata is stored in a provider's last sector.
208The kernel module
209.Pa geom_label.ko
210will be loaded if it is not loaded already.
211.It Cm stop
212Turn off the given label by its
213.Ar name .
214This command does not touch on-disk metadata!
215.It Cm destroy
216Same as
217.Cm stop .
218.It Cm clear
219Clear metadata on the given devices.
220.It Cm dump
221Dump metadata stored on the given devices.
222.It Cm refresh
223Refresh / rediscover metadata from the given devices.
224.It Cm list
225See
226.Xr geom 8 .
227.It Cm status
228See
229.Xr geom 8 .
230.It Cm load
231See
232.Xr geom 8 .
233.It Cm unload
234See
235.Xr geom 8 .
236.El
237.Pp
238Additional options:
239.Bl -tag -width indent
240.It Fl f
241Force the removal of the specified labels.
242.It Fl v
243Be more verbose.
244.El
245.Sh SYSCTL VARIABLES
246The following
247.Xr sysctl 8
248variables can be used to control the behavior of the
249.Nm LABEL
250GEOM class.
251The default value is shown next to each variable.
252.Bl -tag -width indent
253.It Va kern.geom.label.debug : No 0
254Debug level of the
255.Nm LABEL
256GEOM class.
257This can be set to a number between 0 and 2 inclusive.
258If set to 0 minimal debug information is printed, and if set to 2 the
259maximum amount of debug information is printed.
260.El
261.Bl -tag -width indent
262.It Va kern.geom.label.*.enable : No 1
263Most
264.Nm LABEL
265providers implement a
266.Xr sysctl 8
267flag and a tunable variable named in the above format.
268This flag controls if the label provider will be active, tasting devices
269and creating label nodes in the
270.Xr devfs 4
271tree.
272It is sometimes desirable to disable certain label types if they
273conflict with other classes in complex GEOM topologies.
274.El
275.Sh EXIT STATUS
276Exit status is 0 on success, and 1 if the command fails.
277.Sh EXAMPLES
278The following example shows how to set up a label for disk
279.Dq Li da2 ,
280create a file system on it, and mount it:
281.Bd -literal -offset indent
282glabel label -v usr /dev/da2
283newfs /dev/label/usr
284mount /dev/label/usr /usr
285[...]
286umount /usr
287glabel stop usr
288glabel unload
289.Ed
290.Pp
291The next example shows how to set up a label for a UFS file system:
292.Bd -literal -offset indent
293tunefs -L data /dev/da4s1a
294mount /dev/ufs/data /mnt/data
295.Ed
296.Sh SEE ALSO
297.Xr geom 4 ,
298.Xr loader.conf 5 ,
299.Xr geom 8 ,
300.Xr mount 8 ,
301.Xr newfs 8 ,
302.Xr sysctl 8 ,
303.Xr tunefs 8 ,
304.Xr umount 8
305.Sh HISTORY
306The
307.Nm
308utility appeared in
309.Fx 5.3 .
310.Sh AUTHORS
311.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org
312