blkid - locate/print block device attributes
blkid --label label | --uuid uuid
blkid [--no-encoding --garbage-collect --list-one --cache-file file] [--output format] [--match-tag tag] [--match-token NAME=value] [device...]
blkid --probe [--offset offset] [--output format] [--size size] [--match-tag tag] [--match-types list] [--usages list] [--no-part-details] device...
blkid --info [--output format] [--match-tag tag] device...
The blkid program is the command-line interface to working with the libblkid(3) library. It can determine the type of content (e.g., filesystem or swap) that a block device holds, and also the attributes (tokens, NAME=value pairs) from the content metadata (e.g., LABEL or UUID fields).
lsblk(8) provides more information, better control on
output formatting, easy to use in scripts and it does not require root
permissions to get actual information. blkid reads information
directly from devices and for non-root users it returns cached unverified
information. blkid is mostly designed for system services and to test
When device is specified, tokens from only this device are displayed. It is possible to specify multiple device arguments on the command line. If none is given, all partitions or unpartitioned devices which appear in /proc/partitions are shown, if they are recognized.
blkid has two main forms of operation: either searching for a device with a specific NAME=value pair, or displaying NAME=value pairs for one or more specified devices.
For security reasons blkid silently ignores all devices where the probing result is ambivalent (multiple colliding filesystems are detected). The low-level probing mode (-p) provides more information and extra exit status in this case. It’s recommended to use wipefs(8) to get a detailed overview and to erase obsolete stuff (magic strings) from the device.
The size and offset arguments may be followed by the multiplicative suffixes like KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB"), or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
-c, --cache-file cachefile
-H, --hint setting
This option forces blkid to use udev when used for LABEL or UUID tokens in --match-token. The goal is to provide output consistent with other utils (like mount(8), etc.) on systems where the same tag is used for multiple devices.
-L, --label label
Unfortunately, the original blkid(8) from e2fsprogs uses the -L option as a synonym for -o list. For better portability, use -l -o device -t LABEL=label and -o list in your scripts rather than the -L option.
-n, --match-types list
blkid --probe --match-types vfat,ext3,ext4 /dev/sda1
probes for vfat, ext3 and ext4 filesystems, and
blkid --probe --match-types nominix /dev/sda1
probes for all supported formats except minix filesystems. This option is only useful together with --probe.
-o, --output format
This output format is DEPRECATED in favour of the lsblk(8) command.
The udev output returns the ID_FS_AMBIVALENT tag if more superblocks are detected, and ID_PART_ENTRY_* tags are always returned for all partitions including empty partitions.
This output format is DEPRECATED.
The non-printing characters are encoded by ^ and M- notation and all potentially unsafe characters are escaped.
-O, --offset offset
Note that low-level probing also returns information about partition table type (PTTYPE tag) and partitions (PART_ENTRY_* tags). The tag names produced by low-level probing are based on names used internally by libblkid and it may be different than when executed without --probe (for example PART_ENTRY_UUID= vs PARTUUID=). See also --no-part-details.
-s, --match-tag tag
-S, --size size
-t, --match-token NAME=value
-u, --usages list
blkid --probe --usages filesystem,other /dev/sda1
probes for all filesystem and other (e.g., swap) formats, and
blkid --probe --usages noraid /dev/sda1
probes for all supported formats except RAIDs. This option is only useful together with --probe.
-U, --uuid uuid
If the specified device or device addressed by specified token (option --match-token) was found and it’s possible to gather any information about the device, an exit status 0 is returned. Note the option --match-tag filters output tags, but it does not affect exit status.
If the specified token was not found, or no (specified) devices could be identified, or it is impossible to gather any information about the device identifiers or device content an exit status of 2 is returned.
For usage or other errors, an exit status of 4 is returned.
If an ambivalent probing result was detected by low-level probing mode (-p), an exit status of 8 is returned.
The standard location of the /etc/blkid.conf config file can be overridden by the environment variable BLKID_CONF. The following options control the libblkid library:
Setting LIBBLKID_DEBUG=all enables debug output.
blkid was written by Andreas Dilger for libblkid and improved by Theodore Ts’o and Karel Zak.
For bug reports, use the issue tracker at <https://github.com/util-linux/util-linux/issues>.
The blkid command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.