Home / Alt manpages / findfs(8)

  • findfs(8)
  • Admin command
  • linux

Find a Block Device by UUID or Label with findfs

Your fstab says UUID, your rescue shell says /dev/sdb3, and you need to know whether they are the same thing, which is where findfs earns its keep. You will finish with a repeatable way to turn a filesystem label, filesystem UUID, partition UUID or partition label into the device path Linux is using.

That is handy before inspecting a disk, checking a mount configuration or handing a stable identifier to another command. Allow about ten minutes.

  • Versions. The examples use findfs from util-linux 2.41.3, while the installed manpage is generated for util-linux 2.39.3. The tags and exit statuses used here are the same in both.
  • Privileges. The normal lookup is read-only and needs no sudo. Root can expose more devices, but it will not fix a misspelled identifier.

1. Confirm the installed command

Check which binary your shell will run, then ask it for its version and syntax:

$ command -v findfs
/home/linuxbrew/.linuxbrew/sbin/findfs
$ findfs --version
findfs from util-linux 2.41.3
$ findfs --help

Usage:
 findfs [options] {LABEL,UUID,PARTUUID,PARTLABEL}=<value>

Your path and version can differ. The contract is one argument in the form NAME=value, and the installed manual documents four names:

  • LABEL is a filesystem label.
  • UUID is a filesystem UUID.
  • PARTUUID is a partition identifier.
  • PARTLABEL is a partition name.

Checkpoint

If findfs --help does not show the tag you intend to use, stop and read the manpage for that installed version instead of guessing a spelling.

2. Inspect identifiers before choosing one

List the identifiers your system can see. This also shows the difference between a filesystem and a partition:

$ lsblk --fs
NAME    FSTYPE LABEL UUID                                 MOUNTPOINTS
md2     ext4         242175d2-d353-417c-98f9-341c92a571d2 /

$ blkid
/dev/md2: UUID="242175d2-d353-417c-98f9-341c92a571d2" TYPE="ext4"
/dev/sdb3: UUID="b6dcb1db-d315-406a-88e2-d5d1f97889a1" LABEL="rescue:2" TYPE="linux_raid_member" PARTUUID="2d1cbd66-235b-4a2f-bcf9-c544dd95d27a"

These outputs are host-specific, so treat the values as examples and do not paste them into a different machine.

  • lsblk --fs. A quick overview.
  • blkid. Reports the tags it can read, and can show several identifiers for one device.
  • Filesystem UUID vs partition UUID. The first identifies the filesystem metadata. The second identifies the partition entry, commonly in a GPT partition table. They are not interchangeable.

Tip

Labels may contain spaces or shell metacharacters, so quote the whole argument, for example findfs 'LABEL=archive data'. Quoting protects the shell; it does not make an identifier valid.

3. Resolve a filesystem UUID

Pass the exact tag as one argument. This lookup was checked against the local inventory:

$ findfs UUID=b6dcb1db-d315-406a-88e2-d5d1f97889a1
/dev/sdb3
$ printf 'exit status: %s\n' "$?"
exit status: 0

A successful lookup prints the resolved device name on standard output. Capture it if another command needs it:

$ device=$(findfs UUID=YOUR-FILESYSTEM-UUID) && printf '%s\n' "$device"
/dev/your-device

Replace YOUR-FILESYSTEM-UUID with a value from your own blkid or lsblk --fs output. The && stops a failed lookup being used as if it had worked.

Checkpoint

The line findfs prints must be a device path, and the status must be zero. Do not assume the path is a particular disk such as /dev/sda3, because device names can change after hardware or boot-order changes.

4. Resolve a filesystem label

Use LABEL= when the filesystem has a label. If the label contains punctuation, quote the whole argument:

$ findfs 'LABEL=rescue:2'
/dev/sdb3
$ printf 'exit status: %s\n' "$?"
exit status: 0

Labels suit human-managed media, but they are not necessarily unique.

Warning

If two visible devices share a label, do not build an unattended workflow around an ambiguous match. Prefer the identifier your storage layout guarantees to be unique, then verify the returned path with lsblk --fs "$device" or blkid "$device".

5. Resolve a partition UUID or label

Use PARTUUID= when you want the partition-table identifier rather than the filesystem inside the partition:

$ findfs PARTUUID=8f15dee8-b85e-4a44-b33a-1c1c24a2a282
/dev/sdb2
$ printf 'exit status: %s\n' "$?"
exit status: 0

The local example is a RAID-member partition. Its partition UUID and its filesystem or member UUID are different values, so copying the UUID= value into a PARTUUID= lookup would be an error. PARTLABEL= works the same way for a partition name when one is present:

$ findfs PARTLABEL=YOUR-PARTITION-LABEL
/dev/your-partition

Partition tags describe the partition table entry. They do not prove a filesystem is mounted, healthy or safe to write. Finding a path is an identification step, not a repair or mount operation.

6. Handle a failed lookup without changing anything

Test failure with a deliberately nonexistent value, or with your real value after checking its spelling:

$ findfs UUID=00000000-0000-0000-0000-000000000000
findfs: unable to resolve 'UUID=00000000-0000-0000-0000-000000000000'
$ printf 'exit status: %s\n' "$?"
exit status: 1
  • Exit status 1 means the label or UUID could not be found. Check the tag name, hyphens, case and whether the device is visible. Run lsblk --fs and blkid again if the storage has just appeared.
  • Exit status 2 is a usage error, such as an unknown option, the wrong number of arguments or an invalid command shape.

A missing result can also mean the metadata is not readable in the current context. Only after checking the path and permissions should you consider an elevated read-only inspection.

Safety boundary

The lookup does not alter partitions, filesystems, mounts or services, so there is nothing to undo for these examples.

Done means

  • Command confirmed. You know the findfs binary and the installed util-linux version.
  • Exact tag chosen. You picked it from current lsblk --fs or blkid output.
  • Identifiers kept apart. Filesystem identifiers and partition identifiers were not mixed up.
  • Clean success. A successful lookup printed a device path and returned status 0.
  • Failures told apart. You can distinguish a missing identifier (status 1) from a malformed invocation (status 2).
  • Nothing touched. You have not mounted, modified or written to any device merely by running findfs.