util-linux / util-linux

http://en.wikipedia.org/wiki/Util-linux
GNU General Public License v2.0
2.68k stars 1.21k forks source link

Feature Request: The ability to exclude/limit devices reported by the 'mount' command #2575

Open pghpete opened 1 year ago

pghpete commented 1 year ago

With the addition of a number of different "mounted' file systems and devices, it is getting harder and harder to make out physical disk devices on a system using the mount command. (yes 'df -h' is an option but it does not provide the same information as the 'mount' command)

On a newly installed Fedora 39 system using the default disk layout provided by the installer, there are 10 devices shown by 'df -h'

~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       476G  3.9G  470G   1% /
devtmpfs        4.0M     0  4.0M   0% /dev
tmpfs           7.7G     0  7.7G   0% /dev/shm
efivarfs        192K   95K   93K  51% /sys/firmware/efi/efivars
tmpfs           3.1G  2.4M  3.1G   1% /run
tmpfs           7.7G  8.0K  7.7G   1% /tmp
/dev/sda3       476G  3.9G  470G   1% /home
/dev/sda2       974M  247M  660M  28% /boot
/dev/sda1       599M   18M  582M   3% /boot/efi
tmpfs           1.6G  136K  1.6G   1% /run/user/1000

However, the 'mount' command shows 29 devices.

/dev/sda3 on / type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/root)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=4096k,nr_inodes=2005984,mode=755,inode64)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel,inode64)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,seclabel,nsdelegate,memory_recursiveprot)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime,seclabel)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,size=3218720k,nr_inodes=819200,mode=755,inode64)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,nosuid,noexec,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=19549)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,nosuid,nodev,relatime,seclabel,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime,seclabel)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime,seclabel)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime,seclabel)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,seclabel,nr_inodes=1048576,inode64)
/dev/sda3 on /home type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/home)
/dev/sda2 on /boot type ext4 (rw,relatime,seclabel)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=1609356k,nr_inodes=402339,mode=700,uid=1000,gid=1000,inode64)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

Picking out the devices you are interested in in a list of that size continues to get more difficult. I am aware that you can use the mount command with the '-t|--type' command line options, however, it would be nice if there was something like...

'-e|--exclude' to exclude file system types like cgroup2, devpts, sysfs, securityfs, etc '-d|--disk' (or '--df'? ) to list mounts of physical disk devices or provide mount information on those mounts displayed in 'df'

This would allow users to be able to identify devices they are interested in far quicker than looking through the current full output the mount command provides.

Here is what is currently needed to see the mount points in question that the 'df' command reports on.

mount -t btrfs,ext3,ext4,devtmpfs,vfat,tmpfs,efivarfs

/dev/sda3 on / type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/root)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=4096k,nr_inodes=2005984,mode=755,inode64)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel,inode64)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,size=3218720k,nr_inodes=819200,mode=755,inode64)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,seclabel,nr_inodes=1048576,inode64)
/dev/sda3 on /home type btrfs (rw,relatime,seclabel,compress=zstd:1,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/home)
/dev/sda2 on /boot type ext4 (rw,relatime,seclabel)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=1609356k,nr_inodes=402339,mode=700,uid=1000,gid=1000,inode64)

I do not know if my suggestions are the best route forward or if there might be a better way to achieve the same results. For instance maybe it is as simple as adding colorized output for various file system types?

I am interested to see what others think about this issue.

karelzak commented 1 year ago

mount(8) output is maintained for backward compatibility only. If you want a better overview of the mounted filesystem then use findmnt(8), or if you prefer a devices-based view then use lsblk(8).

pghpete commented 1 year ago

I was aware of lsblk but not findmnt. Thank you for pointing me to it @karelzak