How to Use Findmnt to Find Mounted Filesystems in Linux

Channel: Linux
Abstract: $ findmnt --poll --first-only Similar like df output The command findmnt can also be used to imitate the output you would get if you used the df comma

The command findmnt is used to list mounted filesystems in Linux. This command will look for a particular filesystem in /etc/fstab, /etc/mtab or /proc/self/mountinfo.

The command findmnt comes in the package 'util-linux-ng',  now renamed 'util-linux'. The package comes with several other utilities such as hwclock. To install findmnt download util-linux from kernel.org ftp page.

Fedora users can install the package as follows:

How to Get the File Path of any Fil...

To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video

How to Get the File Path of any File or Folder on Mac OS
$ sudo yum install util-linux-ng

Note: This package comes by default

Findmnt Default option

This command by default will give you a list of all filesystems mounted if no mountpoint or device is specified.

$ findmnt
Findmnt Polling Mode

The command findmnt can be used to monitor changes in /proc/self/mountinfo file. The polling mode can be invoked by typing in your terminal the following command:

$ findmnt -p

alternatively

$ findmnt --poll

Any changes made to /proc/self/mountinfo file will automatically be updated on the terminal. At first, you will not see any output but if you try to unplug and plugging your flash drive, the changes are reflected on the terminal as in the following example.

The time which polling mode will block can be restricted by --timeout or --first-only option.

Timeout option

This option can be used along with --poll to limit the time polling mode will block to the time you explicitly set. The timeout to be set is in milliseconds. After the timeout period, findmnt will no longer monitor for changes to the /proc/self/mountinfo file.

$ findmnt --poll --timeout 6000

First-only option

The first-only option will monitor for changes in the /proc/self/mountinfo file only for the first change and the command will no longer be in polling mode. The first change is displayed on the terminal and the prompt is returned to you. To use this option type on your terminal:

$ findmnt --poll --first-only

Similar like df output

The command findmnt can also be used to imitate the output you would get if you used the df command. You can achieve this by running the command findmnt with the --df option as shown the following example.

$ findmnt --df

or

$ findmnt -D

This will give an almost identical output if you had run the command df with the -h option.

$ df -h

Findmnt list option

If you do not like the default tree output you can use the --list or -l option. This will print your output in a list format.

$ findmnt --list

Running this command will give you an output as follows:

Findmnt Evaluate Option

The evaluate option will convert all tags for example LABEL, UUID, PARTUUID or PARTLABEL to the actual device name. This option can be combined with --fstab option to print all the filesystems in /etc/fstab. The fstab option has its output in list format, and therefore there is no need to call the --list option when --fstab is used.

$ findmnt --fstab --evaluate

When the two options are combined as follows, the output will look like the example below:

Findmnt type option

This option allows you to limit the set of printed filesystems. Multiple filesystems can be specified and separated by a coma. In this example the command will search for ext4, ext3 and vfat filesystems.

$ findmnt -t ext4,ext3,vfat

You can try out the different options for findmnt depending on your needs.

Ref From: linoxide

Related articles