zfs icon indicating copy to clipboard operation
zfs copied to clipboard

zfs-mount-generator nofail option does not work

Open iyzana opened this issue 9 months ago • 3 comments

System information

Type Version/Name
Distribution Name Arch Linux
Distribution Version rolling
Kernel Version 6.12.18-1-lts
Architecture x86_64
OpenZFS Version 2.3.1-1

Describe the problem you're observing

Mount units generated by zfs-mount-generator with org.openzfs.systemd:nofail=on set on the dataset still have Before=local-fs.target set in the running system.

That is because according to man 5 systemd.mount: "Mount units referring to local file systems automatically gain an After= dependency on local-fs-pre.target, and a Before= dependency on local-fs.target unless one or more mount options among nofail, x-systemd.wanted-by=, and x-systemd.required-by= is set."

The zfs-mount-generator does not itself set the Before=local-fs.target ordering when org.openzfs.systemd:nofail=on is set, but that does not keep systemd from then still adding it as a default dependency.

I believe zfs-mount-generator should also include nofail in the mount Options= in this case.

Describe how to reproduce the problem

  1. Set canmount=on and org.openzfs.systemd:nofail=on on a dataset.
  2. systemctl soft-reboot
  3. systemctl show mnt-<dataset>.mount | grep Before=
  4. Observe that local-fs.target is still included

Include any warning/errors/backtraces from the system logs

iyzana avatar Mar 14 '25 13:03 iyzana

I confirm this and it creates various ordering cycles in systemd, breaking the boot process.

Is there a workaround for this like an override or something? This really is a show-stopper for me right now.

Thanks

brevilo avatar May 30 '25 12:05 brevilo

Is there a workaround for this like an override or something?

Yes, by overriding the mount unit via systemctl edit mnt-DATASET.mount and appending nofail to the existing mount Options:

[Mount]
Options=...,nofail

Ugly and error-prone due to the now static mount options, but at least it's a workaround until this issue got resolved.

Cheers

brevilo avatar May 30 '25 13:05 brevilo

at least it's a workaround until this issue got resolved.

Actually, no. local-fs.target still sports an After=zfs-mount.service which in turn has a After=mnt-DATASET.mount in place. So, effectively, the order is still Before=local-fs.targetfor the mount unit due to these reverse dependencies. 😭

brevilo avatar May 30 '25 14:05 brevilo