DietPi v10.6.2 - Disk Usage - /mnt/*

“Login banner” only shows:

Disk Usage :
 - / :  45.4% :   416.3 GiB of   916.8 GiB

despite:

It worked ones (all 3 disk did show up), but than disappeart again.

Did not return after reboot and poweroff/on

─────────────────────────────────────────────────────
 DietPi v10.6.2 : 06:54 - Sun 08/09/26
 ─────────────────────────────────────────────────────
 - Device model : Native PC (x86_64)
 - Kernel : 7.1.3+deb13-amd64
 - CPU temp : 32 °C / 89 °F : Cool runnings
 - FQDN/hostname : DietPi
 - LAN IP : 192.168.178.22 (eth0)
 - MOTD : DietPi v10.6 has been released. Check out all changes:
          https://github.com/MichaIng/DietPi/pull/8235
 ─────────────────────────────────────────────────────
 Disk Usage :
 - / :  45.4% :   416.3 GiB of   916.8 GiB
 ─────────────────────────────────────────────────────

Torben

Did mange to get it back:

 Disk Usage :
 - /     :  45.4% :   416.3 GiB of   916.8 GiB
 - terra :  45.5% :   416.4 GiB of   915.8 GiB
 - tor   :  45.5% :   416.3 GiB of   915.8 GiB

But disappeart again after reboot:

Disk Usage :
 - / :  45.4% :   416.3 GiB of   916.8 GiB

Torben

Thanks for the report. Something we didn’t think about is that, with x-systemd-automount, drivers are not mounted until their mountpoint is accessed for the first time.

The best/cheapest solution to this is probably a test -e <mountpoint> for every directory matching the added mountpoint patterns, to trigger the automount if not done yet. That wouldn’t cover mounts in subdirs, though. Another approach would be to loop through active systemd automount units, and start them. But calling systemctl is somewhat expensive, and deriving the path from the automount unit name is not 100% failsafe, due to some character conversion and removals. Parsing the content of the related mount unit for the true raw path is expensive again.

EDIT: Ah wait, the globs do not match subdirs anyway, and it is sufficiently unlikely that someone would use re:/mnt/+ or similar to match subdir mounts like /mnt/foo/bar, which is generally quite uncommon. So a test -e <dir> loop through every matching dir by prefix should cover almost all cases.

EDIT2: Or we add the --fstab argument to the findmnt call, which includes unmounted drives listed in /etc/fstab. It does not include any mounts outside of /etc/fstab, i.e. skips temporary direct mounts, such automounted via udisks2, or if systemd mount units are created directly, bypassing /etc/fstab. But those are probably exotic cases.

Thanks @MichaIng

It is getting more and exotic :slight_smile:

Now this showup:

after X at “terra” and “tor” than this:

 Disk Usage :
 - /     :  45.5% :   417.2 GiB of   916.8 GiB
 - terra :  45.5% :   416.4 GiB of   915.8 GiB
 - tor   :  45.5% :   416.3 GiB of   915.8 GiB

After reboot:

Disk Usage :
 - /     :  45.5% :   417.1 GiB of   916.8 GiB
 - terra :    ??? :     ??? GiB of     ??? GiB
 - tor   :    ??? :     ??? GiB of     ??? GiB

Torben

Yes, this is also expected: If a mount was added explicitly, rather than as glob/regex pattern, it is always shown. But if the values cannot be obtained (as it is not mounted), they are replaced with ???. A “not mounted” text instead would be better.

Thanks @MichaIng

It how shows this:

Both - “terra” and “tor” has been mounted to the server long time ago.

Torben

@MichaIng - Sorry, I can’t find any pattern in this. How it shows:

Disk Usage :
 - /     :  45.5% :   417.0 GiB of   916.8 GiB
 - terra :  45.5% :   416.4 GiB of   915.8 GiB
 - tor   :  45.5% :   416.3 GiB of   915.8 GiB

Sometimes it works and something not. Strange :slight_smile:

Torben

PS: When it works, it is a nice service (information) about “Disk Usage”. Thanks

As said, the important factor is whether a disk has been actually mounted or not. If they are defined in /etc/fstab with x-systemd.automount (default for external drives mounted with dietpi-drive_manager), they are not mounted automatically at boot. They are mounted instead once anything is trying to access them.

Do a reboot, then check df or findmnt --real, and you won’t see those drives listed there either. But as fast as you do e.g. ls /mnt/terra, the drive will be mounted almost instantly. From that point on it appears in df and findmnt as well.

So what we need to do in the banner, is triggering the automount for at best all mountpoints which match the selection and pattern. The question is how to do this as cheaply as possible (regarding processing time and I/O). And findmnt --fstab actually seems the best solution to me right now. It can even query size and usage for unmounted drives, and I am not even sure how it does this:

findmnt --fstab -no TARGET,SIZE,USED,USE%

EDIT: Ah, findmnt actually mounts and unmounts again the filesystems, to read this information. And doing so, it is not even significantly slower. Very nice!
EDIT2: Nope, I misinterpreted the output. It shows the rootfs size+usage for unmounted drives. The mounts+unmounts in dmesg I saw were from past cron jobs, not from the findmnt call :sweat_smile:. So back to the test -e loop.

Your right, when using ls ls /mnt/terra and ls /mnt/tor it shows up again:

 Disk Usage :
 - /     :  45.5% :   417.0 GiB of   916.8 GiB
 - terra :  45.5% :   416.4 GiB of   915.8 GiB
 - tor   :  45.5% :   416.3 GiB of   915.8 GiB

Torben

Yes :slight_smile:

root@DietPi:~# findmnt --fstab -no TARGET,SIZE,USED,USE%
/tmp         7.6G     4K  0%
/var/log      50M    16K  0%
/          916.8G   417G 45%
/boot/efi     63M  46.1M 73%
/mnt/tor   915.8G 416.3G 45%
/mnt/terra 915.8G 416.4G 45%
root@DietPi:~#

Torben

PS: But it still would be very nice to have in the banner :slight_smile:

I actually misinterpreted the findmnt --fstab output, and mistook the mount+unmount logs in my dmesg from past backup cron jobs for such triggered by findmnt. As you can see from your output, it does list unmounted drives, but size + usage data is from the rootfs, not from the unmounted filesystem/drive.

Back to the test -e loop for matches.