
Check Device Attributes with blkid and lsblk
Why Should You Care About Device Attributes? (And What Are They, Anyway?)
If you’re running a cloud server, VPS, Docker host, or even a gnarly bare-metal box, you’re going to deal with disks. And not just “hey, I have a disk!” — but “which disk is which, what’s its UUID, what filesystem is on it, and how do I make sure my data doesn’t disappear after a reboot?”
Ever been in a situation where your server boots and suddenly your data disk is missing, or your Docker volume is mounted as /dev/sdb
instead of /dev/sdc
? Or maybe you’re prepping a new VPS and want to make sure you’re formatting the right disk (not your root one — yikes!).
That’s where blkid and lsblk come in. These two command-line tools are your best friends for peeking under the hood of your Linux storage setup. Whether you’re a sysadmin, a developer, or just someone who likes to tinker, knowing how to check device attributes quickly can save you from a world of pain.
Three Big Questions: What, How, and Why?
- What exactly do
blkid
andlsblk
show you? - How do you use them in real-world scenarios (cloud, VPS, Docker, etc)?
- Why does it matter for automation, scripting, and avoiding disasters?
How Does It Work? (A Quick Dive Into the Algorithms and Structure)
blkid: The Filesystem Detective
blkid
is like the Sherlock Holmes of block devices. It scans your block devices (disks, partitions, USB sticks, etc.) and tells you all about their “attributes”: UUID, LABEL, filesystem type, and more. It does this by reading the superblocks and magic numbers on the device itself — not by trusting what’s in /etc/fstab
or elsewhere.
- UUID: Universally Unique Identifier. Never changes (unless you reformat).
- LABEL: Human-readable name you can set (e.g., “DATA” or “DOCKER_VOL”).
- TYPE: Filesystem type (ext4, xfs, btrfs, etc.).
- PARTUUID: Partition UUID (for GPT/MBR partition tables).
lsblk: The Block Device Map
lsblk
is your block device map. It shows you the tree of devices, partitions, and their mount points. It’s great for visualizing what’s attached, what’s mounted, and where.
- Shows device hierarchy (disk → partition → LVM → mountpoint).
- Shows size, type, mountpoint, and optionally UUID, LABEL, etc.
- Can output in tree, list, or JSON format for scripting.
Quick Setup: How to Check Device Attributes Instantly
Step 1: Install the Tools
On most modern Linux distros, both tools are included in the util-linux
package. If not:
sudo apt install util-linux # Debian/Ubuntu
sudo yum install util-linux # CentOS/RHEL
sudo dnf install util-linux # Fedora
Step 2: List All Block Devices
lsblk
This gives you a quick tree of all disks and partitions. Add -f
for filesystem info:
lsblk -f
Step 3: Get Detailed Attributes
blkid
This lists every block device with its UUID, LABEL, TYPE, etc. For a specific device:
blkid /dev/sda1
Step 4: Combine for Power
lsblk -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINT
This gives you a table with all the info you need, at a glance.
Real-World Examples: Good, Bad, and Ugly
Scenario | What Can Go Right | What Can Go Wrong | Advice |
---|---|---|---|
Mounting Data Disk on VPS | Use UUID in /etc/fstab for stable mounts. |
Use /dev/sdb (device name), which may change after reboot or hardware change. |
Always use blkid to get UUID, then mount by UUID. |
Docker Volume Mounts | Mount host path by UUID, avoid accidental data loss. | Mount wrong device, Docker fails to start containers. | Check with lsblk -f before configuring Docker volumes. |
Expanding Storage on Cloud | Identify new disk by size/UUID, format and mount safely. | Format wrong disk, lose data. | Double-check with lsblk and blkid before formatting. |
Beginner Mistakes and Common Myths
- Myth: Device names (
/dev/sda
,/dev/sdb
) are permanent.
Reality: They can change if you add or remove disks, or even after a reboot in cloud/VPS environments. - Mistake: Formatting or mounting by device name without checking attributes.
Fix: Always useblkid
andlsblk
to verify before making changes. - Myth: All filesystems support LABEL and UUID.
Reality: Some filesystems (like old FAT) may not support UUIDs or labels.
Similar Tools and Utilities
- fdisk -l: Lists partitions, but less info about filesystems and UUIDs.
- parted -l: Good for partitioning, but not as user-friendly for quick checks.
- findmnt: Shows mount points, but not device attributes.
- udevadm info: Super detailed, but overkill for most use cases.
But for the sweet spot of “what is this disk, what’s on it, and how do I use it safely?” — blkid
and lsblk
are the winners.
Statistics: Why UUIDs and Labels Matter
- According to Arch Wiki, using UUIDs in
/etc/fstab
is the recommended way to ensure reliable mounts, especially on cloud and virtualized systems. - Cloud providers (AWS, Azure, GCP) recommend mounting by UUID to avoid device name changes after instance resize or migration.
Interesting Facts and Non-Standard Usage
- You can use
lsblk -J
to get JSON output — perfect for scripts and automation! blkid
can be used in scripts to dynamically find and mount disks by label or UUID.- Some backup tools (like rsnapshot) can be configured to check for the correct disk UUID before running, to avoid backing up to the wrong drive.
- If you’re running a cluster (Kubernetes, Proxmox, etc.), you can use
lsblk
andblkid
in your provisioning scripts to automatically discover and mount new storage.
Automation and Scripting: New Opportunities
With lsblk
and blkid
, you can build scripts that:
- Automatically detect new disks and format/mount them by UUID or label.
- Verify that all expected disks are present and mounted correctly (great for monitoring and alerting).
- Generate
/etc/fstab
entries programmatically, reducing human error. - Integrate with configuration management tools (Ansible, Chef, Puppet) for idempotent storage setup.
Example: A bash snippet to mount all disks with label “DATA” at /mnt/dataX
:
for dev in $(blkid -L DATA); do
mountpoint="/mnt/data$(basename $dev)"
mkdir -p "$mountpoint"
mount "$dev" "$mountpoint"
done
Comparison Table: blkid vs lsblk vs Others
Tool | Shows Hierarchy | Shows UUID/LABEL | Filesystem Type | Scriptable Output | Best For |
---|---|---|---|---|---|
lsblk | Yes | Yes (with -f) | Yes | Yes (JSON, columns) | Overview, scripting, automation |
blkid | No | Yes | Yes | Yes (parseable) | Attributes, scripting, fstab |
fdisk -l | Partial | No | Partial | No | Partitioning, old-school checks |
parted -l | Partial | No | Partial | No | Partitioning, advanced layouts |
Official Resources
Conclusion: Why, How, and Where to Use These Tools
If you’re running any kind of server — cloud, VPS, Docker host, or dedicated — knowing your way around blkid
and lsblk
is a must. They’re fast, reliable, and script-friendly. They help you avoid classic mistakes (like mounting the wrong disk), automate your storage setup, and keep your data safe and organized.
- Why? Because device names change, but UUIDs and labels don’t. That means fewer surprises and less downtime.
- How? Use
lsblk -f
andblkid
before making any disk changes. Always mount by UUID in/etc/fstab
. - Where? Everywhere: VPS, cloud, Docker, dedicated servers. Especially when automating or scaling up.
Ready to put this into practice? If you need a new VPS, check out MangoHost VPS. For more power, try a dedicated server. And remember: always check your device attributes before you format, mount, or automate. Your data will thank you!

This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.