Quick take: The blkid command prints the UUID, filesystem type, and label of block devices. sudo blkid lists them all, and sudo blkid /dev/sdX1 shows one — exactly the information you need to write stable /etc/fstab entries.

Introduction

The blkid command (block ID) identifies block devices by reporting their UUID, filesystem type, and label. UUIDs are the stable identifiers you should use in /etc/fstab instead of device names like /dev/sdb1, which can change between boots — so blkid is a key tool when configuring permanent mounts.

Syntax

The basic syntax of the blkid command is:

blkid [OPTIONS] [DEVICE]

Common Options and Parameters

The most useful options and parameters for the blkid command:

OptionDescription
(default)List all block devices with UUID, type, and label.
DEVICEShow details for a specific device.
-s UUIDShow only the UUID tag.
-o value -s UUIDOutput just the UUID value (scriptable).
-L LABELFind the device with a given label.
-U UUIDFind the device with a given UUID.

Practical Examples

Real blkid commands you can run today:

# List all devices with UUIDs and types
sudo blkid
# Show one device
sudo blkid /dev/sdb1
# Print just the UUID (for scripts/fstab)
sudo blkid -s UUID -o value /dev/sdb1
# Find the device for a label
sudo blkid -L data
# Find the device for a UUID
sudo blkid -U 1234-ABCD

Tips and Best Practices

  • Use the UUID from blkid in /etc/fstab rather than the device name, so mounts stay correct even if disk ordering changes.
  • blkid -s UUID -o value /dev/sdX1 prints just the bare UUID, perfect for scripts and copy-paste into fstab.
  • lsblk -f shows similar information in a tree; blkid is better for scripting a single value.

Final Thoughts

blkid reports the UUID, type, and label of block devices — the stable identifiers you need for reliable /etc/fstab entries. Use its scriptable -s UUID -o value form to grab a bare UUID, and reach for it whenever you set up a permanent mount. It complements lsblk, which gives the friendlier tree overview.

FAQ: blkid Command in Linux

How do I find a partition's UUID in Linux?+

Run sudo blkid to list every device with its UUID, type, and label, or sudo blkid /dev/sdX1 for one. Use sudo blkid -s UUID -o value /dev/sdX1 to print just the UUID.

Why use UUIDs instead of device names in fstab?+

Device names like /dev/sdb1 can change when disks are added or reordered, breaking mounts. A UUID is tied to the filesystem itself, so fstab entries using UUIDs stay correct across reboots.

What is the difference between blkid and lsblk?+

blkid focuses on identifiers — UUID, type, and label — and is easy to script for a single value. lsblk shows the whole device tree with sizes and mount points. Use blkid for UUIDs and lsblk for an overview.

How do I get just the UUID for a script?+

Use sudo blkid -s UUID -o value /dev/sdX1, which outputs only the bare UUID with no labels, ready to paste into /etc/fstab or use in a script.

How do I find a device by its label?+

Use sudo blkid -L labelname, which returns the device path for the filesystem with that label.

Need help with Linux servers or infrastructure?

Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.

Hire Me for Support