LinuxCommandLibrary

findfs

Find filesystem by label or UUID

TLDR

Search block devices by filesystem label

$ findfs LABEL=[label]
copy

Search by filesystem UUID
$ findfs UUID=[uuid]
copy

Search by partition label (GPT or MAC partition table)
$ findfs PARTLABEL=[partition_label]
copy

Search by partition UUID (GPT partition table only)
$ findfs PARTUUID=[partition_uuid]
copy

SYNOPSIS

findfs options

PARAMETERS

-b, --blkid
    Use blkid (block id utility) to search for the filesystem. This is the default behavior.

LABEL=label
    Search for a filesystem with the specified label.

UUID=uuid
    Search for a filesystem with the specified UUID.

-h, --help
    Display help text and exit.

-V, --version
    Display version information and exit.

DESCRIPTION

The findfs command is a utility used to locate a filesystem on a block device. It searches for filesystems by their UUID (Universally Unique Identifier) or label, and prints the block device name where the filesystem is located.

It is particularly useful in system startup scripts or when dealing with dynamically mounted storage devices where device names might change. Instead of relying on a fixed device name like `/dev/sda1`, which can be unpredictable, findfs allows you to identify the filesystem based on its persistent identifier (UUID or label).

By using UUIDs or labels, the system can reliably locate and mount the correct filesystem, even if the device names have changed due to changes in hardware configuration or the order in which devices are detected by the kernel.

findfs is part of the `util-linux` package, so it is commonly available on most Linux distributions.

CAVEATS

The filesystem must be discoverable by blkid for findfs to work correctly. Ensure blkid database is up to date.

EXIT CODES

findfs returns 0 if a filesystem is found and its block device is printed. If no filesystem is found, it returns a non-zero exit code.

EXAMPLES

findfs UUID=a1b2c3d4-e5f6-7890-1234-567890abcdef: Finds the device with the specified UUID.
findfs LABEL=MyData: Finds the device with the label 'MyData'.

HISTORY

The findfs command has been a part of the `util-linux` suite for many years. It was developed to provide a reliable method for identifying filesystems regardless of device naming conventions. Its usage has become more prevalent with the increasing use of UUIDs and labels for filesystem identification, particularly in modern system initialization processes.

SEE ALSO

blkid(8), mount(8), lsblk(8)

Copied to clipboard