Showing only "interesting" mount points / filtering non interesting types
Do not use mount
.
From man mount
:
- The listing.
- The listing mode is maintained for backward compatibility only.
- For more robust and customizable output use
findmnt
(8), especially in your scripts. - Note that control characters in the mountpoint name are replaced with ?.
Use findmnt
, as the documentation suggests. Here are a few interesting options as described by findmnt --help
:
-i
or--invert
- invert the sense of matching
-R
or--submounts
- print all submounts for the matching filesystems
-t
or--types
list
- limit the set of filesystems by FS types
Those are only a couple of the many filters you can apply on the commandline.
man findmnt
- EXAMPLES
findmnt --fstab -t nfs
- Prints all NFS filesystems defined in
/etc/fstab
. findmnt --fstab /mnt/foo
- Prints all
/etc/fstab
filesystems where the mountpoint directory is/mnt/foo
. It also prints--bind
mounts where/mnt/foo
is a source.
You might use:
findmnt -it sysfs,cgroup,proc,devtmpfs,devpts,pstore,debugfs,hugetlbfs,mqueue,configfs
That should filter out all pseudo-filesystems, I believe.
Still, you can do the same with mount
:
mount -t nosysfs,nodevtmpfs...
Possibly a better way might be to use one of either the following commands, which findmnt --help
describes as noted:
findmnt -D
orfindmnt --df
- Imitate the output of
df
(1). This option is equivalent to-o SOURCE,FSTYPE,SIZE,USED,AVAIL,USE%,TARGET
but excludes all pseudo filesystems. Use--all
to print all filesystems.
- Imitate the output of
You can add list fields to the defaults with findmnt -Do
+field,+field
.... You can specify your own list of fields using only the file-systems -D
would show by omitting the +
like findmnt -Do
field,field
.
How about:
mount | grep '^/[^/]'
Mount points relating to physical disks will always start with a /
since the first field is the path to a device. cifs
mounts will start with //
so exclude lines with a second /
to ignore them.
Update
I misread the question, I thought you wanted to exclude cifs
and nfs
. Try this instead:
mount | grep -E '^[^ ]*[/:]'
The -t
option for mount
also works when displaying mount points and takes a comma separated list of filesystem types:
mount -t ext3,ext4,cifs,nfs,nfs4,zfs
I am not sure if that is a better solution. If you start using (e.g. btrfs
) and forget to add that to the list you will not see it and maybe not miss it. I'd rather actively filter out any new "uninteresting" filesystem when they pop up, even though that list is getting long.
You can actively try to only grep
the interesting mount points similar to what @Graeme proposed, but since you are interested in NFS/CIFS mounts as well (which don't start with /
), you should do:
mount | grep -E --color=never '^(/|[[:alnum:]\.-]*:/)'
( the --color
is necessary to suppress coloring of the initial /
on the lines found). As Graeme pointed out name based mounting of NFS shares should be allowed as well. The pattern either selects lines starting with a /
or any combination of "a-zA-Z0-9." followed by :/
(for NFS mounts).