The findmnt command finds a mounted file system

Time:2022-1-3

The findmnt command lists the mounted file systems in Linux. This command will look for a specific file system in / etc / fstab, / etc / mtab, or / proc / self / mountinfo.
The findmnt command is included in the util Linux package, which comes with other tools, such as hwlock.

Use the following command to install in CentOS system:

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

Findmnt default options
If no device or mount point for the device is specified, this command provides a list of all installed file systems by default.

[[email protected] ~]# findmnt
The findmnt command finds a mounted file system. The findmnt command finds a mounted file system

Real time monitoring mode of findmnt
The findmnt command can be used to monitor changes in the / proc / self / mountinfo file. In the following example, after mounting the CD, you can see that findmnt has captured the mounting action:

[[email protected] ~]# findmnt -p
ACTION TARGET SOURCE FSTYPE OPTIONS
mount /mnt /dev/sr0 iso9660 ro,relatime,nojoliet,check=s,map=n,blocksize=2048
The findmnt command finds a mounted file system. The findmnt command finds a mounted file system
Any changes made to the / proc / self / mountinfo file will be automatically updated on the terminal. In the figure above, the actions will be captured when the CD is mounted or unloaded.

Similar to DF output
If you use the DF command, the findmnt command can also be used to simulate output. You can do this by using the — DF option, as shown in the following example:

[[email protected] ~]# findmnt –df
The findmnt command finds a mounted file system. The findmnt command finds a mounted file system
You can see that the output information of findmnt — DF and DF – HT are very similar.

Findnt options list
If you don’t like the default tree output, you can use the — list or – L option. This will be output in list format.

[[email protected] ~]# findmnt –list
The findmnt command finds a mounted file system. The findmnt command finds a mounted file system

List the mount information from the / etc / fstab file
Using the — fstab option, the mount information will be obtained from the / etc / fstab file.

–The evaluate option converts all labels (such as label, UUID, partuid, or partlabel) to the actual device name. This option can be used in conjunction with the — fstab option to print all file systems in the file. The fstab option is 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
The findmnt command finds a mounted file system. The findmnt command finds a mounted file system

Displays the file system of the specified type
This option limits the collection of print file systems. You can specify multiple file systems separated by commas. In this example, the command will search ext4, XFS, and VFAT file systems.

[[email protected] ~]# findmnt -t ext4,xfs,vfat
The findmnt command finds a mounted file system. The findmnt command finds a mounted file system

summary
You can try different findmnt options as needed. The findmnt command lists the mounted file systems in Linux. This command will look for a specific file system in / etc / fstab, / etc / mtab, or / proc / self / mountinfo.