findfs is a command-line tool used to find a file system by either its label or UUID (Universally Unique Identifier) on a Linux or Unix-based system. It is a part of the util-linux package and can be used to locate a specific file system in a system with multiple file systems.
A file system label is a human-readable name that is assigned to a file system, typically at the time of its creation. A UUID, on the other hand, is a unique identifier that is assigned to a file system by the operating system, and it is not intended to be human-readable.
The findfs command can be used to find a file system by either its label or UUID. When used with the -l option, it will look for a file system with a specific label. When used with the -u option, it will look for a file system with a specific UUID. Once a file system is found, the command will return its device name, which can then be used to mount or work with the file system.
For example, to find a file system with the label “data”, the command would be:
# findfs LABEL="data"
To find a file system with UUID “8cc0f05e-7c9b-4c0d-8a2b-3f6f3e6e0c6a” the command would be:
# findfs UUID="8cc0f05e-7c9b-4c0d-8a2b-3f6f3e6e0c6a"
If you encounter the below error while running the command findfs:
findfs: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install util-linux |
Ubuntu | apt-get install util-linux |
Alpine | apk add util-linux |
Arch Linux | pacman -S util-linux |
Kali Linux | apt-get install util-linux |
CentOS | yum install util-linux |
Fedora | dnf install util-linux |
OS X | brew install util-linux |
Raspbian | apt-get install e2fsprogs |
findfs Command Examples
1. Search block devices by filesystem label:
# findfs LABEL=label
2. Search by filesystem UUID:
# findfs UUID=uuid
3. Search by partition label (GPT or MAC partition table):
# findfs PARTLABEL=partition_label
4. Search by partition UUID (GPT partition table only):
# findfs PARTUUID=partition_uuid