blkid system

the name tag for your disks.

The blkid man page is 300 lines long. You need one command and one concept: every filesystem has a unique ID that never changes.

You need to add a disk to fstab so it mounts automatically on boot. The entry needs a device identifier. You could use /dev/sdb1, but device names can change — add a new disk, reorder your SATA cables, plug in a USB drive first, and suddenly sdb1 is sdc1. Your fstab entry points at the wrong disk. Your data mount fails on boot. Your application can’t find its files. Your pager goes off at 3 AM.

UUIDs don’t change. Every filesystem gets a universally unique identifier when it’s formatted. The disk can move to a different port, a different server, a different continent — the UUID stays the same. blkid tells you what that UUID is.

Unless you’re running Windows then wtf none of this applies to you. But hey, come to the dark side, go install WSL2 and you can follow along. We’ll wait. Impatiently.

If you’re lazy like me (all sysadmins are!) then click here for the blkid cheat sheet.


Show all block device IDs

sudo blkid
/dev/sda1: UUID="a1b2c3d4-e5f6-7890-abcd-ef1234567890" TYPE="ext4" PARTUUID="1a2b3c4d-01"
/dev/sda2: UUID="b2c3d4e5-f6a7-8901-bcde-f12345678901" TYPE="swap" PARTUUID="1a2b3c4d-02"
/dev/sdb1: UUID="c3d4e5f6-a7b8-9012-cdef-123456789012" LABEL="data" TYPE="ext4"

Every partition with a filesystem. UUID, type, label if one exists, and partition UUID. This is the reference sheet you need when writing fstab entries.


Get info for one device

sudo blkid /dev/sdb1
/dev/sdb1: UUID="c3d4e5f6-a7b8-9012-cdef-123456789012" LABEL="data" TYPE="ext4"

Just the one you care about. Copy that UUID straight into fstab:

UUID=c3d4e5f6-a7b8-9012-cdef-123456789012  /mnt/data  ext4  defaults  0  2

Get just the UUID

sudo blkid -s UUID -o value /dev/sdb1
c3d4e5f6-a7b8-9012-cdef-123456789012

Just the UUID, nothing else. Perfect for scripts:

UUID=$(sudo blkid -s UUID -o value /dev/sdb1)
echo "UUID=$UUID  /mnt/data  ext4  defaults  0  2" | sudo tee -a /etc/fstab

Automate adding fstab entries without manually copy-pasting.


Get just the filesystem type

sudo blkid -s TYPE -o value /dev/sdb1
ext4

For when you need to know the filesystem type but don’t want to parse the full output.


Find a device by UUID

sudo blkid -U "c3d4e5f6-a7b8-9012-cdef-123456789012"
/dev/sdb1

Reverse lookup — you have a UUID (maybe from fstab) and want to know which device it corresponds to right now.


Find a device by label

sudo blkid -L "data"
/dev/sdb1

Same idea, but by filesystem label. Labels are human-friendly names you can set when formatting a disk.


blkid vs lsblk -f

Both show filesystem information. The difference:

blkid lsblk -f
Requires root Usually yes No
Shows mount points No Yes
Shows disk hierarchy No (flat list) Yes (tree view)
Shows PARTUUIDs Yes Not by default
Best for Getting UUIDs for fstab/scripts Quick overview of disk layout

Use lsblk to see the big picture. Use blkid when you need the exact UUID for a specific device.


The flags that actually matter

Flag What it does
-s TAG Show only a specific tag (UUID, TYPE, LABEL).
-o value Output just the value, not the tag name.
-U UUID Find the device with this UUID.
-L LABEL Find the device with this label.
-p Low-level probe (bypass cache).

“But I just use /dev/sdX—”

For now.

“Device names have always worked for me.” They work until they don’t. Add a new disk, plug in a USB drive before boot, or move a disk to a different SATA port, and /dev/sdb becomes /dev/sdc. Your fstab, your scripts, your mount commands — all pointing at the wrong disk. UUIDs are immune to this because they’re stored on the filesystem itself.

"lsblk shows me everything I need." lsblk -f shows UUIDs without root, which is great for looking. But blkid is better for scripting — the -s and -o value flags give you clean, parseable output that’s easy to assign to variables.

“I don’t use fstab.” Then every mount you do is temporary. Reboot the server and you’re remounting everything by hand. fstab with UUIDs is the correct, stable, permanent way to mount filesystems. blkid gives you the UUIDs you need to set it up.


blkid cheat sheet

You made it. Or you skipped straight here. Either way, no judgment. Copy and paste these. Pin them. Tattoo them on your forearm. Whatever works.

What you’re doing Command
Show all device IDs sudo blkid
Show one device sudo blkid /dev/sdb1
Get just the UUID sudo blkid -s UUID -o value /dev/sdb1
Get just the filesystem type sudo blkid -s TYPE -o value /dev/sdb1
Find device by UUID sudo blkid -U "uuid-string"
Find device by label sudo blkid -L "label"

The one command: sudo blkid /dev/sdb1 — get the UUID you need for fstab. Copy it, paste it, never worry about device name changes again.

Back to the top, you overachiever.