8 ms·
Clean mount lists in Linux
- semiotic1 3y agoWhy not just use the designated `findmnt` command from util-linux for the majority of this?
- pixelmonkey 3y agoYea, seems like: findmnt --options rw --real ... gets you most of the way there.
- networked 3y agoThanks. I have added a section about `findmnt` to the page. I'll expand the section later. 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.
- saurik 3y agoThis article covers three commands, and the two I use the most--df and lsblk--don't seem easily covered by "findmnt"?
- semiotic1 3y ago> df -x tmpfs 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.
- saurik 3y agoOk, the df one works, so--assuming the mount ones work (I haven't checked)--I guess you are up to 2/3 and so "the majority": touché ;P. The lsblk one though isn't even close... I'm not sure whether you are trying to cover this with your parenthetical that the functionality isn't the same, but then I don't get why you are trying to slip it in that list. 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.)
- semiotic1 3y agoThe block post is titled "Clean mount lists in Linux" not "Clean block device lists in Linux". I was demonstrating that findmnt can filter the source based on MAJOR:MINOR as a tangential, there was no attempt to "slip" anything in, hence the disclaimer. You are correctly pointing out that it filters only the first loop device and doesn't support globbing. lsblk is clearly the better suited tool for the job you are describing and the reason I said "majority" in my first comment.
- flas9sd 3y agosomething I came to use later in my cli life - using `df .` as in most cases the working directory I'm in is the filesystem I want to get the info on
- petecooper 3y agoSomewhat related - `duf` is "a better `df` alternative": https://github.com/muesli/duf https://github.com/muesli/duf
- ggambetta 3y agoAnd `dust` as a `du` replacement.
- 2bluesc 3y agoAlso `dua`[0] is a great `du` replacement which is must faster on modern NVMe drives. It includes an interactive mode `dua i` which I'd frame as a `ncdu` replacement. [0] https://github.com/Byron/dua-cli https://github.com/Byron/dua-cli
- Given_47 3y agoStarted using dust yesterday and like it so far. Also a big fan of diskus by sharkdp as a blazingly fast du -hs alternative
- gkfasdfasdf 3y agoI also like https://github.com/Byron/dua-cli https://github.com/Byron/dua-cli, does disk usage like du but also has an interactive mode which makes finding and freeing up space a breeze.
- tinco 3y agoEven though it's not supposed to be my day job, I've ran `df |grep -v <super long list` hundreds of times in the past year, yet it never occurred to me that I could try and find a better tool.
- jrm4 3y agoPreach. This happens to me all the time and keeps happening. 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')
- cyfex 3y agoI have been using `duf` [1] for a while, as a "cleaner" alternative to `df`. [1] https://github.com/muesli/duf https://github.com/muesli/duf
- deleted 3y ago[deleted]
- rollcat 3y agoHere we are, one of the primary reasons why I adore the BSDs. Linux seems to be just neverending layers of indirection, abstraction, and a kitchen sink of features that less than 1% of its users actually need. 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/df https://man.openbsd.org/df
- bayindirh 3y agoWell, if you're seasoned enough, you start to read df output from right to left. Find 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.
- rollcat 3y agoI prefer, in this order: 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.
- backendanon 3y agoYou want the mount points first? In school we were taught to think in what then where order. That's how the df -h command works on Linux, the way most people think. When you want to eat, most of us think what do I want to eat, then where.
- bayindirh 3y agoI think Linux is doing the more reasonable thing. The features are implemented with the existing facilities and extended to the bare minimum as required. 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.
- leslielurker 3y agoOff topic but the favicon for this website is giving me big Windows 3.1 File Manager nostalgia. Whenever I see a file icon from that era it takes me back. </getting-old>
- networked 3y agoI am glad someone noticed. :-) It is the File Manager icon. I have always liked this icon and the aesthetic of graphics made for Windows 3.x, even though my first Windows was 95 OSR2. Since File Manager and the icon are now free (https://github.com/microsoft/winfile https://github.com/microsoft/winfile), there is no copyright reason not to use it verbatim. If you liked it, you may enjoy my page https://dbohdan.com/gui-games https://dbohdan.com/gui-games.
- backendanon 3y agoI'm OK with how the disk tools show stats on Linux, thank you.
- nemetroid 3y agoSounds like a Snap/Ubuntu thing. On my Arch system: $ df -h | wc -l 7 $ lsblk | wc -l 6 $ mount | wc -l 26 (in the article: 25, 56, 77)
- mixmastamyk 3y agoYes, rather than this, I moved to Mint.
- cf100clunk 3y agodfc may be of interest to some: https://github.com/rolinh/dfc https://github.com/rolinh/dfc https://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Display-File-System-Space-Usage-with-dfc https://www.linux-magazine.com/Online/Blogs/Productivity-Sau...
- chrisco23 3y agoGreat post, thanks, also 'duf' was new to me, like it. 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"?
- deleted 3y ago[deleted]