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