Nfs share setup to automount in a laptop client

Have nfs share setup to automount in a laptop client. The server occasionally goes offline, and when it does, the laptop cannot reboot or shutdown (it seems to get stuck looking for the share). Are there mount options that tell the client to ignore missing share and proceed to reboot or shutdown cleanly, without having to manually umount the share.

these are the automount and mount unit files:

[Unit]
Description=Automount NFS share

[Automount]
Where=/mnt/Data
TimeoutIdleSec=60

[Install]
WantedBy=multi-user.target
[Unit]
Description=Mount NFS Share

[Mount]
What=server
Where=/mnt/Data
Type=nfs
Options=vers=4,_netdev,rw,suid,users,async,nofail,
TimeoutSec=1
LazyUnmount=true
ForceUnmount=true


[Install]
WantedBy=multi-user.target

if you enabled the mount unit - you will get issues when the server goes offline.

Wnen using the automount - only enable automount unit.

The automount will activate the mount unit when required and disable after TimeoutIdleSec so with your current autmount it will unmount after 60s idle time.

EDIT:
A tip for handling the shares automagically can be found at NFS - ArchWiki

1 Like

Completely remove the install section from your mount unit, after disabling it.
Because you should never enable the mount unit, if you have an automount unit…

If you would like to monitor/watch if the NFS server is reachable and accordingly enable/disable the NFS share on the client, you should create a manual service with a script that checks the connection and enable/disable to automount unit accordingly.
This is best done using the nc -vz command :wink:

1 Like