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.
Use sudo blkid to list all known devices, then mount by UUID in /etc/fstab (preferred) instead of hardcoding /dev/sdb1.
Mental Model
/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:
which blkid
blkid --version
Core Syntax
blkid [OPTIONS] [DEVICE...]
Most practical usage is either:
- List all devices:
sudo blkid - Query a single device:
sudo blkid /dev/sdb1
Key Options
| Option | What it does | Example | WordPress / VPS use case |
|---|---|---|---|
-o <format> | Choose output format | sudo blkid -o full /dev/sdb1 | Readable output with all tags |
-o export | Export format for scripts | sudo blkid -o export /dev/sdb1 | Easy parsing into env-like lines |
-s <tag> | Print only specific tag(s) | sudo blkid -s UUID /dev/sdb1 | Focus on UUID only |
-t NAME=VALUE | Find device with a token | blkid -t LABEL=BACKUP | Find disks by label |
-U <uuid> | Convert UUID to device | blkid -U 6666-... | Find device path after reboot |
-L <label> | Convert LABEL to device | blkid -L BACKUP | Mount by label (less stable than UUID) |
-p | Probe device (bypass cache) | sudo blkid -p /dev/sdb1 | Refresh detection after changes |
-c /dev/null | Disable cache | sudo blkid -c /dev/null /dev/sdb1 | Avoid stale cache results |
Examples (Commands + Expected Output)
UUIDs and device names are examples. Always copy UUIDs from your own server.
List all block devices with filesystem signatures
sudo blkid
Expected output:
/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
sudo blkid /dev/sdb1
Expected output:
/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.
Print only the UUID value (script-friendly)
sudo blkid -s UUID -o value /dev/sdb1
Expected output:
66666666-7777-8888-9999-000000000000
Use case: Paste only the UUID into /etc/fstab.
Find a device by UUID
blkid -U 66666666-7777-8888-9999-000000000000
Expected output:
/dev/sdb1
Use case: Map a UUID back to a device name after reboot.
Find a device by LABEL
blkid -L BACKUP
Expected output:
/dev/sdb1
Use case: Quick lookup when you label a dedicated backup disk.
Export output format for parsing
sudo blkid -o export /dev/sdb1
Expected output:
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
| Situation | What you need | Command | Why it helps |
|---|---|---|---|
| Add a backup disk mount | UUID and filesystem type | sudo blkid /dev/sdb1 | Stable fstab entry and correct mount |
| Verify a DB volume | Mount device identity | sudo blkid /var/lib/mysql | Confirms where database storage lives |
| Repair mount failures | Confirm UUID did not change | sudo blkid | Detects formatting/replacement events |
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
blkid prints nothing for a device | No filesystem signature exists | Format the partition (carefully) before mounting |
| Permission denied | Needs root to read block metadata | Use sudo blkid ... |
| UUID changed | Device was reformatted/replaced | Update /etc/fstab and any scripts using the old UUID |
| Results look stale | Cache is outdated | Use sudo blkid -p or sudo blkid -c /dev/null |
Best Practices
- Prefer UUID-based mounts in
/etc/fstabover raw/dev/sdXnames. - Use
lsblk -p -falongsideblkidto see mount points and filesystem IDs together.
Cheat Sheet
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