System and processes
The blkid command
Shows the UUID, label and filesystem type of each device or partition.
Most useful options
-o, --output <formato>Output format: full (default), value (only the values), device (only the name) or export (NAME=value)-s, --match-tag <etiqueta>Shows only that tag, for example UUID or TYPE-t, --match-token NOMBRE=valorSearches for devices with that tag and value, for example TYPE=swap-U, --uuid <uuid>Finds the device with that filesystem UUID and shows its name-L, --label <etiqueta>Finds the device with that filesystem label and shows its name-p, --probeReads the device directly, without using the cacheCopy-ready examples
$ blkidUUID and type of each device it recognizes.Example output
/dev/sdb1: UUID="B4E1-2C7A" TYPE="vfat"
$ sudo blkid -p -s TYPE /dev/sdb1type of /dev/sdb1, read directly from the disk and without cache.Example output
/dev/sdb1: TYPE="vfat"
$ blkid -o value -s UUID /dev/sdb1only the UUID, without name or tag. Useful in a script.Example output
B4E1-2C7A
$ blkid -t TYPE=swaplists the swap areas it finds.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| blkid: error: /dev/sdz9: No such file or directory | With -p, blkid cannot find that device and exits with code 2. The name may have changed when another disk was connected. | Check the current names with lsblk and use the one listed there. |
| blkid: -t needs NAME=value pair | With -t you must write a NAME=value pair. Without the equals sign, blkid does not know what to search for. | Write -t TYPE=swap, not -t TYPE swap. |
Typical mistakes
- Without root, blkid uses cached data that may be out of date. To read the disk live, use sudo blkid -p.
- The blkid from e2fsprogs uses -L as a synonym of -o list. For portable scripts, use -l -o device -t LABEL=label, as the manual recommends.
- If a device has conflicting filesystem signatures, blkid skips it silently. With -p, exit status 8 points it out.
Differences from similar commands
FAQ
Why mount by UUID instead of /dev/sdb1?
Because the name /dev/sdb1 can change from one boot to the next depending on disk detection order. The UUID identifies the filesystem and does not change.
What does exit code 2 of blkid mean?
That it did not find the device or the value searched for, or could not read any information from it. Code 4 indicates a usage error.
How do I find a device by its label?
With blkid -L label. In scripts, better blkid -l -o device -t LABEL=label, which the manual recommends for portability.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course