xref: /freebsd/lib/geom/label/glabel.8 (revision e5b786625f7f82a1fa91e41823332459ea5550f9)
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 September 27, 2023
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
116REISERFS (directory
117.Pa /dev/reiserfs/ ) .
118.It
119NTFS (directory
120.Pa /dev/ntfs/ ) .
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.Xr glabel 8
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. E.g. for every node like
168.Pa /dev/label/bigdisk
169there will be additional entries for any partitions which the device
170contains, like
171.Pa /dev/label/bigdiskp1
172and
173.Pa /dev/label/bigdiskp1a .
174.Pp
175The first argument to
176.Nm
177indicates an action to be performed:
178.Bl -tag -width ".Cm destroy"
179.It Cm create
180Create temporary label
181.Ar name
182for the given provider.
183This is the
184.Dq manual
185method.
186The kernel module
187.Pa geom_label.ko
188will be loaded if it is not loaded already.
189.It Cm label
190Set up a label
191.Ar name
192for the given provider.
193This is the
194.Dq automatic
195method, where metadata is stored in a provider's last sector.
196The kernel module
197.Pa geom_label.ko
198will be loaded if it is not loaded already.
199.It Cm stop
200Turn off the given label by its
201.Ar name .
202This command does not touch on-disk metadata!
203.It Cm destroy
204Same as
205.Cm stop .
206.It Cm clear
207Clear metadata on the given devices.
208.It Cm dump
209Dump metadata stored on the given devices.
210.It Cm refresh
211Refresh / rediscover metadata from the given devices.
212.It Cm list
213See
214.Xr geom 8 .
215.It Cm status
216See
217.Xr geom 8 .
218.It Cm load
219See
220.Xr geom 8 .
221.It Cm unload
222See
223.Xr geom 8 .
224.El
225.Pp
226Additional options:
227.Bl -tag -width indent
228.It Fl f
229Force the removal of the specified labels.
230.It Fl v
231Be more verbose.
232.El
233.Sh SYSCTL VARIABLES
234The following
235.Xr sysctl 8
236variables can be used to control the behavior of the
237.Nm LABEL
238GEOM class.
239The default value is shown next to each variable.
240.Bl -tag -width indent
241.It Va kern.geom.label.debug : No 0
242Debug level of the
243.Nm LABEL
244GEOM class.
245This can be set to a number between 0 and 2 inclusive.
246If set to 0 minimal debug information is printed, and if set to 2 the
247maximum amount of debug information is printed.
248.El
249.Bl -tag -width indent
250.It Va kern.geom.label.*.enable : No 1
251Most
252.Nm LABEL
253providers implement a
254.Xr sysctl 8
255flag and a tunable variable named in the above format. This flag
256controls if the label provider will be active, tasting devices
257and creating label nodes in the
258.Xr devfs 5
259tree. It is sometimes desirable to disable certain label types if
260they conflict with other classes in complex GEOM topologies.
261.El
262.Sh EXIT STATUS
263Exit status is 0 on success, and 1 if the command fails.
264.Sh EXAMPLES
265The following example shows how to set up a label for disk
266.Dq Li da2 ,
267create a file system on it, and mount it:
268.Bd -literal -offset indent
269glabel label -v usr /dev/da2
270newfs /dev/label/usr
271mount /dev/label/usr /usr
272[...]
273umount /usr
274glabel stop usr
275glabel unload
276.Ed
277.Pp
278The next example shows how to set up a label for a UFS file system:
279.Bd -literal -offset indent
280tunefs -L data /dev/da4s1a
281mount /dev/ufs/data /mnt/data
282.Ed
283.Sh SEE ALSO
284.Xr geom 4 ,
285.Xr loader.conf 5 ,
286.Xr geom 8 ,
287.Xr mount 8 ,
288.Xr newfs 8 ,
289.Xr sysctl 8 ,
290.Xr tunefs 8 ,
291.Xr umount 8
292.Sh HISTORY
293The
294.Nm
295utility appeared in
296.Fx 5.3 .
297.Sh AUTHORS
298.An Pawel Jakub Dawidek Aq Mt pjd@FreeBSD.org
299