blkid — filesystem UUID, label and type
The blkid command prints the UUID, label and type of the filesystem on a device — what goes into /etc/fstab.
Cheat sheet
7 commands Printable version-
sudo blkidevery device with a filesystem -
sudo blkid /dev/vdb1one device -
sudo blkid -s UUID -o value /dev/vdb1just the UUID, for scripts -
sudo blkid -L datawhich device has the label data -
sudo blkid -U 5d1c0f4e-…which device has this UUID -
sudo blkid -p /dev/vdbthe disk itself: its table -
lsblk -fthe same as a tree
Overview
blkid reads the start of a device and reports what is written there. For a
partition with a filesystem it is one line of pairs:
/dev/vdb1: LABEL="data" UUID="…" TYPE="ext4" …. With -o export the same pairs come
one per line:
| Tag | Belongs to | Comes from |
|---|---|---|
UUID |
the filesystem | set by mkfs, changes on every new mkfs |
LABEL |
the filesystem | mkfs.ext4 -L, e2label |
TYPE |
the filesystem | ext4, xfs, swap, vfat |
PARTUUID |
the partition in the table | set by fdisk or parted when the partition is created |
PARTLABEL |
the partition in GPT | the name from mkpart data … |
In /etc/fstab a partition is referred to by UUID or
label: UUID=… or LABEL=data. A name like /dev/vdb1
depends on the order in which disks are attached and may go to another disk after a
reboot. More on the fstab line in mount.
Run blkid with sudo. Without root it cannot read the devices and prints only what
it cached earlier — sometimes nothing.
Options
5The full list is in man blkid.
| Option | What it does | Example |
|---|---|---|
-s --match-tag TAG |
Print only this tag — UUID, LABEL, TYPE; may be repeated. | sudo blkid -s UUID /dev/vdb1 |
-o --output value|export|list |
Output format; value prints bare values, export prints NAME=value lines. | sudo blkid -s UUID -o value /dev/vdb1 |
-L --label LABEL |
Print the device that has this label. | sudo blkid -L data |
-U --uuid UUID |
Print the device that has this UUID. | sudo blkid -U 3f6c1a2e-9b7d-4c55-8e21-6d0b9a4f7c13 |
-p --probe |
Probe the device directly, bypassing the cache; on a whole disk shows PTTYPE. | sudo blkid -p /dev/vdb |
Nothing found. Try a shorter query.
Recipes
4Compare an fstab line with the device
If it does not, fix fstab. mkfs is not the answer here: it wipes the data.
Find a device by label or UUID
What is on a disk with no filesystem
Troubleshooting
5blkid prints nothing
The device holds neither a filesystem nor a partition table — a new disk. The exit
code in this case is 2. Or blkid ran without sudo. sudo blkid -p shows what is
really on the disk.
The output has only PARTLABEL and PARTUUID
The partition is in the table, but there is no filesystem on it: UUID, LABEL and
TYPE appear after mkfs.
The UUID in fstab is not found
After a new mkfs the filesystem has a new UUID. Take it from sudo blkid and fix the
fstab line. findmnt --verify checks the table before a reboot.
Two partitions have the same UUID
The partition was copied whole (dd, a cloned disk). Change the copy's UUID:
sudo tune2fs -U random /dev/vdc1 for ext4 — see Filesystems.
fstab has PARTUUID instead of UUID
Both work, but they are different values: PARTUUID= looks up the partition in the
table, UUID= looks up the filesystem. The key in fstab must match the blkid tag.
Terms
2- filesystem UUID
- A filesystem identifier allowing references independent of its current device name. Also appears in: Filesystems: ext4, xfs, fsck, lsblk, mkfs
- filesystem label
- A short name given to a filesystem at creation (mkfs.ext4 -L) or later (e2label). It finds the partition: LABEL=data in fstab, blkid -L data. Also appears in: Software RAID with mdadm, mkfs, qemu-img, Disk quotas
See also
- mount — add a partition to fstab and mount it.
- mkfs — create a filesystem; the UUID and label come from it.
- lsblk —
lsblk -fshows the same tags as a tree. - fdisk-parted — partitions, their PARTUUID and PARTLABEL.
- filesystems — change the label and UUID with tune2fs.
- loop-device — a practice disk made from a file.
Found an inaccuracy? Report an error in the article