0

I am trying to mount my NFS shares at boot time on a Raspberry Pi 4. It does not work and systemd complains that the network is unreachable. Manually mounting each shares works as expected. I have tried different things now. Instead of using /etc/fstab I use systemd services to mount the volumes like this:

[Unit]
Description=Mount NFS share Music
After=network-online.target
Wants=network-online.target

[Mount]
What=10.5.0.34:/music
Where=home/pi/media_storage/music
Options=auto
Type=nfs
TimeoutSec=60

[Install]
WantedBy=remote-fs.target

The two services systemd-networkd.service and systemd-networkd-wait-online.service are enabled. Here is the journalctl output:

Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: IAID 32:23:48:46
Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: adding address fe80::9819:5d1a:3c86:8b41
Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: rebinding lease of 10.5.0.43
Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: probing address 10.5.0.43/24
Nov 30 16:30:46 NextcloudPi dhcpcd[383]: eth0: soliciting an IPv6 router
Nov 30 16:30:47 NextcloudPi systemd-networkd[152]: eth0: Gained IPv6LL
Nov 30 16:30:47 NextcloudPi systemd-timesyncd[281]: Network configuration changed, trying to establish connection.
Nov 30 16:30:47 NextcloudPi systemd-networkd-wait-online[183]: ignoring: lo
Nov 30 16:30:47 NextcloudPi systemd[1]: Started Wait for Network to be Configured.
Nov 30 16:30:47 NextcloudPi systemd[1]: Reached target Network is Online.
Nov 30 16:30:48 NextcloudPi systemd[1]: Mounting Mount NFS share Music...
Nov 30 16:30:48 NextcloudPi systemd[1]: Started /etc/rc.local Compatibility.
Nov 30 16:30:48 NextcloudPi mount[498]: mount.nfs: Network is unreachable
Nov 30 16:30:48 NextcloudPi systemd[1]: mnt-music.mount: Mount process exited, code=exited, status=32/n/a
Nov 30 16:30:48 NextcloudPi systemd[1]: mnt-music.mount: Failed with result 'exit-code'.
Nov 30 16:30:48 NextcloudPi systemd[1]: Failed to mount Mount NFS share Music.
Nov 30 16:30:48 NextcloudPi systemd[1]: Reached target Remote File Systems.

According to journalctl the interface is configured and has a valid IP address. Why is mount.nfs complaining anyway?

  • Try adding "_netdev" the the options line. "Options=_netdev,auto" – d4n3sh Nov 30 '19 at 18:00
  • did not help... – Christoph Kuhr Nov 30 '19 at 19:37
  • For your manual mount, did you run mount or "systemctl restart mount.nfs" ? – d4n3sh Nov 30 '19 at 21:11
  • systemctl start mnt-music.service – Christoph Kuhr Nov 30 '19 at 21:30
  • Well, DHCP is not ready with its configuration. I need to use a different target than network-online.target. Right now, I have a messy workaround and use sshd.service as target, which works so far. Any suggestion and/or insight in how to use the network-online.target correctly would be appreciated. The documentation is pretty useless. – Christoph Kuhr Dec 1 '19 at 8:01
0

Since the network-online.target seems broken, no matter what I do, I developed a different and reliable solution.

I created a oneshot systemd script: "ping_barrier". It pings the NFS server until it succeeds. The WantedBy=nfs-client.target makes NFS wait for this service to finish.

[Unit]    
Description=Ping until Success

[Service]
Type=oneshot
ExecStart=/opt/ping_barrier.sh
StandardOutput=journal

[Install]
WantedBy=nfs-client.target

Here is the ping script, which loops, until the ping command is successful:

#!/bin/bash    
printf "%s" "waiting for FileServer ..."
while ! ping -c 1 -n -w 1 10.5.0.34 &> /dev/null
do
    printf "%c" "."
done
printf "\n%s\n"  "Server is back online"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.