Home / Alt manpages / findfs(8)

  • findfs(8)
  • Admin command
  • linux

Find the Right Block Device by UUID, Label or Partition ID

You will finish with a repeatable way to turn a filesystem label, filesystem UUID, partition UUID or partition label into the device path that Linux is using. This is useful before inspecting a disk, checking a mount configuration or handing a stable identifier to another command. The examples use findfs from util-linux 2.41.3, while the installed manpage is generated for util-linux 2.39.3. The supported tags and exit statuses used here are the same in both references.

Allow about ten minutes. You need a shell and a readable block-device inventory. The normal lookup is read-only and does not need sudo. Do not add elevated privileges by habit: root access can expose more devices, but it does not fix a misspelled identifier.

1. Confirm the installed command

Check which binary your shell will execute, 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 important contract is one argument in the form NAME=value. The installed manual documents four names: LABEL for a filesystem label, UUID for a filesystem UUID, PARTUUID for a partition identifier, and PARTLABEL for 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 visible to your system. This is also a useful way to spot 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. Treat the values above as examples, not values to paste into a different machine. lsblk --fs is a quick overview. blkid reports tags it can read, and can show several identifiers for one device. A filesystem UUID identifies the filesystem metadata. A partition UUID identifies the partition entry, commonly in a GPT partition table. They are not interchangeable.

Labels may contain spaces or shell metacharacters. Quote the complete argument when needed, 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 that output 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 && prevents the placeholder result from being used if the lookup fails.

Checkpoint: the line printed by findfs must be a device path, and the status must be zero. Do not assume that the path is a particular disk such as /dev/sda3; device names can change after hardware or boot-order changes.

4. Resolve a filesystem label

Use LABEL= when the filesystem has a label. For a label containing punctuation, quote the complete argument:

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

Labels are convenient for human-managed media, but they are not necessarily unique. If two visible devices use the same label, do not build an unattended workflow around an ambiguous match. Prefer the identifier that 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 need 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 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 that 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 failures with a deliberately nonexistent value or your actual 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 relevant device is visible. Run lsblk --fs and blkid again if the storage has just appeared. A missing result can also mean that the metadata is not readable in the current context. Only after checking the path and permissions should you consider an elevated read-only inspection.

Exit status 2 means a usage error, such as an unknown option, the wrong number of arguments or an invalid command shape. The lookup itself does not alter partitions, filesystems, mounts or services, so there is no undo operation for these examples.

Done means

  • You confirmed the findfs binary and installed util-linux version.
  • You selected an exact tag from current lsblk --fs or blkid output.
  • You kept filesystem identifiers separate from partition identifiers.
  • A successful lookup printed a device path and returned status 0.
  • You can distinguish a missing identifier, status 1, from a malformed invocation, status 2.
  • You have not mounted, modified or written to any device merely by running findfs.