Ubuntu – Systemd seems to ignore _netdev option for NFS in Ubuntu 16.04


I have the following mount for NFS in /etc/fstab: /media/share nfs hard,intr,retrans=10,timeo=10000000,_netdev 0 0

On reboot my system hangs; turns out it's the mount as proved by systemd-analyze blame.

The status:

● media-share.mount - /media/share
   Loaded: loaded (/etc/fstab; bad; vendor preset: enabled)
   Active: failed (Result: timeout) since Tue 2016-04-26 21:13:43 EDT; 6min ago
    Where: /media/share
     Docs: man:fstab(5)
  Process: 1071 ExecMount=/bin/mount /media/share -t nfs -o hard,intr,retrans=10,timeo=10000000,_netdev (code=kille

Apr 26 21:12:12 j-Lemur systemd[1]: Mounting /media/share...
Apr 26 21:13:42 j-Lemur systemd[1]: media-share.mount: Mounting timed out. Stopping.
Apr 26 21:13:42 j-Lemur systemd[1]: Mounted /media/share.
Apr 26 21:13:43 j-Lemur systemd[1]: media-share.mount: Unit entered failed state.

This appears to be a bug?

After logging in and running systemctl restart media-share.mount it is fixed (because the network is available now).

Best Answer

I had the same problem.

There's some info on the Ubuntu Community Help Wiki here suggesting it is intentional behaviour by Ubuntu 16:

Under NFSv3 (type nfs) the _netdev option will tell the system to wait to mount until the network is available. With a type of nfs4 this option is ignored, but can be used with mount -O _netdev in scripts later. Currently Ubuntu Server does not come with the scripts needed to auto-mount nfs4 entries in /etc/fstab after the network is up.

My solution was to the add "vers=3" before "_netdev", forcing the connection to use NFS v3. Obviously this might not help in your case, if you are relying on NFS v4.

Other options could include AutoFS or shell scripting.

Related Question