2

Ubuntu 20.04. I have a systemd mount file that mounts a remote NFS path. The mount file looks like this:

[Unit]
Description=/userdata
Wants=network-online.target
After=network-online.target

[Mount]
What=10.20.30.40:/data/users
Where=/userdata
Type=nfs
Options=nofail,rw,soft,intr,actimeo=60

[Install]
WantedBy=multi-user.target

Randomly, the path will fail to mount on reboot. It is enabled. If I start in manually, it works fine and mounts the /userdata/ directory.

Checking the status of the mount file gives a "Network is unreachable" error:

$ sudo systemctl status userdata.mount
● userdata.mount - /userdata
     Loaded: loaded (/lib/systemd/system/userdata.mount; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2021-06-07 09:56:27 EDT; 6h ago
      Where: /userdata
       What: 10.20.30.40:/data/users

Jun 07 09:56:27 hostname mount[474]: mount.nfs: Network is unreachable
Jun 07 09:56:27 hostname systemd[1]: userdata.mount: Mount process exited, code=exited, status=32/n/a
Jun 07 09:56:27 hostname systemd[1]: userdata.mount: Failed with result 'exit-code'.
Jun 07 09:56:27 hostname systemd[1]: Failed to mount /userdata.
Warning: journal has been rotated since unit was started, output may be incomplete.

From web searches, this is a common problem. It predates systemd, though, so the most common solution is "write a systemd mount file for it." In this case, I'm already using systemd, so that doesn't help.

I found an Arch Wiki comment that suggest I should enable systemd-networkd-wait-online.service to solve this problem. However, the command $ sudo systemctl status systemd-networkd-wait-online.service shows that this unit file is already enabled on my system.

So, I don't know what else to do. How do I get this path to mount consistently at startup?

Edit

I tried replacing Wants=network-online.target with Requires=network-online.target, but this did not fix or otherwise affect the problem.

1 Answer 1

1

I think your problem is Wants=network-online.target instead of Requires=network-online.target.

While Wants= asks for network-online.target to be started, it may ignore a failure in network-online.target. However, for an NFS this obviously is essential. Requires= strictly requests successful starts and running services. I think your network is a bit unstable during boot.

See Wants= vs. Requires= in systemd

1
  • That's a good idea, but it didn't work, unfortunately. After making that change, the directory still failed to mount on the second test reboot. Commented Jun 8, 2021 at 13:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .