findmnt command to find mounted filesystems

Time:2022-8-4

The findmnt command is used to list the mounted filesystems in Linux. This command will look for a specific filesystem in /etc/fstab, /etc/mtab or /proc/self/mountinfo.
The findmnt command is included in the util-linux package, which comes with some other tools like hwclock.

Use the following command to install on Centos system:

[[email protected] ~]# yum -y install util-linux
This installation package is installed by default in the system.

Findmnt default options
If no device or device's mount point is specified, by default this command will provide a list of all mounted filesystems.

[[email protected] ~]# findmnt
findmnt command to find mounted file systems findmnt command to find mounted file systems

Findmnt's real-time monitoring mode
The findmnt command can be used to monitor changes in the /proc/self/mountinfo file. In the following example, mount the CD, and you can see that findmnt has captured the mount action:

[[email protected] ~]# findmnt -p
ACTION TARGET SOURCE FSTYPE OPTIONS
mount /mnt /dev/sr0 iso9660 ro,relatime,nojoliet,check=s,map=n,blocksize=2048
findmnt command to find mounted file systems findmnt command to find mounted file systems
Any changes made to the /proc/self/mountinfo file will be automatically updated on the terminal. Mounting or unmounting the disc in the image above will capture the action.

similar to df output
The findmnt command can also be used to simulate the output if the df command is used. This can be achieved by using the –df option, as shown in the following example:

[[email protected] ~]# findmnt –df
findmnt command to find mounted file systems findmnt command to find mounted file systems
You can see that the information output by findmnt –df and df -hT is very similar.

Findmnt list options
If you don't like the default tree-like output, you can use the –list or -l options. This will output in list format.

[[email protected] ~]# findmnt –list
findmnt command to find mounted file systems findmnt command to find mounted file systems

List mount information from /etc/fstab file
With the –fstab option, mount information will be obtained from the /etc/fstab file.

The –evaluate option will convert all labels (such as LABEL, UUID, PARTUUID or PARTLABEL) to actual device names. This option can be combined with the –fstab option to print all filesystems in the file. fstab options are output in list format, so there is no need to call the –list option when using –fstab.

[[email protected] ~]# findmnt –fstab
TARGET SOURCE FSTYPE OPTIONS
/ /dev/mapper/cl-root xfs defaults
/boot UUID=26309fe5-0c1d-4b28-b20f-7231a83cc9ef ext4 defaults
swap /dev/mapper/cl-swap swap defaults
[[email protected] ~]# findmnt –fstab –evaluate
TARGET SOURCE FSTYPE OPTIONS
/ /dev/mapper/cl-root xfs defaults
/boot /dev/nvme0n1p1 ext4 defaults
swap /dev/mapper/cl-swap swap defaults
findmnt command to find mounted file systems findmnt command to find mounted file systems

Displays file systems of the specified type
This option can limit the set of print file systems. Multiple file systems can be specified, separated by commas. In this example, the command will search for ext4, xfs and vfat filesystems.

[[email protected] ~]# findmnt -t ext4,xfs,vfat
findmnt command to find mounted file systems findmnt command to find mounted file systems

Summarize
You can try different findmnt options as needed. The findmnt command is used to list the mounted filesystems in Linux. This command will look for a specific filesystem in /etc/fstab, /etc/mtab or /proc/self/mountinfo.