trapexit / mergerfs

a featureful union filesystem
http://spawn.link
Other
4.03k stars 168 forks source link

Failing to mount from fstab on boot, but can mount from command line #1300

Closed jmineau closed 5 months ago

jmineau commented 5 months ago

Description

I have a fairly simple setup - two external drives, both with a directory M-NAS, that I want to merge to /share/M-NAS.

This is my fstab:

# External Drives UUID=d3963381-8288-4274-b584-280b9dc5785b /mnt/hdd/M-Drive ext4 defaults 0 0 UUID=8c6aafeb-beef-4404-aff5-bbbfc8d1a5ef /mnt/hdd/MyBook ext4 defaults 0 0
# mergerfs /mnt/hdd/*/M-NAS /share/M-NAS fuse.mergerfs cache.files=partial,dropcacheonclose=true,category.create=mfs,fsname=M-NAS 0 0

After boot, running ls -la /share returns

ls: cannot access '/share/M-NAS': No such file or directory total 8 drwxr-xr-x 3 root root 4096 Feb 1 07:55 . drwxr-xr-x 20 root root 4096 Feb 1 07:55 .. d????????? ? ? ? ? ? M-NAS

However, I can sudo umount /share/M-NAS && sudo mount -a and everything works

james@m-pi:~ $ ls -la /share/M-NAS/ total 16 drwxr-xr-x 2 james james 4096 Jan 30 09:17 . drwxr-xr-x 3 root root 4096 Feb 1 07:55 .. drwxr-xr-x 5 james james 4096 Jan 3 10:45 media drwxr-xr-x 3 james james 4096 Jan 4 09:21 wkspace

The command line version works as well:

sudo mergerfs -o cache.files=partial,dropcacheonclose=true,category.create=mfs,fsname=M-NAS /mnt/hdd/\*/M-NAS /share/M-NAS

To Reproduce

  1. I started with a fresh copy of Raspberry Pi OS Lite (64 Bit)
  2. Did the ole sudo apt update && sudo apt upgrade
  3. Make and chown -R /mnt/hdd/* and /share/M-NAS to my user james
  4. Mount my external drives
  5. Installed the lastest release of mergerfs (as of 2024-02-01 it is 2.39.0)
  6. Attempt boot

System information:

Linux m-pi 6.1.0-rpi8-rpi-v8 # 1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux mergerfs v2.39.0

I don't know how to strace the boot...

Additional context

This seems similar to #1148 but I am running the latest release. I thought maybe it would be a permissions issue, but since it works outside of the boot, I don't think this is it.

trapexit commented 5 months ago

Look at your boot logs. You will likely see that those paths don't exist at boot. You are pointing to locations inside a mount point, correct? If mergerfs runs before them then naturally those paths won't exist. As mentioned in the docs the globbing happens at configure/start time. You must either use dependencies to force mergerfs to be mounted last or if your init system mounts things concurrently you can try the branches-mount-timeout option. The best bet is the former.

jmineau commented 5 months ago

Thank you for your dedication to support.

That makes sense and I think you are right. Using journalctl -b to get my most recent boot without using branches-mount-timeout, I see that the system tries to mount M-NAS about 2 seconds before the two other drives and I believe fails due to the directories not being MTP devices?

Feb 02 07:20:42 m-pi mtp-probe[337]: bus: 2, device: 2 was not an MTP device Feb 02 07:20:42 m-pi mtp-probe[339]: bus: 1, device: 4 was not an MTP device

However, when I add in a 3 second delay with branches-mount-timeout, I see mergerfs wait, the system mounts the two external drives, but after 3 seconds I get these messages: boot_3s_delay.log

Feb 02 07:29:55 m-pi mergerfs[323]: /mnt/hdd/*/M-NAS not mounted within timeout Feb 02 07:29:55 m-pi mergerfs[323]: Continuing to mount mergerfs despite 1 branches not being different from the mountpoint filesystem Feb 02 07:29:55 m-pi mergerfs[505]: running basic garbage collection Feb 02 07:29:55 m-pi mergerfs[505]: threadpool (fuse.read): spawning 4 threads w/ max queue depth 4 Feb 02 07:29:55 m-pi mergerfs[505]: read-thread-count=4; process-thread-count=-1; process-thread-queue-depth=-1; pin-threads=false; Feb 02 07:29:55 m-pi systemd[1]: Mounted share-M\x2dNAS.mount - /share/M-NAS.

resulting in the drives not being merged. I tried 1,3,5,10,&20 seconds and got the same 'not mounted within timeout' message.

I have attached both logs. Thank you again so much for your help!

jmineau commented 5 months ago

Is this what you mean by dependencies? Where would I put this line?

https://askubuntu.com/a/1054394

jmineau commented 5 months ago

Oh they're just fstab options, silly me...

It works! I put this in my fstab

x-systemd.requires-mounts-for=/mnt/hdd/M-Drive,x-systemd.requires-mounts-for=/mnt/hdd/MyBook

I don't really understand the difference between x-systemd.requires-mounts-for & x-systemd.requires, but this seems to be working.

I will have to play around to see if I can use wildcards with this too rather then having to enter each drive.

Thank you so much again!

trapexit commented 5 months ago

if the mount timeout isn't working then something about the setup is waiting for it.

https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html

Details on the settings.