I need to mount NFS shares on my laptop when I am in the office and plugged into a wired Ethernet connection (via a dock). Is there a reliable way to automatically mount and unmount NFS shares in this scenario?

I'm running Arch Linux. I tried the NetworkManager dispatcher method described here: NFS - ArchWiki

Using that method, my system will freeze (hang, become unresponsive) when I try to connect to any WiFi access point outside the office.

All of my NFS mounts use these options:

nfsserver:/path/one/ /path/one nfs _netdev,defaults,noatime,nodiratime,soft,retrans=6,timeo=20,retry=0,rsize=32768,wsize=32768,proto=tcp   0 0

The full instructions I used from the link above are pasted here:

Enable and start the NetworkManager-dispatcher.service.

The following script safely unmounts the NFS shares before the relevant network connection is disabled by listening for the pre-down and vpn-pre-down events:

Note: This script ignores mounts with the noauto option.

Place this script at /etc/NetworkManager/dispatcher.d/30-nfs.sh


# Find the connection UUID with "nmcli con show" in terminal.
# All NetworkManager connection types are supported: wireless, VPN, wired...

if [[ "$CONNECTION_UUID" == "$WANTED_CON_UUID" ]]; then

    # Script parameter $1: NetworkManager connection name, not used
    # Script parameter $2: dispatched event

    case "$2" in
            mount -a -t nfs4,nfs 
            umount -l -a -t nfs4,nfs >/dev/null

Make the script executable with chmod and create a symlink inside /etc/NetworkManager/dispatcher.d/pre-down to catch the pre-down events:

# ln -s /etc/NetworkManager/dispatcher.d/30-nfs.sh /etc/NetworkManager/dispatcher.d/pre-down.d/30-nfs.sh

In order to make this script actually work, I had to modify the case statement for the pre-down event as follows:


Before that change, no script action was taken in response to the pre-down event. After the change, script responds to events appropriately. However, as I said, my laptop freezes whenever I try to connect to WiFi access points outside of the office.

I can't find anything in the logs that seems related to this. But I have enough experience with NFS to guess that this issue is exactly what happens when NFS mounts are not available. Furthermore, the problem only started after I started using the method described above. Previously, I was connecting manually via SSHFS and I did not have a freezing problem.

I also briefly tried the following method:

[solved] Long delay booting with a downed NFS share / Networking, Server, and Protection / Arch Linux Forums

However, that method looked really sketchy and dated, so I gave up on it quickly. Because this seems to be a common need, I expect there is a known, reliable solution. However, I can't seem to find one.

  • This would be an ideal situation to use the Automounter (autofs). – roaima Mar 26 '18 at 21:52
  • Here is the reason I didn't yet try autofs: unix.stackexchange.com/questions/415947/… The OP says, "I thought autofs would help me here but it causes me even more trouble." – MountainX Mar 27 '18 at 5:08
  • On and off, I've been using NFS and automount for probably close to 15 years on various laptops. Works well provided you remember not to try and mount a filesystem that can't be reached. Note that your reference is to CIFS and SSHFS, whereas you are using NFS. – roaima Mar 27 '18 at 6:34
  • What do you mean by "provided you remember not to try and mount a filesystem that can't be reached"? I thought automating the process would eliminate situations like that. (I don't even have to worry about that with my manual mount script because it checks if the server is available before mounting.) – MountainX Mar 30 '18 at 20:50
  • 1
    Just want to mention that I have the same issues. Laptop with nfs (and cifs) mounts on different networks, the system restarts from suspend only to hang after a while with 100% "phantom" load on all cpus (identified as "other" on the system monitor and no obvious fan noise). What is strange is that this question is the first time I see similar issues for somebody else. – fho Sep 3 '18 at 19:37

Your Answer

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

Browse other questions tagged or ask your own question.