Skip to main content

blkid — Show Block Device UUIDs and Labels

blkid prints identifying metadata for block devices (filesystem type, UUID, label, PARTUUID). Use it when you need a stable identifier for /etc/fstab, when you are mounting a new backup disk, or when you're verifying that a partition really contains the filesystem you expect. On WordPress VPS servers, this is commonly used to mount /mnt/backups and to confirm where database storage lives.

Quick Summary

Use sudo blkid to list all known devices, then mount by UUID in /etc/fstab (preferred) instead of hardcoding /dev/sdb1.

Mental Model

uuid-to-mount.txt
/dev/sdb1 -> UUID="6666-7777-..." -> /etc/fstab -> mounted at /mnt/backups

Prerequisites

blkid is provided by the util-linux package and is installed by default on most Linux distributions.

Verify it exists:

verify-blkid-installed.sh
which blkid
blkid --version

Core Syntax

blkid-syntax.sh
blkid [OPTIONS] [DEVICE...]

Most practical usage is either:

  • List all devices: sudo blkid
  • Query a single device: sudo blkid /dev/sdb1

Key Options

OptionWhat it doesExampleWordPress / VPS use case
-o <format>Choose output formatsudo blkid -o full /dev/sdb1Readable output with all tags
-o exportExport format for scriptssudo blkid -o export /dev/sdb1Easy parsing into env-like lines
-s <tag>Print only specific tag(s)sudo blkid -s UUID /dev/sdb1Focus on UUID only
-t NAME=VALUEFind device with a tokenblkid -t LABEL=BACKUPFind disks by label
-U <uuid>Convert UUID to deviceblkid -U 6666-...Find device path after reboot
-L <label>Convert LABEL to deviceblkid -L BACKUPMount by label (less stable than UUID)
-pProbe device (bypass cache)sudo blkid -p /dev/sdb1Refresh detection after changes
-c /dev/nullDisable cachesudo blkid -c /dev/null /dev/sdb1Avoid stale cache results

Examples (Commands + Expected Output)

Output varies

UUIDs and device names are examples. Always copy UUIDs from your own server.

List all block devices with filesystem signatures

blkid-list-all.sh
sudo blkid

Expected output:

example-output-blkid-list-all.txt
/dev/sda1: UUID="11111111-2222-3333-4444-555555555555" TYPE="ext4" PARTUUID="aaaa-bbbb"
/dev/sdb1: LABEL="BACKUP" UUID="66666666-7777-8888-9999-000000000000" TYPE="ext4" PARTUUID="cccc-dddd"

Use case: Identify the UUID of a new backup disk.

Query a single device

blkid-single-device.sh
sudo blkid /dev/sdb1

Expected output:

example-output-blkid-single-device.txt
/dev/sdb1: LABEL="BACKUP" UUID="66666666-7777-8888-9999-000000000000" TYPE="ext4" PARTUUID="cccc-dddd"

Use case: Confirm the filesystem type before you mount it.

blkid-uuid-only-value.sh
sudo blkid -s UUID -o value /dev/sdb1

Expected output:

example-output-blkid-uuid-only.txt
66666666-7777-8888-9999-000000000000

Use case: Paste only the UUID into /etc/fstab.

Find a device by UUID

blkid-find-device-by-uuid.sh
blkid -U 66666666-7777-8888-9999-000000000000

Expected output:

example-output-blkid-u.txt
/dev/sdb1

Use case: Map a UUID back to a device name after reboot.

Find a device by LABEL

blkid-find-device-by-label.sh
blkid -L BACKUP

Expected output:

example-output-blkid-l.txt
/dev/sdb1

Use case: Quick lookup when you label a dedicated backup disk.

Export output format for parsing

blkid-export-format.sh
sudo blkid -o export /dev/sdb1

Expected output:

example-output-blkid-export.txt
DEVNAME=/dev/sdb1
LABEL=BACKUP
UUID=66666666-7777-8888-9999-000000000000
TYPE=ext4
PARTUUID=cccc-dddd

Use case: Feed values into automation.

WordPress VPS Use Cases

SituationWhat you needCommandWhy it helps
Add a backup disk mountUUID and filesystem typesudo blkid /dev/sdb1Stable fstab entry and correct mount
Verify a DB volumeMount device identitysudo blkid /var/lib/mysqlConfirms where database storage lives
Repair mount failuresConfirm UUID did not changesudo blkidDetects formatting/replacement events

Troubleshooting

ProblemLikely causeFix
blkid prints nothing for a deviceNo filesystem signature existsFormat the partition (carefully) before mounting
Permission deniedNeeds root to read block metadataUse sudo blkid ...
UUID changedDevice was reformatted/replacedUpdate /etc/fstab and any scripts using the old UUID
Results look staleCache is outdatedUse sudo blkid -p or sudo blkid -c /dev/null

Best Practices

  • Prefer UUID-based mounts in /etc/fstab over raw /dev/sdX names.
  • Use lsblk -p -f alongside blkid to see mount points and filesystem IDs together.
Cheat Sheet
blkid-cheat-sheet.sh
sudo blkid
sudo blkid /dev/sdb1
sudo blkid -s UUID -o value /dev/sdb1
blkid -U <uuid>
blkid -L <label>
sudo blkid -o export /dev/sdb1
sudo blkid -p /dev/sdb1

What's Next