1

I have a Ubuntu machine that takes an iSCSI block, mounts it as ext4, then exports it as an NFS share. On boot, NFS fails to start as the iSCSI directory mounts have not loaded yet.

"exportfs: Failed to stat /mnt/iscsi/nfs: No such file or directory"

This works fine if I run nfs-kernel-server after the server starts.

Is there a way to force NFS to wait till the iSCSI block has been mounted?

Edit: Further investigation.. By forcing nfs-server.service to wait for mnt-iscsi.mount, I've triggered a dependency loop.

Dec 02 09:16:09 on1 systemd[1]: nfs-server.service: Found ordering cycle on mnt-iscsi.mount/start
Dec 02 09:16:09 on1 systemd[1]: nfs-server.service: Found dependency on remote-fs-pre.target/start
Dec 02 09:16:09 on1 systemd[1]: nfs-server.service: Found dependency on nfs-server.service/start
Dec 02 09:16:09 on1 systemd[1]: nfs-server.service: Unable to break cycle starting with nfs-server.service/start

Am stuck trying to figure out what to change.

Thanks!

Joshua
  • 11
  • 1
    If you services, NFS and iSCSI, are started with systemd, see this Stack Overflow answer – ender.qa Dec 01 '19 at 23:19
  • @ender.qa /etc/systemd/system/iscsi.service exists but there isn't any nfs-server.service in /etc/systemd/. I edited /lib/systemd/system/nfs-server.service and placed a line After=iscsi.service under [Unit] but no luck – Joshua Dec 01 '19 at 23:37
  • First, it's best practice not to edit the files in /lib/systemd/system, you can create your own custom options for nfs-server in /etc/systemd/system. See this Ask Ubuntu answer for lots of details. Second, you also may need to run systemctl daemon-reload. – ender.qa Dec 02 '19 at 00:33
  • @ender.qa I created a loop script that slept until /mnt/iscsi was mounted and it never happens - the system gets stuck in boot forever. My theory is that there is some hierarchy issue where something else requires nfs-server.service to load before other stuff and iscsi.service is dependent on that. Is there a way to figure out which? – Joshua Dec 02 '19 at 00:48
  • Dependency loop is confirmed, more details added. – Joshua Dec 02 '19 at 01:24
  • Searching stack exchange for systemd dependency loop points to this answer. See if you can plot yourself such a graph to show what depends on what else. The other answers have some diagnostic tools as well. – ender.qa Dec 02 '19 at 02:31

1 Answers1

1

In my case, the issue seems to have been that my iSCSI drive is considered part of remote-fs-pre.target, and systemd defaults want to start nfs-server Before that.

Just putting an After line in /etc/systemd/system/nfs-server.service.d/override.conf creates a loop, like what you indicated in your question.

My solution was to use:

systemctl edit --full nfs-server

which clones the full settings so that you can comment out:

##Before=remote-fs-pre.target

and add:

After=mnt-foo.mount

So far so good.

AdminBee
  • 22,803
dlo
  • 113