Nfs mounts from /etc/fstab fail on boot

I want to mount an nfs share on boot (the following one and also /home). After booting, I can manually mount it just fine with something like

mount server:/mnt/oracle /mnt/oracle

However, during boot the network is not yet up:

# systemctl status mnt-oracle.mount

  • mnt-oracle.mount - /mnt/oracle
    Loaded: loaded (/etc/fstab)
    Active: failed (Result: exit-code) since Sun 2015-06-14 21:38:51 UTC; 7min ago
    Where: /mnt/oracle
    What: deusex:/mnt/oracle
    Docs: man:fstab(5)
    man:systemd-fstab-generator(8)
    Process: 269 ExecMount=/bin/mount -n deusex:/mnt/oracle /mnt/oracle -t nfs -o ro (code=exited, status=32)

Jun 14 21:38:51 osmc mount[269]: mount.nfs: Network is unreachable
Jun 14 21:38:51 osmc systemd[1]: mnt-oracle.mount mount process exited, code=exited status=32
Jun 14 21:38:51 osmc systemd[1]: Failed to mount /mnt/oracle.
Jun 14 21:38:51 osmc systemd[1]: Unit mnt-oracle.mount entered failed state.

There have been previous posts about that topic:
https://discourse.osmc.tv/t/osmc-alpha-2-problem-mounting-nfs-share-at-boot-via-fstab/
https://discourse.osmc.tv/t/nfs-mounting-issues
https://discourse.osmc.tv/t/solved-nfs-share-not-mounting-at-boot/

They propose to use the mount options _netdev or x-systemd.automount,noauto. The first one (_netdev) does not help. The second one does suppress the error message - but also the mounting. The “noauto” option will just cause it not to be automatically mounted.

For testing, I created an /etc/network/interfaces (auto eth0; allow-hotplug eth0; iface eth0 inet dhcp) - the network still comes up as before, but didn’t help with the nfs share. I also tried to enter the mount commands into the /etc/rc.local, but that resulted in the same “mount.nfs: Network is unreachable” error.

I believe this to be a bug - the system should know it needs a running networking before it can even try to mount nfs shares. (I think I’m using RC3.)

_netdev is wrong, the correct options to use with systemd are x-systemd.automount,noauto and yes it does work. :wink:

OSMC doesn’t support /etc/network/interfaces because we use connman not network manager, so you’re wasting your time going in that direction.

Trying to use rc.local will also not work because rc.local does not wait for the network to come up.

There is no bug there - you’re just not using the right mount options for systemd. Forget everything you learnt on other systems - systemd does not handle network mounts the same as other init systems, which means 90% of the tutorials and recommended settings out there are wrong for systemd.

x-systemd.automount in fstab creates a systemd automount unit on the fly which handles on-demand mounting:

http://www.freedesktop.org/software/systemd/man/systemd.mount.html

You can also enable wait for network in the GUI which will cause any services that declare dependencies on network-online.target to be delayed until the network is actually up (this includes Kodi) but this isn’t really neccessary for x-systemd.automount because it is both on demand and has a built in retry mechanism. Even without wait for the network enabled it will automatically retry until the network is up.

Yes, indeed! :smile: What I didn’t know: it mounts the thing on demand! After boot I checked df -h and the output of mount, but my nfs share didn’t show up. Only after e.g. ls /mnt/oracle/ it gets mounted in the background. (I guess any comment on that design idea goes into the systemd holy wars, which is not the topic here :wink: )

So, you’re right. The following line in my /etc/fstab does work as designed:

deusex:/mnt/oracle /mnt/oracle nfs ro,x-systemd.automount,noauto 0 0

Thanks!

Would there be any options to add, to speed up the NFS somehow we should use ? especially when using WiFI ?
I already have the IR repeat/not working issue (during the caching phase)…

Your question is unrelated to what was being discussed in this thread so you should really start a new thread of your own.