3

My requirement is to find out all such directories in Linux which are mount points for network-based storage/file systems (like NFS, SSHFS, CIFS, SMB, etc)

I did some research, and there is no utility command for that.

The approach I am thinking of is first to list all mounted filesystems using the findmnt -l command, and then try and figure out from the SOURCE and FSTYPE columns of the output, which are network mounted.

But I'm not sure to check for what information would surely tell me that this is a network share mounted on my Linux.

Please help me with what would be the best approach to find this information.

My Linux machines are RHEL 5/6/7 and Ubuntu v18 and above.

utobi
  • 109
  • 1
  • 7
dig_123
  • 143
  • 3
  • 1
    Anything wrong with doing `df` & `df -l` and `diff'ing` the output? – Bib Feb 01 '22 at 13:12
  • @Bib Can you elaborate ? In case of a network mount how will both the outputs be different ? What difference to expect ? – dig_123 Feb 01 '22 at 13:15
  • 1
    Read the man page, the `-l` switch means list only local mounts. – Bib Feb 01 '22 at 13:19
  • 2
    @Bib I agree with your point. I can use this `diff <(df | awk '{print $NF}') <(df -l | awk '{print $NF}')` to compare the mounted points output of `df` and `df -l`. I'll try to test this after mounting a network share on my Linux box. – dig_123 Feb 01 '22 at 13:31
  • 1
    Nice. It's a poor man's way of doing it though. I would hope there are better ways. You may get something better looking at the contents of `/proc/mounts`. – Bib Feb 01 '22 at 13:34
  • Also, nice! How about this as a simpler/more output solution: `diff -w <(df -l) <(df)`. Gets you all the fields from `df`, just ignores whitespace (which will differ on every line as df will adjust column widths as necessary). – lost Aug 31 '22 at 14:55
  • does `findmnt -l | grep 'rclone' | cut -d ' ' -f 1` do what is needed? It really isn't very clear as to what you need for, for all the detail you give. Substitute `rclone` for whatever kind of FSTYPE you need of course. – Whitequill Riclo Jul 16 '23 at 06:19
  • Is this a really BIG network or a moderate network or a small network? – Whitequill Riclo Jul 16 '23 at 06:23
  • Use `mount` to list ALL the mounted filesystems, and `grep -v` to eliminate unwanted mounts. – waltinator Jul 18 '23 at 16:40

0 Answers0