Friday 29 May 2020

Re: Adjusting what fstypes df displays

On Fri, May 29, 2020 at 12:39 AM Bryce Harrington
<bryce.harrington@canonical.com> wrote:
>
> These days, df displays a lot of mount points, due to the increased use
> of non-consumable filesystems such as tmpfs and squashfs. This clutter
> is particularly noticeable using df in Ubuntu, due to the increased
> popularity of snaps, but the general problem affects all Linux distros,
> and shows up in other commands such as lsblk, blkid, fdisk -l, and
> mount.
>
> A commonly documented user customization[1] is to use aliases, e.g.:
>
> alias df='df -h -x squashfs -x tmpfs -x devtmpfs'
> alias lsblk='lsblk -e 7'
>
> df's upstream is aware of the issue, and would like to address it in
> their code. They've considered a number of solutions[2], but do not
> appear to have come to a consensus as of yet. Among the raised concerns
> are variations in distro requirements, and providing an ability for
> users to override/customize the exclusions.
>
> A solution I am considering to propose would add an environment
> variable, DF_EXCLUDE_FSTYPES, that df would treat similar to the -x
> flag.
>
>
> I've drafted a POC implementation for df here:
>
> https://github.com/bryceharrington/coreutils/commit/cc372d778b44abcf81af42743a5174685f9bb4db
>
>
> Here's what it does inside a container...
>
> Before:
>
> $ df
> Filesystem 1K-blocks Used Available Use% Mounted on
> default/containers/coreutils 24891008 2258816 22632192 10% /
> none 492 4 488 1% /dev
> udev 32862724 0 32862724 0% /dev/tty
> tmpfs 100 0 100 0% /dev/lxd
> /dev/nvme0n1p2 982940092 348781368 584158392 38% /home/bryce/pkg
> tmpfs 100 0 100 0% /dev/.lxd-mounts
> tmpfs 32892912 0 32892912 0% /dev/shm
> tmpfs 6578584 224 6578360 1% /run
> tmpfs 5120 0 5120 0% /run/lock
> tmpfs 32892912 0 32892912 0% /sys/fs/cgroup
> tmpfs 6578580 0 6578580 0% /run/user/1001
>
> After:
>
> $ export DF_EXCLUDE_FSTYPES=tmpfs,devtmpfs,squashfs
>
> $ df
> Filesystem 1K-blocks Used Available Use% Mounted on
> default/containers/coreutils 24891008 2258816 22632192 10% /
> /dev/nvme0n1p2 982940092 348781372 584158388 38% /home/bryce/pkg
>
> (It's even more drastic on my desktop - from 39 lines down to 6.)
>
> For Ubuntu, DF_EXCLUDE_FSTYPES could be set in the global profile (under
> /etc/profile.d/ perhaps?) This would make it straightforward to add
> new non-consumable filesystems that may crop up down the road. Perhaps
> other tools could use a similar/same env var approach, giving us a
> uniform way to control fs listings in the distro.
>
> Two alternate approaches I'm weighing are a config file in /etc, or just
> a package patch to carry in coreutils, but the env var approach feels
> like it would be more flexible to users and hopefully more suitable for
> upstream. Before I forward it upstream, though, what does ubuntu-devel@
> think?

I agree on the pain of df output pollution, for sure. And patching df
would help; though as you mentioned it's not the only tool affected,
e.g. lsblk, and IMO mount output is even worse.

While I'm +1 on adding an easy way to hide them, I'm -1 on hiding all
squashfs and tmpfs from everyone *by default*. I think that will lead
to a lot of confusion. But that's just my opinion.

Also re: using an env var, keep in mind there are quite a few
environments that won't keep profile vars, e.g. sudo, lxc exec, etc.
It could be quite confusing for 'df' to show one thing, and 'sudo df'
something else.


>
> Thanks,
> Bryce
>
>
>
> 1: Google shows many links, here's a sample:
>
> https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1756595
> https://askubuntu.com/questions/1029493/how-can-i-stop-snaps-from-listing-in-df
> https://clintonminton.com/how-to-clean-up-snap-and-loop-devices-from-df-output-in-ubuntu-18-04/
>
> Note that one drawback to this approach is it's not overrideable, i.e.:
>
> $ alias df='df -h -x squashfs -x tmpfs -x devtmpfs'
> $ df -t tmpfs
> df: file system type 'tmpfs' both selected and excluded
>
> 2: Ideas the maintainers discussed include omitting read-only devices,
> or ones with non-consumable storage, or with <1% usage. They also
> discussed maintaining a simple list of excludable "lesser" file
> systems, possibly stored in a user's ~/.dfrc or ~/.shellrc.
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37702
>
> 3: We exclude squashfs,tmpfs,devtmpfs in our nagios packaging, where
> these were generating false-positive 'disk full' alerts:
>
> https://bugs.launchpad.net/charm-nagios/+bug/1827159
>
> --
> ubuntu-devel mailing list
> ubuntu-devel@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel

--
ubuntu-devel mailing list
ubuntu-devel@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel