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.
| Tag | Source | Typical use |
|---|---|---|
| TYPE | Filesystem or container signature | Selecting the correct mount or fsck helper |
| UUID | Filesystem superblock | Stable fstab and boot entries |
| LABEL | Filesystem superblock | Human-readable mounting by name |
| PARTUUID | GPT entry or MBR disk signature | Kernel root= parameter without initramfs |
| PARTLABEL | GPT partition entry | Naming partitions independently of content |
| BLOCK_SIZE | Filesystem superblock | Checking alignment and format options |
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.
| Option | Effect | When it helps |
|---|---|---|
-p | Low-level probe, ignores the cache | Verifying a freshly formatted device |
-o value | Prints values only | Feeding a single field into a script |
-o export | Prints shell-friendly KEY=value lines | Sourcing results with eval |
-s TAG | Shows only the named tag | Extracting a UUID or TYPE |
-t TAG=value | Filters devices by a tag | Finding a device by label |
-L and -U | Resolves a label or UUID to a device | Quick lookups in shell sessions |
-c /dev/null | Disables the cache file | Avoiding stale cached entries |
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 compared with lsblk and related tools
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.
| Tool | Main question it answers | Data source |
|---|---|---|
| blkid | What format and identifiers does this device hold | Direct probing or udev cache |
| lsblk | How are devices nested and where are they mounted | sysfs and udev database |
| findmnt | What is mounted where, with which options | Mount table of the kernel |
| file -s | What does the data on this device look like | Generic magic signatures |
| wipefs | Which signatures exist, and can they be erased | libblkid probing |
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.
| Situation | Recommended identifier | Reason |
|---|---|---|
| Permanent data disk in fstab | UUID | Unique and independent of device order |
| Removable media with friendly names | LABEL | Readable, but must be kept unique |
| Kernel root without initramfs | PARTUUID | The kernel resolves it directly |
| Partition reformatted regularly | PARTUUID or PARTLABEL | Survives a new filesystem |
| Cloned disks on one host | Regenerated UUID | Duplicates cause ambiguous mounts |
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 -porudevadm settleresolves this. - Cloning a disk with dd copies the filesystem UUID, so two devices report the same value until one is changed with
tune2fs -Uorxfs_admin -U. - Ambivalent signatures occur when old metadata survives a reformat; blkid may then refuse to report a type, and
wipefsis 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.