How to use the command findfs (with examples)

How to use the command findfs (with examples)

The findfs command is used to find a filesystem by its label or UUID. It is part of the util-linux package in the Linux operating system. This command can be useful when you want to locate a specific filesystem on your system. It supports searching block devices by filesystem label, searching by filesystem UUID, searching by partition label in GPT or MAC partition tables, and searching by partition UUID in GPT partition tables.

Use case 1: Searching block devices by filesystem label

Code:

findfs LABEL=label

Motivation: You may have a specific filesystem label that you want to search for on your system. By using the findfs command with the appropriate label, you can easily locate the device associated with that filesystem.

Explanation:

  • LABEL: This is the label of the filesystem you want to search for. The label is a custom name assigned to the filesystem during formatting.

Example output:

/dev/sda2

This output indicates that the block device associated with the filesystem label “label” is “/dev/sda2”.

Use case 2: Searching by filesystem UUID

Code:

findfs UUID=uuid

Motivation: If you know the UUID (Universally Unique Identifier) of a filesystem, you can use this command to quickly locate the associated block device. UUIDs provide a unique identifier for each filesystem, ensuring that the correct device is found.

Explanation:

  • UUID: This is the UUID of the filesystem you want to search for. UUIDs are long alphanumeric strings that uniquely identify a filesystem.

Example output:

/dev/sdb1

This output indicates that the block device associated with the filesystem UUID “uuid” is “/dev/sdb1”.

Use case 3: Searching by partition label (GPT or MAC partition table)

Code:

findfs PARTLABEL=partition_label

Motivation: In systems that use GPT (GUID Partition Table) or MAC (Apple Partition Map) partition tables, you may want to find a partition by its label. This command helps you search for a partition label to locate the associated device.

Explanation:

  • PARTLABEL: This is the label of the partition you want to search for. The label is a custom name assigned to the partition.

Example output:

/dev/sdc3

This output indicates that the partition with the label “partition_label” is associated with the block device “/dev/sdc3”.

Use case 4: Searching by partition UUID (GPT partition table only)

Code:

findfs PARTUUID=partition_uuid

Motivation: In GPT partition tables, partitions can be identified by their unique UUID. If you have the UUID of a partition, you can use this command to find the corresponding device.

Explanation:

  • PARTUUID: This is the UUID of the partition you want to search for. PARTUUIDs are specific to GPT partition tables and provide a unique identifier for each partition.

Example output:

/dev/sde2

This output indicates that the partition with the UUID “partition_uuid” is associated with the block device “/dev/sde2”.

Conclusion:

The findfs command is a useful tool for locating filesystems and partitions on a Linux system. It provides several options for searching by label or UUID, allowing you to easily find the associated block devices. Incorporating this command into your workflow can help streamline filesystem management and troubleshooting tasks.

Related Posts

How to use the command cmctl (with examples)

How to use the command cmctl (with examples)

cmctl is a command-line tool for managing cert-manager resources inside your Kubernetes cluster.

Read More
How to use the command devcontainer (with examples)

How to use the command devcontainer (with examples)

The devcontainer command allows developers to use Docker containers as development environments.

Read More
How to use the command zipalign (with examples)

How to use the command zipalign (with examples)

Zipalign is a command line tool that is part of the Android SDK build tools.

Read More