]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/blkid.8
tests: logger with socat device
[thirdparty/util-linux.git] / misc-utils / blkid.8
1 .\" Copyright 2000 Andreas Dilger (adilger@turbolinux.com)
2 .\"
3 .\" This file may be copied under the terms of the GNU Public License.
4 .TH BLKID 8 "March 2013" "util-linux" "System Administration"
5 .SH NAME
6 blkid \- locate/print block device attributes
7 .SH SYNOPSIS
8 .B blkid
9 .BI \-L " label"
10 |
11 .BI \-U " uuid"
12
13 .B blkid
14 .RB [ \-dghlv ]
15 .RB [ \-c
16 .IR file ]
17 .RB [ \-o
18 .IR format ]
19 .RB [ \-s
20 .IR tag ]
21 .in +6
22 .RB [ \-t
23 .IR NAME=value ]
24 .RI [ device " ...]"
25 .in -6
26
27 .B blkid
28 .BR -p " [" \-O
29 .IR offset ]
30 .RB [ \-o
31 .IR format ]
32 .RB [ \-S
33 .IR size ]
34 .RB [ \-s
35 .IR tag ]
36 .in +9
37 .RB [ \-n
38 .IR list ]
39 .RB [ \-u
40 .IR list ]
41 .IR device " ..."
42 .in -9
43
44 .B blkid
45 .BR -i " [" \-o
46 .IR format ]
47 .RB [ \-s
48 .IR tag ]
49 .IR device " ..."
50
51 .SH DESCRIPTION
52 The
53 .B blkid
54 program is the command-line interface to working with the
55 .BR libblkid (3)
56 library. It can determine the type of content (e.g. filesystem or swap)
57 that a block device holds, and also the attributes (tokens, NAME=value pairs)
58 from the content metadata (e.g. LABEL or UUID fields).
59 .PP
60 It is recommended to use
61 .BR lsblk (8)
62 command to get information about block devices rather than blkid.
63 .BR lsblk (8)
64 provides more information, better control on output formatting and it does not
65 require root permissions to get actual information.
66 .PP
67 When
68 .I device
69 is specified, tokens from only this device are displayed.
70 It is possible to specify multiple
71 .I device
72 arguments on the command line.
73 If none is given, all devices which appear in
74 .I /proc/partitions
75 are shown, if they are recognized.
76 .PP
77 Note that
78 .B blkid
79 reads information directly from devices and for non-root users
80 it returns cached unverified information. It is better to use
81 .B lsblk --fs
82 to get a user-friendly overview of filesystems and devices.
83 .BR lsblk (8)
84 is also easy to use in scripts.
85 .B blkid
86 is mostly designed for system services and to test libblkid functionality.
87 .PP
88 .B blkid
89 has two main forms of operation: either searching for a device with a
90 specific NAME=value pair, or displaying NAME=value pairs for one or
91 more specified devices.
92 .SH OPTIONS
93 The \fIsize\fR and \fIoffset\fR arguments may be followed by the multiplicative
94 suffixes like KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB
95 (the "iB" is optional, e.g. "K" has the same meaning as "KiB"), or the suffixes
96 KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
97 .TP
98 .BI \-c " cachefile"
99 Read from
100 .I cachefile
101 instead of reading from the default cache file (see the CONFIGURATION FILE section
102 for more details). If you want to start with a clean cache (i.e. don't report
103 devices previously scanned but not necessarily available at this time), specify
104 .IR /dev/null .
105 .TP
106 .B \-d
107 Don't encode non-printing characters. The non-printing characters are encoded
108 by ^ and M- notation by default. Note that the \fB-o udev\fR output format uses
109 a different encoding which cannot be disabled.
110 .TP
111 .B \-g
112 Perform a garbage collection pass on the blkid cache to remove
113 devices which no longer exist.
114 .TP
115 .B \-h
116 Display a usage message and exit.
117 .TP
118 .B \-i
119 Display information about I/O Limits (aka I/O topology). The 'export' output format is
120 automatically enabled. This option can be used together with the \fB-p\fR option.
121 .TP
122 .B \-k
123 List all known filesystems and RAIDs and exit.
124 .TP
125 .B \-l
126 Look up only one device that matches the search parameter specified with the \fB-t\fR
127 option. If there are multiple devices that match the specified search
128 parameter, then the device with the highest priority is returned, and/or
129 the first device found at a given priority. Device types in order of
130 decreasing priority are: Device Mapper, EVMS, LVM, MD, and finally regular
131 block devices. If this option is not specified,
132 .B blkid
133 will print all of the devices that match the search parameter.
134 .TP
135 .BI \-L " label"
136 Look up the device that uses this filesystem \fIlabel\fR; this is equal to
137 .BR "-l -o device -t LABEL=\fIlabel\fR" .
138 This lookup method is able to reliably use /dev/disk/by-label
139 udev symlinks (dependent on a setting in /etc/blkid.conf). Avoid using the
140 symlinks directly; it is not reliable to use the symlinks without verification.
141 The \fB-L\fR option works on systems with and without udev.
142
143 Unfortunately, the original
144 .BR blkid (8)
145 from e2fsprogs uses the \fB-L\fR option as a
146 synonym for \fB-o list\fR. For better portability, use \fB-l -o device
147 -t LABEL=\fIlabel\fR and \fB-o list\fR in your scripts rather than the \fB-L\fR option.
148 .TP
149 .BI \-n " list"
150 Restrict the probing functions to the specified (comma-separated) \fIlist\fR of
151 superblock types (names).
152 The list items may be prefixed with "no" to specify the types which should be ignored.
153 For example:
154 .sp
155 blkid -p -n vfat,ext3,ext4 /dev/sda1
156 .sp
157 probes for vfat, ext3 and ext4 filesystems, and
158 .sp
159 blkid -p -n nominix /dev/sda1
160 .sp
161 probes for all supported formats except minix filesystems.
162 This option is only useful together with \fB-p\fR.
163 .TP
164 .BI \-o " format"
165 Use the specified output format. Note that the order of variables and
166 devices is not fixed. See also option \fB-s\fR. The
167 .I format
168 parameter may be:
169 .RS
170 .TP
171 .B full
172 print all tags (the default)
173 .TP
174 .B value
175 print the value of the tags
176 .TP
177 .B list
178 print the devices in a user-friendly format; this output format is unsupported
179 for low-level probing (\fB-p\fR or \fB-i\fR).
180
181 This output format is \fBDEPRECATED\fR in favour of the
182 .BR lsblk (8)
183 command.
184 .TP
185 .B device
186 print the device name only; this output format is always enabled for the \fB-L\fR
187 and \fB-U\fR options
188 .TP
189 .B udev
190 print key="value" pairs for easy import into the udev environment; the keys are
191 prefixed by ID_FS_ or ID_PART_ prefixes
192
193 The udev output returns the ID_FS_AMBIVALENT tag if more superblocks are detected,
194 and ID_PART_ENTRY_* tags are always returned for all partitions including empty
195 partitions. This output format is \fBDEPRECATED\fR.
196 .TP
197 .B export
198 print key=value pairs for easy import into the environment; this output format
199 is automatically enabled when I/O Limits (\fB-i\fR option) are requested.
200
201 The non-printing characters are encoded by ^ and M- notation and all
202 potentially unsafe characters are escaped.
203 .RE
204 .TP
205 .BI \-O " offset"
206 Probe at the given \fIoffset\fR (only useful with \fB-p\fR). This option can be
207 used together with the \fB-i\fR option.
208 .TP
209 .BI \-p
210 Switch to low-level superblock probing mode (bypassing the cache).
211
212 Note that low-level probing also returns information about partition table type
213 (PTTYPE tag) and partitions (PART_ENTRY_* tags).
214 .TP
215 .BI \-s " tag"
216 For each (specified) device, show only the tags that match
217 .IR tag .
218 It is possible to specify multiple
219 .B \-s
220 options. If no tag is specified, then all tokens are shown for all
221 (specified) devices.
222 In order to just refresh the cache without showing any tokens, use
223 .B "-s none"
224 with no other options.
225 .TP
226 .BI \-S " size"
227 Override the size of device/file (only useful with \fB-p\fR).
228 .TP
229 .BI \-t " NAME" = value
230 Search for block devices with tokens named
231 .I NAME
232 that have the value
233 .IR value ,
234 and display any devices which are found.
235 Common values for
236 .I NAME
237 include
238 .BR TYPE ,
239 .BR LABEL ,
240 and
241 .BR UUID .
242 If there are no devices specified on the command line, all block devices
243 will be searched; otherwise only the specified devices are searched.
244 .TP
245 .BI \-u " list"
246 Restrict the probing functions to the specified (comma-separated) \fIlist\fR of "usage" types.
247 Supported usage types are: filesystem, raid, crypto and other. The list items may be
248 prefixed with "no" to specify the usage types which should be ignored. For example:
249 .sp
250 blkid -p -u filesystem,other /dev/sda1
251 .sp
252 probes for all filesystem and other (e.g. swap) formats, and
253 .sp
254 blkid -p -u noraid /dev/sda1
255 .sp
256 probes for all supported formats except RAIDs.
257 This option is only useful together with \fB-p\fR.
258 .TP
259 .BI \-U " uuid"
260 Look up the device that uses this filesystem \fIuuid\fR. For more details see the \fB-L\fR option.
261 .TP
262 .B \-V
263 Display version number and exit.
264 .SH "RETURN CODE"
265 If the specified token was found, or if any tags were shown from (specified)
266 devices, 0 is returned.
267
268 If the specified token was not found, or no (specified) devices could be
269 identified, an exit code of 2 is returned.
270
271 For usage or other errors, an exit code of 4 is returned.
272
273 If an ambivalent low-level probing result was detected, an exit code of 8 is
274 returned.
275 .SH CONFIGURATION FILE
276 The standard location of the
277 .I /etc/blkid.conf
278 config file can be overridden by the environment variable BLKID_CONF.
279 The following options control the libblkid library:
280 .TP
281 .I SEND_UEVENT=<yes|not>
282 Sends uevent when
283 .I /dev/disk/by-{label,uuid,partuuid,partlabel}/
284 symlink does not match with LABEL, UUID, PARTUUID or PARTLABEL on the device. Default is "yes".
285 .TP
286 .I CACHE_FILE=<path>
287 Overrides the standard location of the cache file. This setting can be
288 overridden by the environment variable BLKID_FILE. Default is
289 .IR /run/blkid/blkid.tab ,
290 or
291 .I /etc/blkid.tab
292 on systems without a /run directory.
293 .TP
294 .I EVALUATE=<methods>
295 Defines LABEL and UUID evaluation method(s). Currently, the libblkid library
296 supports the "udev" and "scan" methods. More than one method may be specified in
297 a comma-separated list. Default is "udev,scan". The "udev" method uses udev
298 .I /dev/disk/by-*
299 symlinks and the "scan" method scans all block devices from the
300 .I /proc/partitions
301 file.
302 .SH AUTHOR
303 .B blkid
304 was written by Andreas Dilger for libblkid and improved by Theodore Ts'o
305 and Karel Zak.
306 .SH ENVIRONMENT
307 .IP "Setting LIBBLKID_DEBUG=all enables debug output."
308 .SH SEE ALSO
309 .BR libblkid (3),
310 .BR findfs (8),
311 .BR wipefs (8),
312 .BR lsblk (8),
313 .SH AVAILABILITY
314 The blkid command is part of the util-linux package and is available from
315 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.