Default installations of Linux distributions mount more filesystems than they used to. This is because of loop devices, cgroups, and, in Ubuntu, snaps. As a result, the output from GNU df(1) as well as from lsblk(1) and mount(1) is more difficult to understand at a glance.
It is possible to make the output of these commands more readable by removing some of the “noise” devices. The following is a list of command arguments that remove irrelevant devices. After the list, I show how to replace the default commands in fish. You can adapt the replacement script for other shells.
GNU df(1) allows you to exclude tmpfs with a simple option. In Ubuntu 22.04, this removes
/run/user/*, and other mount points from its output. In an improvement from Ubuntu 20.04, df(1) is already patched to exclude Squashfs (snaps).
df -x tmpfs
The improvement on my system is as follows:
> df | wc -l 25 > df -x tmpfs | wc -l 19
The command lsblk(1) can exclude devices by major device type. Snaps are loopback devices. According to
devices.txt in the Linux kernel admin guide, the device type for loopback devices is 7.
lsblk -e 7
> lsblk | wc -l 56 > lsblk -e 7 | wc -l 28
We can simplify the output of GNU mount(1) by either excluding certain filesystem types or only including certain filesystem types.
mount -l -t btrfs,fat,exfat,ext2,ext4,iso9660,ntfs3,ufs,vfat,xfs,zfs
Choose the type based on what filesystems you work with. For a list of supported filesystem type, look in
This is a little more involved, since mount(1) seems to lack a built-in “exclude” option. We can filter the output by the type column with awk.
mount | awk '$5 !~ /(autofs|binfmt_misc|bpf|cgroup2|configfs|debugfs|devpts|devtmpfs|fuse|hugetlbfs|mqueue|nfsd|nsfs|proc|pstore|ramfs|rpc_pipefs|securityfs|squashfs|sysfs|tmpfs|tracefs)/'
The improvement with the exclude list is,
> mount | wc -l 77 > mount | awk '...' | wc -l 19
This configuration script replaces commands with wrappers that use arguments from the previous sections by default. They only use the arguments if you do not give arguments of your own. To ignore the wrapper and run, for example,
mount without any arguments, use
command mount or
cd ~/.config/fish/conf.d/ curl -O https://dbohdan.com/clean-mount-lists.fish less clean-mount-lists.fish # Examine the code.
# Wrap commands to show cleaner mount lists in Linux. # See https://dbohdan.com/clean-mount-lists # License: MIT. # https://dbohdan.mit-license.org/@2023 if status is-interactive; and test "$(uname)" = Linux if not set --query clean_fs_lists_exclude set --universal clean_fs_lists_exclude autofs binfmt_misc bpf cgroup2 configfs debugfs devpts devtmpfs fuse hugetlbfs mqueue nfsd nsfs proc pstore ramfs rpc_pipefs securityfs squashfs sysfs tmpfs tracefs end function df --wraps df if test (count $argv) -eq 0 # `-x` requires GNU df(1). command df -h -x tmpfs else command df $argv end end function mount --wraps mount if test (count $argv) -eq 0 set --local re (string join '|' $clean_fs_lists_exclude) command mount | awk -v re=$re '$5 !~ re' else command mount $argv end end function lsblk --wraps lsblk if test (count $argv) -eq 0 command lsblk -e 7 else command lsblk $argv end end end
findmnt instead of df and mount
findmnt(1) from util-linux is an alternative to df(1) and mount(1) with better options for filtering. For example,
findmnt --df --options rw --real
produces output like
df -h, but only for real and read-write filesystems.
Thanks to the HN discussion thread for suggesting findmnt(1) and the
--options rw --real invocation.