Stable filesystem identifiers keep Linux mounts, boot entries, and automation tied to the correct storage even when kernel device names such as /dev/sdb1 or /dev/nvme0n1p2 change after a reboot or hardware change.
In Linux, blkid reads the identifier stored in filesystem metadata on the device itself, while findmnt can confirm whether a mounted filesystem matches a chosen UUID=… reference. This is the value commonly copied into /etc/fstab and other configuration that should survive device-name changes.
The command flow below was verified on Ubuntu 24.04 with an ext4 filesystem. Query the filesystem device itself, which is usually a partition or logical volume rather than the whole-disk node, because a raw disk such as /dev/sdb often reports partition-table metadata instead of a filesystem UUID, and minimal containers may not populate every udev-managed symlink under /dev/disk/by-uuid.
Steps to get a disk or partition UUID in Linux:
- Read the exact filesystem metadata from the target device with blkid.
$ sudo blkid /dev/loop4 /dev/loop4: LABEL="data" UUID="90e3b518-5ab8-4162-b977-25346b1ef034" BLOCK_SIZE="4096" TYPE="ext4"
Replace /dev/loop4 with the filesystem device path, such as /dev/sdb1, /dev/nvme0n1p1, or /dev/mapper/vg0-data.
- Print only the filesystem UUID when a configuration file or script needs the raw value without other metadata.
$ sudo blkid -s UUID -o value /dev/loop4 90e3b518-5ab8-4162-b977-25346b1ef034
If blkid prints no UUID, verify that the path points to the filesystem itself and not only to a whole-disk device that contains partitions.
- Confirm that a mounted filesystem with that UUID resolves to the expected device and mount point.
$ findmnt --source UUID=90e3b518-5ab8-4162-b977-25346b1ef034 --output TARGET,SOURCE,FSTYPE,OPTIONS TARGET SOURCE FSTYPE OPTIONS /mnt/data /dev/loop4 ext4 rw,relatime
findmnt only returns mounted filesystems, so use the blkid result directly when the target is not mounted yet.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
