findfs
Find filesystem by label or UUID
TLDR
Search block devices by filesystem label
Search by filesystem UUID
Search by partition label (GPT or MAC partition table)
Search by partition UUID (GPT partition table only)
SYNOPSIS
findfs [fs-options] LABEL=label | UUID=uuid
PARAMETERS
LABEL=label
Search for filesystem by human-readable label name
UUID=uuid
Search for filesystem by unique identifier (e.g., 12345678-1234-1234-1234-123456789abc)
-t, --type FSTYPE
Restrict search to filesystems of type (e.g., ext4, vfat)
-o, --output FORMAT
Set output format (default: device; others: list, name, value, full)
--help
Display usage information
--version
Print version information
DESCRIPTION
findfs is a utility from the util-linux package designed to locate the block device associated with a filesystem using its LABEL or UUID. It is invaluable in boot scripts, fstab configurations, and automation tasks where device names like /dev/sda1 may change due to hardware reconfiguration or kernel updates.
The command internally invokes blkid(8) to scan all available block devices, matching the specified label or UUID, and outputs the full device path of the first match. For instance, running findfs LABEL=root might return /dev/sda2 if that partition has the label "root".
Labels are human-readable strings set with tools like e2label or fatlabel, while UUIDs are unique 128-bit identifiers generated during formatting. Using them ensures stability over volatile device node names. findfs accepts fs-options from blkid, allowing refinements like filesystem type restrictions. It exits with 0 on success, 4 if no match, or other codes for errors.
This tool promotes portable scripting, especially in environments with dynamic storage like LVM or RAID.
CAVEATS
Returns only the first matching device; scanning can be slow on systems with many block devices. Requires root for some blkid features. No match exits with code 4.
EXAMPLES
findfs LABEL=boot
Outputs: /dev/sda1 (if matching label)
findfs UUID=12345678-1234-1234-1234-123456789abc -t ext4
Outputs device with matching UUID and ext4 type
ROOTDEV=$(findfs LABEL=root)
Mounts via variable in scripts
HISTORY
Introduced in util-linux 2.14 (2008) as a convenience wrapper for blkid label/UUID searches, evolving with blkid enhancements in later releases like 2.23+ for better performance.


