You are not logged in.

#1 2016-11-11 00:53:30

barius
Member
From: Europe
Registered: 2016-11-10
Posts: 9

nfs mount fails at boot, network-online.target not waiting for dhcp

Hi all, any tips on this would be valued.  (Not really a noob topic IMO but I'm a noob on this forum... wink )

I added an NFS filesystem in /etc/fstab and I can mount it fine with a command: sudo mount /home/nfs.
Systemd has created the correct mount unit so I can also (u)mount with

sudo systemctl start home-nfs.mount
sudo systemctl stop home-nfs.mount

The problem is that it fails systematically on boot because the network is not yet up.

20:15:37 systemd[1]: Reached target Network is Online.
20:15:37 systemd[1]: Mounting /home/nfs...
20:15:38 mount[490]: mount.nfs: Network is unreachable
20:15:38 systemd[1]: home-nfs.mount: Mount process exited, code=exited status=32
20:15:38 systemd[1]: Failed to mount /home/nfs.

This despite the dependency on network-online.target (which seems to be respected from above log extract).

$ systemctl list-dependencies home-nfs.mount
home-nfs.mount
* |--.mount
* |-system.slice
* `-network-online.target

From the network-online target documentation I would expect the network interface (at least one!) to be configured before the network-online target is reached.
But the logs show that the DHCP address is not assigned until at least 2 seconds after the target is reached, after the nfs mount has failed.

I guess the correct question to ask is: How can I ensure that my network really is online (DHCP address assigned) before the network-online target is reached?

The network config is very simple: the wireless if is not yet configured and the wired if (renamed to fe0 with a udev rule) is configured with systemd-networkd:

$ more /etc/systemd/network/fe0-dhcp.network
[Match]
Name=fe0

[Network]
DHCP=ipv4

Note that the network comes up without any problem, only it happens after the network-online target is reached.

Here is a more complete log extract.

20:15:29 kernel: tg3.c:v3.137 (May 11, 2014)
20:15:29 kernel: tg3 0000:03:00.0 eth0: Tigon3 [partno(none) rev 5784100] (PCI Express) MAC address 00:1f:16:cf:7f:cd
20:15:29 kernel: tg3 0000:03:00.0 eth0: attached PHY is 5784 (10/100/1000Base-T Ethernet) (WireSpeed[1], EEE[0])
20:15:29 kernel: tg3 0000:03:00.0 eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] TSOcap[1]
20:15:29 kernel: tg3 0000:03:00.0 eth0: dma_rwctrl[76180000] dma_mask[64-bit]
20:15:32 kernel: ath9k 0000:09:00.0 wl0: renamed from wlan0
20:15:32 kernel: tg3 0000:03:00.0 fe0: renamed from eth0
20:15:33 systemd[1]: Starting Flush Journal to Persistent Storage...
20:15:35 systemd[1]: Reached target Local File Systems.
20:15:36 systemd[1]: Started Flush Journal to Persistent Storage.
20:15:36 systemd[1]: Reached target System Initialization.
20:15:36 systemd[1]: Started Daily rotation of log files.
20:15:36 systemd[1]: Listening on D-Bus System Message Bus Socket.
20:15:36 systemd[1]: Reached target Sockets.
20:15:36 systemd[1]: Reached target Basic System.
20:15:36 systemd[1]: Started D-Bus System Message Bus.
20:15:37 systemd[1]: Starting Network Service...
20:15:37 systemd[1]: Starting Login Service...
20:15:37 systemd-networkd[467]: Enumeration completed
20:15:37 kernel: IPv6: ADDRCONF(NETDEV_UP): fe0: link is not ready
20:15:37 systemd-networkd[467]: fe0: Renamed to eth0
20:15:37 systemd-networkd[467]: wl0: Renamed to wlan0
20:15:37 systemd-networkd[467]: wlan0: Renamed to wl0
20:15:37 systemd-networkd[467]: eth0: Renamed to fe0
20:15:37 systemd-networkd[467]: fe0: IPv6 enabled for interface: Success
20:15:37 systemd[1]: Reached target Timers.
20:15:37 systemd[1]: Started Network Service.
20:15:37 systemd[1]: Started Virtual console mouse server.
20:15:37 systemd[1]: Reached target Network.
20:15:37 systemd[1]: Starting Network Name Resolution...
20:15:37 systemd[1]: Reached target Network is Online.
20:15:37 systemd[1]: home-nfs.mount: Directory /home/nfs to mount over is not empty, mounting anyway.
20:15:37 systemd[1]: Mounting /home/nfs...
20:15:37 systemd[1]: Started Login Service.
20:15:37 systemd[1]: Started Network Name Resolution.
20:15:37 systemd[1]: Starting Preprocess NFS configuration...
20:15:38 systemd[1]: Reached target Host and Network Name Lookups.
20:15:38 systemd[1]: Listening on RPCbind Server Activation Socket.
20:15:38 systemd[1]: Started Preprocess NFS configuration.
20:15:38 systemd[1]: Starting NFS status monitor for NFSv2/3 locking....
20:15:38 rpc.statd[499]: Version 1.3.3 starting
20:15:38 rpc.statd[499]: Flags: TI-RPC
20:15:38 systemd[1]: Starting RPC bind service...
20:15:38 systemd[1]: Started RPC bind service.
20:15:38 rpc.statd[499]: Running as root. chown /var/lib/nfs to choose different user
20:15:38 systemd[1]: Started NFS status monitor for NFSv2/3 locking..
20:15:38 mount[490]: mount.nfs: Network is unreachable
20:15:38 systemd[1]: home-nfs.mount: Mount process exited, code=exited status=32
20:15:38 systemd[1]: Failed to mount /home/nfs.
20:15:38 systemd[1]: Dependency failed for Remote File Systems.
20:15:38 systemd[1]: remote-fs.target: Job remote-fs.target/start failed with result 'dependency'.
20:15:38 systemd[1]: home-nfs.mount: Unit entered failed state.
20:15:38 systemd[1]: Starting Permit User Sessions...
20:15:38 systemd[1]: Started Permit User Sessions.
20:15:38 systemd[1]: Reached target Multi-User System.
20:15:38 systemd[1]: Reached target Graphical Interface.
20:15:38 systemd[1]: Startup finished in 4.525s (kernel) + 13.399s (userspace) = 17.924s.
20:15:39 kernel: tg3 0000:03:00.0 fe0: Link is up at 100 Mbps, full duplex
20:15:39 kernel: tg3 0000:03:00.0 fe0: Flow control is on for TX and on for RX
20:15:39 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): fe0: link becomes ready
20:15:39 systemd-networkd[467]: fe0: Gained carrier
20:15:39 systemd-networkd[467]: fe0: DHCPv4 address 192.168.69.10/27 via 192.168.69.6
20:15:40 systemd-networkd[467]: fe0: Gained IPv6LL
20:15:53 systemd-networkd[467]: fe0: Configured

Offline

#2 2016-11-14 07:21:11

monodromy
Member
Registered: 2014-02-08
Posts: 65

Re: nfs mount fails at boot, network-online.target not waiting for dhcp

What does your /etc/fstab entry look like? I have

/path/to/mount     /mount/point        nfs     nfsvers=3,rw,rsize=8192,wsize=8192,users,nofail,noauto,x-systemd.automount,x-systemd.device-timeout=10  0 0

As mentioned on the wiki page,

noauto,x-systemd.automount

will not attempt to mount until you navigate to the mount point. There will be a short lag upon doing so.

Edit:

Actually, this wiki page is more relevant for you.

Last edited by monodromy (2016-11-14 07:25:20)

Offline

#3 2016-11-22 18:28:41

barius
Member
From: Europe
Registered: 2016-11-10
Posts: 9

Re: nfs mount fails at boot, network-online.target not waiting for dhcp

@monodromy, thanks but no, it's not that.

192.168.69.2:/srv/exports/nfshome  /home/nfs  nfs  proto=udp,vers=3,hard  0  0

As you see from the log extracts, system is trying to mount the volume (so yes it is auto not noauto) but is trying too soon, before the network is up.  The thing is that systemd-networkd's dhcp is only configuring the interface after the network-online target is reached.  Systemd does seem to be waiting for the network-online target before attempting the mount.  Only, conditions for that target appear not to be sufficient to guarantee that the really network is really online.  Whereas that would seem to be a reasonable expectation as that is the purpose of this target!

"network-online.target is a target that actively waits until the nework is "up", where the definition of "up" is defined by the network management software. Usually it indicates a configured, routable IP address of some kind. It's primary purpose is to actively delay activation of services until the network is set up..... By default all remote mounts defined in /etc/fstab pull this service in, in order to make sure the network is up before it is attempted to connect to a network share."

(From the network-online target documentation to which I referred earlier.

This looks like a fairly standard, basic setup.  I can imagine I am the first to run into this problem.  Or does nobody use NFS with systemd-networkd and DHCP???  (On another host, I use automount for the same NFS vol and netctl and there it works but of course the mount is only attempted much later, after a user has logged in...)

Offline

Board footer

Powered by FluxBB