LinuxCommandLibrary

findmnt

Find mount information about a filesystem

TLDR

List all mounted filesystems

$ findmnt
copy

Search for a device
$ findmnt [/dev/sdb1]
copy

Search for a mountpoint
$ findmnt [/]
copy

Find filesystems in specific type
$ findmnt [[-t|--types]] [ext4,virtiofs,btrfs,...]
copy

Find filesystems with specific label
$ findmnt LABEL=[BigStorage]
copy

Check mount table content in detail and verify /etc/fstab
$ findmnt [[-x|--verify]] --verbose
copy

SYNOPSIS

findmnt [options] [DEVICE | MOUNTPOINT]

PARAMETERS

-n, --noheadings
    
Do not print headings in the output.

-r, --raw
    
Use raw output format, useful for parsing by scripts.

-u, --notruncate
    
Do not truncate text in output columns.

-J, --json
    
Use JSON output format. This is highly recommended for programmatic parsing.

-o, --output list
    
Define output columns. Common columns include SOURCE, TARGET, FSTYPE, OPTIONS, USED, AVAIL.

-t, --types list
    
Limit the output to a specified comma-separated list of filesystem types (e.g., 'ext4,xfs').

-s, --fstab
    
Search in /etc/fstab instead of the kernel's mount information.

-F, --first-only
    
Print only the first matching entry.

-l, --list
    
Use the list format output table.

-D, --df
    
Report information in a df(1)-like format, showing used and available space.

-k, --kernel
    
Search in /proc/self/mounts (kernel) instead of /proc/self/mountinfo.

-M, --mountpoint path
    
Specify a mount point to search for. Also accepts -T, --target.

DESCRIPTION

findmnt is a utility for locating and displaying information about currently mounted filesystems or searching for specific mount points. It queries /proc/self/mountinfo, /proc/self/mounts, or /etc/fstab to provide a structured and often more reliable output compared to simply parsing the mount command's output. It's particularly useful for scripting due to its various output options, including raw and JSON formats, and its ability to filter results based on device, mount point, or filesystem type. findmnt can also be used to verify entries in /etc/fstab, making it a versatile tool for system administration and diagnostics related to storage and mounts.

CAVEATS

While findmnt offers powerful filtering and output options, its default human-readable output can be verbose. For scripting, it's highly recommended to use the --json or --raw and --noheadings options to ensure stable parsing.
The command relies on the /proc filesystem for current mount information, meaning its availability and content are crucial for findmnt's operation.

OUTPUT CUSTOMIZATION

findmnt allows extensive control over its output columns using the -o option. Users can specify a comma-separated list of columns like SOURCE, TARGET, FSTYPE, OPTIONS, USED, AVAIL, UUID, and many more, enabling tailored reports for specific needs.

JSON OUTPUT FOR SCRIPTING

A significant feature for automation is the --json option. This outputs the mount information in a machine-readable JSON array, making it exceptionally easy for scripts to parse and process mount data reliably without needing to contend with varying text output formats or locale issues.

VERIFYING FSTAB ENTRIES

By combining -s (search fstab) with a target mount point or device, findmnt can be used to quickly verify if an entry exists and is correctly formatted in the /etc/fstab file, which is crucial for system boot processes.

HISTORY

The findmnt command was introduced as part of the util-linux project, appearing in version 2.20 (released around 2011). It was developed to provide a more robust and parseable alternative to traditional methods of querying mounted filesystems, such as parsing the output of the mount command. Its design aims to facilitate scripting and automation by offering structured output formats and flexible filtering capabilities, addressing common parsing challenges faced by system administrators.

SEE ALSO

mount(8), umount(8), lsblk(8), df(1), fstab(5)

Copied to clipboard