I know very little (basically nothing) about snap. I see that in 18.04 they are already using snaps, shown below

Core applications packaged as snaps

Shown here

enter image description here

So, my question is, that since snaps are shown using the df command, and they apparently flood df (On fresh install of 18.04 more than half of my df listings are snaps)

It's just flooding df, and makes it harder to use. Is there a way to stop it? I'm assuming since snap is planning on being used more frequently it will either no show in df, or df will become a much longer command with more pipes.

  • 5
    You can perhaps do df | grep -v "/snap" or similar, but aside from that, no,. Snaps are mounted and so will show up in things which show what is mounted. – dobey Apr 29 '18 at 2:28
  • 1
    Perhaps you could open a bug report at launchpad.net/+ubuntu/source/coreutils about installed snaps being unhelpful in the output. – dobey Apr 29 '18 at 2:41
  • 1
    You can prevent df from listing snaps with the following: df $(cut -d' ' -f3 /proc/mounts | sort -u | grep -v 'squashfs' | sed 's/^/-t /') – Martin Wimpress May 1 '18 at 14:20
  • 1
    I setup an alias: alias df='df | grep -v "/snap"' – Mike Redrobe Sep 19 '18 at 14:19
  • 3
    Instead of piping df results to grep & removing snaps, the cleaner solution is IMHO to use grep's grep -v option to exclude file systems. Snaps use squashfs. Thus you can define an alias like alias df='df -l -BM -Tx"squashfs"' to get the non-snap-list as a default. See [docs.snapcraft.io/the-snap-format/698] for a definition. – Marcus Oct 28 '18 at 10:31

You can use df's df -x option to exclude certain file systems from the results. Since snaps use the squashfs filesystem, you can define an alias like

alias df='df -x"squashfs"'

to get the non-snap-list as a default.

BTW, see this link for a definition of the snap format.

|improve this answer|||||
  • I'm generally against using alias', but I may make an exception here. Thanks! – trueCamelType Nov 1 '18 at 22:08
  • I still prefer the grep solution as this would remove all squashfs filesystems, which is not limited to snaps. – skerit Nov 25 '18 at 13:04
  • 1
    the difference is that the grep solution prevents other arguments to df from working. – tedder42 Feb 19 '19 at 23:30
  • @tedder42 function df() { command df "$@" | grep -v "/snap"; } – mxmlnkn Mar 24 at 17:54
  • how is this better than the proper use of df as listed in the answer, @mxmlnkn? – tedder42 Mar 24 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.