muesli / duf

Disk Usage/Free Utility - a better 'df' alternative
Other
12.73k stars 395 forks source link

Bind mounts should be in the list of special devices #46

Open paper42 opened 3 years ago

paper42 commented 3 years ago

I have some entries in my /etc/fstab which are bind mounts:

/mnt/hdd/sources /src none defaults,bind 0 0

duf shows them in the list of normal, non-special devices, but I think they should be either hidden or shown in the special devices section. There doesn't seem to be a good way to detect a bind mount other than parsing /etc/fstab.

muesli commented 3 years ago

bind-mounts should be detected already and hidden by default. If that's not the case, could you please paste your /proc/self/mountinfo here? Thank you!

paper42 commented 3 years ago

I can paste one mount, if that helps:

61 47 8:4 /sources /src rw,relatime - ext4 /dev/sda4 rw

Thanks

muesli commented 3 years ago

Odd, there should be a bind option in that line.

paper42 commented 3 years ago

Really odd, I can reproduce this exact same issue on Ubuntu 20.04 server.

this is before doing anything (I got duf using go get):

~: duf
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 8 local devices                                                                                          │
├───────────────────┬────────┬────────┬───────┬───────────────────────────────┬──────────┬─────────────────┤
│ MOUNTED ON        │   SIZE │   USED │ AVAIL │              USE%             │ TYPE     │ FILESYSTEM      │
├───────────────────┼────────┼────────┼───────┼───────────────────────────────┼──────────┼─────────────────┤
│ /                 │  18.2G │  15.1G │  2.2G │ [################....]  83.2% │ ext4     │ /dev/vg/lv_root │
│ /boot             │ 461.0M │ 388.3M │ 48.8M │ [################....]  84.2% │ ext2     │ /dev/sda1       │
│ /snap/core18/1885 │  55.4M │  55.4M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop0      │
│ /snap/core18/1932 │  55.4M │  55.4M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop6      │
│ /snap/lxd/16922   │  70.6M │  70.6M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop2      │
│ /snap/lxd/18150   │  67.8M │  67.8M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop1      │
│ /snap/snapd/9607  │  31.0M │  31.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop5      │
│ /snap/snapd/9721  │  31.0M │  31.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop7      │
╰───────────────────┴────────┴────────┴───────┴───────────────────────────────┴──────────┴─────────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                               │
├────────────────┬────────┬──────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │   SIZE │ USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼──────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev           │ 447.8M │   0B │ 447.8M │                               │ devtmpfs │ udev       │
│ /dev/shm       │ 490.6M │   0B │ 490.6M │                               │ tmpfs    │ tmpfs      │
│ /run           │  98.1M │ 1.3M │  96.9M │ [....................]   1.3% │ tmpfs    │ tmpfs      │
│ /run/lock      │   5.0M │   0B │   5.0M │                               │ tmpfs    │ tmpfs      │
│ /run/snapd/ns  │  98.1M │ 1.3M │  96.9M │ [....................]   1.3% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │  98.1M │   0B │  98.1M │                               │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │ 490.6M │   0B │ 490.6M │                               │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴──────┴────────┴───────────────────────────────┴──────────┴────────────╯

The /snapd/* directories shouldn't be there, I think.

let's try a bind mount:

%: cd /tmp
%: mkdir test1 test2
%: sudo mount --bind test1 test2
%: duf
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 9 local devices                                                                                          │
├───────────────────┬────────┬────────┬───────┬───────────────────────────────┬──────────┬─────────────────┤
│ MOUNTED ON        │   SIZE │   USED │ AVAIL │              USE%             │ TYPE     │ FILESYSTEM      │
├───────────────────┼────────┼────────┼───────┼───────────────────────────────┼──────────┼─────────────────┤
│ /                 │  18.2G │  15.2G │  2.2G │ [################....]  83.3% │ ext4     │ /dev/vg/lv_root │
│ /boot             │ 461.0M │ 388.3M │ 48.8M │ [################....]  84.2% │ ext2     │ /dev/sda1       │
│ /snap/core18/1885 │  55.4M │  55.4M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop0      │
│ /snap/core18/1932 │  55.4M │  55.4M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop6      │
│ /snap/lxd/16922   │  70.6M │  70.6M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop2      │
│ /snap/lxd/18150   │  67.8M │  67.8M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop1      │
│ /snap/snapd/9607  │  31.0M │  31.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop5      │
│ /snap/snapd/9721  │  31.0M │  31.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop7      │
│ /tmp/test2        │  18.2G │  15.2G │  2.2G │ [################....]  83.3% │ ext4     │ /dev/vg/lv_root │
╰───────────────────┴────────┴────────┴───────┴───────────────────────────────┴──────────┴─────────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                               │
├────────────────┬────────┬──────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │   SIZE │ USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼──────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev           │ 447.8M │   0B │ 447.8M │                               │ devtmpfs │ udev       │
│ /dev/shm       │ 490.6M │   0B │ 490.6M │                               │ tmpfs    │ tmpfs      │
│ /run           │  98.1M │ 1.3M │  96.9M │ [....................]   1.3% │ tmpfs    │ tmpfs      │
│ /run/lock      │   5.0M │   0B │   5.0M │                               │ tmpfs    │ tmpfs      │
│ /run/snapd/ns  │  98.1M │ 1.3M │  96.9M │ [....................]   1.3% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │  98.1M │   0B │  98.1M │                               │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │ 490.6M │   0B │ 490.6M │                               │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴──────┴────────┴───────────────────────────────┴──────────┴────────────╯

/proc/self/mountinfo

24 30 0:22 / /sys rw,nosuid,nodev,noexec,relatime shared:7 - sysfs sysfs rw
25 30 0:5 / /proc rw,nosuid,nodev,noexec,relatime shared:14 - proc proc rw
26 30 0:6 / /dev rw,nosuid,noexec,relatime shared:2 - devtmpfs udev rw,size=458516k,nr_inodes=114629,mode=755
27 26 0:23 / /dev/pts rw,nosuid,noexec,relatime shared:3 - devpts devpts rw,gid=5,mode=620,ptmxmode=000
28 30 0:24 / /run rw,nosuid,nodev,noexec,relatime shared:5 - tmpfs tmpfs rw,size=100488k,mode=755
30 1 253:1 / / rw,relatime shared:1 - ext4 /dev/mapper/vg-lv_root rw,errors=remount-ro
31 24 0:7 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:8 - securityfs securityfs rw
32 26 0:26 / /dev/shm rw,nosuid,nodev shared:4 - tmpfs tmpfs rw
33 28 0:27 / /run/lock rw,nosuid,nodev,noexec,relatime shared:6 - tmpfs tmpfs rw,size=5120k
34 24 0:28 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:9 - tmpfs tmpfs ro,mode=755
35 34 0:29 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:10 - cgroup2 cgroup2 rw
36 34 0:30 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,xattr,name=systemd
37 24 0:31 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:12 - pstore pstore rw
38 24 0:32 / /sys/fs/bpf rw,nosuid,nodev,noexec,relatime shared:13 - bpf none rw,mode=700
39 34 0:33 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,perf_event
40 34 0:34 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,memory
41 34 0:35 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,cpuset,clone_children
42 34 0:36 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,blkio
43 34 0:37 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,cpu,cpuacct
44 34 0:38 / /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime shared:20 - cgroup cgroup rw,net_cls,net_prio
45 34 0:39 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:21 - cgroup cgroup rw,devices
46 34 0:40 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:22 - cgroup cgroup rw,hugetlb
47 34 0:41 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:23 - cgroup cgroup rw,pids
48 34 0:42 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:24 - cgroup cgroup rw,rdma
49 34 0:43 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:25 - cgroup cgroup rw,freezer
50 25 0:44 / /proc/sys/fs/binfmt_misc rw,relatime shared:26 - autofs systemd-1 rw,fd=28,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=16344
51 26 0:45 / /dev/hugepages rw,relatime shared:27 - hugetlbfs hugetlbfs rw,pagesize=2M
52 26 0:20 / /dev/mqueue rw,nosuid,nodev,noexec,relatime shared:28 - mqueue mqueue rw
53 24 0:8 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:29 - debugfs debugfs rw
54 24 0:12 / /sys/kernel/tracing rw,nosuid,nodev,noexec,relatime shared:30 - tracefs tracefs rw
55 24 0:46 / /sys/fs/fuse/connections rw,nosuid,nodev,noexec,relatime shared:31 - fusectl fusectl rw
56 24 0:21 / /sys/kernel/config rw,nosuid,nodev,noexec,relatime shared:32 - configfs configfs rw
124 30 7:0 / /snap/core18/1885 ro,nodev,relatime shared:67 - squashfs /dev/loop0 ro
130 30 7:2 / /snap/lxd/16922 ro,nodev,relatime shared:71 - squashfs /dev/loop2 ro
142 30 8:1 / /boot rw,relatime shared:79 - ext2 /dev/sda1 rw
610 30 0:52 / /var/lib/lxcfs rw,nosuid,nodev,relatime shared:239 - fuse.lxcfs lxcfs rw,user_id=0,group_id=0,allow_other
433 28 0:54 / /run/user/1000 rw,nosuid,nodev,relatime shared:308 - tmpfs tmpfs rw,size=100484k,mode=700,uid=1000,gid=1000
633 28 0:24 /snapd/ns /run/snapd/ns rw,nosuid,nodev,noexec,relatime shared:248 - tmpfs tmpfs rw,size=100488k,mode=755
927 30 7:5 / /snap/snapd/9607 ro,nodev,relatime shared:417 - squashfs /dev/loop5 ro
684 30 7:7 / /snap/snapd/9721 ro,nodev,relatime shared:373 - squashfs /dev/loop7 ro
716 30 7:6 / /snap/core18/1932 ro,nodev,relatime shared:374 - squashfs /dev/loop6 ro
374 50 0:79 / /proc/sys/fs/binfmt_misc rw,nosuid,nodev,noexec,relatime shared:267 - binfmt_misc binfmt_misc rw
406 53 0:12 / /sys/kernel/debug/tracing rw,nosuid,nodev,noexec,relatime shared:277 - tracefs tracefs rw
127 30 7:1 / /snap/lxd/18150 ro,nodev,relatime shared:69 - squashfs /dev/loop1 ro
664 633 0:4 mnt:[4026532575] /run/snapd/ns/lxd.mnt rw shared:249 - nsfs nsfs rw
387 30 253:1 /tmp/test1 /tmp/test2 rw,relatime shared:1 - ext4 /dev/mapper/vg-lv_root rw,errors=remount-ro
ProactiveServices commented 3 years ago

Also seeing this on Kubuntu 20.04 LTS and Raspbian (Debian) 10, duf build from source commit eefe880. I'm wondering if it might be a parsing bug that's also causing filesystems mounted through /dev/mapper, e.g. LUKS volumes, not to be displayed properly in the filesystem column. On both systems I'm seeing incorrect strings, such as /dev/backup/drive_crypt when it should be /dev/mapper/backup-drive_crypt.

LunNova commented 11 months ago

Similar issue on NixOS unstable, with bind mounts involving btrfs subvolumes.

fstab excerpt:

/dev/disk/by-label/amayadori_persist /persist btrfs x-initrd.mount,defaults,subvol=@persist,ssd,discard=async,rw,noatime,compress=zstd,space_cache=v2,autodefrag 0 0
/persist/var/log /var/log auto x-initrd.mount,bind 0 0
/persist/var/tmp /var/tmp auto x-initrd.mount,bind 0 0

duf excerpt:

│ MOUNTED ON         │   SIZE │   USED │  AVAIL │         USE%        │ TYPE  │ FILESYSTEM     │
├────────────────────┼────────┼────────┼────────┼─────────────────────┼───────┼────────────────┤
│ /persist           │ 239.3G │  73.0G │ 159.8G │ [###.......]  30.5% │ btrfs │ /dev/nvme0n1p4 │
│ /var/log           │ 239.3G │  73.0G │ 159.8G │ [###.......]  30.5% │ btrfs │ /dev/nvme0n1p4 │
│ /var/tmp           │ 239.3G │  73.0G │ 159.8G │ [###.......]  30.5% │ btrfs │ /dev/nvme0n1p4 │

/proc/self/mountinfo excerpt:

33 1 0:30 / / rw,relatime shared:1 - tmpfs tmpfs rw,size=2097152k,mode=755
35 33 0:31 /@persist /persist rw,noatime shared:2 - btrfs /dev/nvme0n1p4 rw,compress=zstd:3,ssd,discard=async,space_cache=v2,autodefrag,subvolid=256,subvol=/@persist
45 33 0:31 /@persist/var/log /var/log rw,noatime shared:14 - btrfs /dev/nvme0n1p4 rw,compress=zstd:3,ssd,discard=async,space_cache=v2,autodefrag,subvolid=256,subvol=/@persist
46 33 0:31 /@persist/var/tmp /var/tmp rw,noatime shared:15 - btrfs /dev/nvme0n1p4 rw,compress=zstd:3,ssd,discard=async,space_cache=v2,autodefrag,subvolid=256,subvol=/@persist
pernu commented 5 months ago

On Arch Linux, 6.8.2 kernel, ext4 bind mounts are not being hidden by -hide binds and nothing shows up when using -only binds. The tool is clearly not able to detect that a device is a bind mount, unlike df and findmnt. This definitely impacts the usefulness of the tool unfortunately.