blkid

On this page 7

blkid is the Linux command-line utility that locates block devices and reports their attributes, such as the filesystem type, the UUID, the volume label and the partition identifiers. In Linux filesystem administration, it answers a basic but critical question: what is actually stored on this device, regardless of the kernel name it received during boot.

The tool is part of util-linux and is built on the libblkid library, which the same package uses inside mount, fsck, mkfs helpers and many installers. Because device names like /dev/sdb1 can change between boots, administrators use blkid to obtain stable identifiers for configuration files such as fstab, boot loader entries and initramfs scripts.

How blkid identifies a block device

blkid identifies a device by reading known signature locations on it and matching them against a database of format probes. Each filesystem, RAID member, LVM physical volume or swap area writes a superblock or magic number at a fixed offset, and libblkid checks these offsets for every supported format.

The library has two modes. The low-level probing mode (blkid -p) reads the device directly and bypasses all caches, which requires root privileges for most devices. The high-level mode consults a cache of earlier results and, on modern systems, information already collected by udev, so ordinary queries are fast and often work without root access.

Probing covers more than filesystems. blkid also reads the partition table, whether GPT or MBR, and reports partition-level values such as PARTUUID and PARTLABEL. These come from the partition table entry, not from the filesystem inside it, which is why they survive reformatting while the filesystem UUID does not.

The following table lists the main tags that blkid prints and where each value comes from.

TagSourceTypical use
TYPEFilesystem or container signatureSelecting the correct mount or fsck helper
UUIDFilesystem superblockStable fstab and boot entries
LABELFilesystem superblockHuman-readable mounting by name
PARTUUIDGPT entry or MBR disk signatureKernel root= parameter without initramfs
PARTLABELGPT partition entryNaming partitions independently of content
BLOCK_SIZEFilesystem superblockChecking alignment and format options
Common blkid output tags

Key blkid options and output formats

Without arguments, blkid prints one line per recognized device in a KEY="value" format. Options change which devices are scanned, how results are filtered and how the output is shaped for people or scripts.

OptionEffectWhen it helps
-pLow-level probe, ignores the cacheVerifying a freshly formatted device
-o valuePrints values onlyFeeding a single field into a script
-o exportPrints shell-friendly KEY=value linesSourcing results with eval
-s TAGShows only the named tagExtracting a UUID or TYPE
-t TAG=valueFilters devices by a tagFinding a device by label
-L and -UResolves a label or UUID to a deviceQuick lookups in shell sessions
-c /dev/nullDisables the cache fileAvoiding stale cached entries
Frequently used blkid options

For automation, the combination blkid -s UUID -o value /dev/sdb1 is a common idiom that returns a bare UUID string. Scripts that parse the default output with regular expressions are fragile, because the field order and quoting are not guaranteed to stay the same across versions.

On many distributions, the cache file lives at /run/blkid/blkid.tab or, on older systems, /etc/blkid.tab. A stale cache can report a device that no longer exists, so troubleshooting usually starts with a direct probe using -p.

blkid focuses on content identification, while neighboring tools in the Linux filesystem toolbox emphasize topology or mount state. Choosing the right one saves time and avoids misreading results.

ToolMain question it answersData source
blkidWhat format and identifiers does this device holdDirect probing or udev cache
lsblkHow are devices nested and where are they mountedsysfs and udev database
findmntWhat is mounted where, with which optionsMount table of the kernel
file -sWhat does the data on this device look likeGeneric magic signatures
wipefsWhich signatures exist, and can they be erasedlibblkid probing
blkid and neighboring tools

In practice, lsblk -f often replaces blkid for a quick overview, because it shows the device tree together with filesystem type, label and UUID. lsblk, however, depends on the udev database, so on a minimal rescue system without udev, blkid with -p remains the reliable choice.

Using blkid in configuration work

The most frequent practical use of blkid is writing persistent mount entries. An fstab line such as UUID=3f1c... /data ext4 defaults 0 2 continues to work when a new disk changes the kernel naming order, while a line with /dev/sdb1 could mount the wrong device or fail at boot.

Choosing between identifiers depends on what must stay stable. The decision table below summarizes typical cases.

SituationRecommended identifierReason
Permanent data disk in fstabUUIDUnique and independent of device order
Removable media with friendly namesLABELReadable, but must be kept unique
Kernel root without initramfsPARTUUIDThe kernel resolves it directly
Partition reformatted regularlyPARTUUID or PARTLABELSurvives a new filesystem
Cloned disks on one hostRegenerated UUIDDuplicates cause ambiguous mounts
Choosing an identifier from blkid output

blkid also helps with LVM, RAID and encryption. It reports types such as LVM2_member, linux_raid_member and crypto_LUKS, which tell an administrator that the device is a container rather than a mountable filesystem and must be activated or unlocked first.

Limitations and common mistakes with blkid

blkid is reliable, but several pitfalls recur in real administration. Most of them come from caching, privileges or duplicated identifiers rather than from defects in the tool.

  • Running without root can return incomplete results, because direct reads of many devices are restricted.
  • Trusting cached output after repartitioning can show outdated values; blkid -p or udevadm settle resolves this.
  • Cloning a disk with dd copies the filesystem UUID, so two devices report the same value until one is changed with tune2fs -U or xfs_admin -U.
  • Ambivalent signatures occur when old metadata survives a reformat; blkid may then refuse to report a type, and wipefs is used to remove the leftover signature.
  • Confusing UUID with PARTUUID in fstab or boot entries leads to unbootable systems after a partition is recreated.

A further subtlety is that blkid identifies but does not validate a filesystem. A recognized ext4 signature does not mean the filesystem is consistent; fsck is still required to check its integrity.

Stripped to the essentials

blkid is like a label reader for storage devices. When Linux starts, it gives disks temporary names, and those names can change from one day to the next. blkid looks inside each disk or partition and reads the permanent name tags written into it, such as a long unique ID and an optional human-readable label.

With those tags, the system can always find the right disk, even if cables are moved or a new drive is added. The key point is stability: blkid tells you what a device really is, not just where it happens to appear today.

Where it is applied

A system administrator adds a second 4 TB drive to a file server that already has one data disk. After a reboot, the new drive appears as /dev/sdb and the old data disk moves to /dev/sdc, so the existing fstab entry based on device names would mount the wrong disk at /srv/archive.

The administrator runs blkid -s UUID -o value /dev/sdc1 to read the UUID of the original ext4 filesystem, replaces the device name in fstab with UUID= followed by that value, and repeats the process for the newly formatted XFS volume. After mount -a and a test reboot, both filesystems mount at the correct paths regardless of the order in which the kernel detects the drives.