189 points · by networked · 3y ago · 69 comments
There's a lot of Unix/Linux stuff that I wish I could UNlearn, I'm aware of other tools but muscle memory keeps me using worse things.
(honestly, I also feel this way about vim as well as 'writing in cursive')
I still `cat foo | grep bar` instead of `grep foo bar`
You’re just saying “show me the subset of this other list” and you automatically select your go-to solution for that: `|grep`
The reason for seeking a better tool is when too much excessive work (== time) is involved, or list generation has side effects. But in this case you don’t have two million mount points, so no need to worry.
$ df /dev/sda1 /dev/nvme0n1p1
And get only those file systems.why not make df better...
Jest aside, it's much easier to write a small tool from scratch, than to contribute to coreutils, where this kind of improvement is likely to be rejected, for various arguably valid reasons.
Besides, having alternatives is healthy for the Linux ecosystem, and writing something from scratch is a good learning experience.
Better is also subjective.
$ df -h | wc -l
7
$ lsblk | wc -l
6
$ mount | wc -l
26
(in the article: 25, 56, 77)findmnt --options rw --real
... gets you most of the way there.
Edit: It seems an adequate replacement for `df` and `mount`. Can it print a block device tree organized by device name like `lsblk`? I have skimmed the man page and not found options for it.
findmnt -Dt notmpfs
> lsblk -e 7
findmnt -iS 7:0 (excludes mounted loop devices, not functionally equivalent to lsblk)
> mount -l -t btrfs,fat,exfat,ext2,ext4,iso9660,ntfs3,ufs,vfat,xfs,zfs
findmnt -lt btrfs,fat,exfat,ext2,ext4,iso9660,ntfs3,ufs,vfat,xfs,zfs
> 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)/'
findmnt -O rw --real
findmnt -lnt noautofs,nobinfmt_misc,nobpf,nocgroup2,noconfigfs,nodebugfs,nodevpts,nodevtmpfs,nofuse,nohugetlbfs,nomqueue,nonfsd,nonsfs,noproc,nopstore,noramfs,norpc_pipefs,nosecurityfs,nosquashfs,nosysfs,notmpfs,notracefs
Or simply invert the target filesystems with --invert instead of prefixing "no".
That counts as the majority for me.
The basic/key functionality of lsblk is that it shows me all the things that look like disks; which, to me, shouldn't include all of these squashfs mounts, but--very very critically--includes disks that haven't been mounted, as the whole point is that we are looking at block devices, not mount points, or we would be using mount instead of lsblk.
Another important feature of lsblk is how it then takes those block devices and builds them into a tree, showing me how the various layers of--again: potentially as yet unmounted--block devices are "built": I can see that this device isn't in a filesystem, but is being used by an md array which is then used by a bcache or (conversely) that this filesystem isn't just some opaque bcache but is a cache of an md array of some set of specific disks.
The findmnt command you provided thereby simply doesn't seem to do anything related to lsblk; again: you said it wasn't functionally the same... but then what are you trying to show me? I will note your findmnt version also doesn't even succeed in filtering all of the loopback disks, much less all of the random mount trash... 7:0 is just the first /dev/loop, but I have a giant pile of them (due to the stupidly slow and wasteful way Ubuntu insists on using squashfs). I don't think -S even supports something akin to filtering '7:*'?
(FWIW, I do thank you for at least causing me to think about my lsblk usage, as I usually hated how the tree was to-me inverted and I was going to say I'd love to have a tool which didn't do that... but after decades of using lsblk I finally looked at --help and it turns out I can use -s to get the output I actually want, so I am amazingly happy! findmnt definitely isn't a useful alternative, enough.)
If you liked it, you may enjoy my page https://dbohdan.com/gui-games.
One question: I have 2 ntfs drives and they show as type "fuseblk". They don't show now with the new "mount" alias. I tried removing "fuse" from the list but no change. How can I bring these back to displaying when I enter "mount"?
https://www.linux-magazine.com/Online/Blogs/Productivity-Sau...
The full command to get a "clean" mount list on OpenBSD, including disk usage with human-friendly units, is:
$ df -h
https://man.openbsd.org/dfFind the mountpoint you're looking for, read to left to see the stats. When you're managing a storage box, no amount of tmpfs entries can create the noise stated in the blog post.
P.S.: If you know the device names like your name, you can quickly skim that list, too.
1. For the computing device to do the more reasonable thing;
2. For the computing device to adapt to and serve my needs, not the other way around.
On top of that the commands are adaptable, and you can always write the tools you need. There are no hidden/forbidden interfaces.
I commend BSDs for what they are, but blindly praising any OS is wrong IMHO. Is Linux perfect? Heck no. Is BSDs are squarely better at everything, again no.
These are different OSes shine at different things. We use all of them, but they are not that interchangeable.
df -h
but df -h | egrep SOMETHING
or maybe df -h | less
and yes I still don't understand why dozens of mount points reported.