# Clean mount lists in Linux Default installations of Linux distributions mount more filesystems than they used to. This is because of [loop devices](!W "Loop device"), [cgroups](!W), and, in Ubuntu, [snaps](!W "Snap (software)"). As a result, the output from [GNU df(1)](https://linux.die.net/man/1/df) as well as from [lsblk(8)](https://linux.die.net/man/8/lsblk) and [mount(8)](https://linux.die.net/man/8/mount) 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](https://fishshell.com/). You can adapt the replacement script for other shells. ## Contents ## df {#df} GNU df(1) allows you to exclude [tmpfs](!W) with a simple option. In Ubuntu 22.04, this removes `/dev/shm`, `/run`, `/run/user/*`, and other mount points from its output. In an improvement over Ubuntu 20.04, df(1) is already [patched](https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1756595) to exclude [Squashfs](!W "SquashFS") (snaps). Command: ```shell df -x tmpfs ``` The improvement on my system is as follows: ``` > df | wc -l 25 > df -x tmpfs | wc -l 19 ``` ## lsblk {#lsblk} The command lsblk(8) can exclude devices by major device type. Snaps are loopback devices. According to [`devices.txt`](https://www.kernel.org/doc/Documentation/admin-guide/devices.txt) in the Linux kernel admin guide, the device type for loopback devices is 7. Command: ```shell lsblk -e 7 ``` Improvement: ``` > lsblk | wc -l 56 > lsblk -e 7 | wc -l 28 ``` ## mount {#mount} We can simplify the output of GNU mount(8) by either excluding certain filesystem types or only including certain filesystem types. ### Include list Example command: ```shell 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 types, see `/proc/filesystems` and `/lib/modules/"$(uname -r)"/kernel/fs/`. ### Exclude list This is a little more involved, since mount(8) seems to lack a built-in "exclude" option. We can filter the output by the type column with awk. Example command: ```shell 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 as follows: ``` > mount | wc -l 77 > mount | awk '...' | wc -l 19 ``` ### fish configuration {#fish} 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 `mount --`. #### Installation ```fish cd ~/.config/fish/conf.d/ curl -O https://dbohdan.com/clean-mount-lists.fish less clean-mount-lists.fish # Examine the code. ``` #### Source ```fish # clean-mount-lists 0.3.1 # Wrap commands to show cleaner mount lists in Linux. # See https://dbohdan.com/clean-mount-lists # License: MIT. # https://dbohdan.com/mit-license/2023 if status is-interactive; and test "$(uname)" = Linux if not set --query clean_mount_lists_exclude set --universal clean_mount_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 -o \( (count $argv) -eq 1 -a "x$argv[1]" = x-h \) # `-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_mount_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} [findmnt(8)](https://linux.die.net/man/8/findmnt) from [util-linux](!W) is an alternative to df(1) and mount(8) with better options for filtering. For example, ```shell findmnt --df --options rw --real ``` produces output like `df -h`, but only for real and read-write filesystems. Thanks to the [Hacker News discussion thread](https://news.ycombinator.com/item?id=37271611) for suggesting findmnt(8) and the `--options rw --real` invocation. ## Page metadata URL: Published 2023-08-26, updated 2025-10-20. Tags: - command line - essay - fish shell - how-to - Linux - personal computing - shell