2

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!

6
  • 1
    If you services, NFS and iSCSI, are started with systemd, see this Stack Overflow answer Commented Dec 1, 2019 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 Commented Dec 1, 2019 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. Commented Dec 2, 2019 at 0: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? Commented Dec 2, 2019 at 0:48
  • Dependency loop is confirmed, more details added. Commented Dec 2, 2019 at 1:24

1 Answer 1

2

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.

1
  • same issues still in 2025 since noone fixes the basics... Commented Mar 16 at 21:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.