AutoFS won't mount an NFS share

I have this NFS share.

# showmount -e 192.168.8.10
Export list for 192.168.8.10:
/mnt/main/data             192.168.7.3

I’m trying to auto mount this share on Fedora 42, and when I start the autofs SystemD service, it just won’t mount anything.

These are the auto configuration files I have:

# /etc/auto.master
+dir:/etc/auto.master.d
/-  /etc/auto.data  --timeout=600
+auto.master
# /etc/auto.data
/home/user/data -fstype=nfs,rw,soft,nconnect=4,rsize=8192,wsize=8192,actimeo=1800 192.168.8.10:/mnt/main/data

I can access the share by mounting it manually.

# mount -t nfs -o rw,soft,nconnect=4,rsize=8192,wsize=8192,actimeo=1800 192.168.8.10:/mnt/main/data /home/user/data/

# df -h /home/user/data
Filesystem                    Size  Used Avail Use% Mounted on
192.168.8.10:/mnt/main/data  5,1T  217G  4,9T   5% /home/user/data

I can also manually start the automount program, which actually works.

# sudo automount -vf
Starting automounter version 5.1.9-9.fc42, master map auto.master
using kernel protocol version 5.06
reading files master auto.master
reading dir master /etc/auto.master.d
reading files master auto.master
mounted direct on /home/user/data with timeout 600, freq 150 seconds
attempting to mount entry /home/user/data
mounted /home/user/data

However, when I start the autofs.service, it still won’t mount the share.
I could not find any error messages for this service.

$ sudo systemctl status autofs
● autofs.service - Automounts filesystems on demand
     Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Mon 2025-06-23 21:15:33 -03; 2s ago
 Invocation: 959645c3e8a647b0b9d71c93221b0161
   Main PID: 4476 (automount)
      Tasks: 4 (limit: 38162)
     Memory: 1.1M (peak: 1.8M)
        CPU: 3ms
     CGroup: /system.slice/autofs.service
             └─4476 /usr/bin/automount --systemd-service --dont-check-daemon

jun 23 21:15:33 pc systemd[1]: Starting autofs.service - Automounts filesystems on demand...
jun 23 21:15:33 pc (utomount)[4476]: autofs.service: Referenced but unset environment variable evaluates to an empty string: OPTIONS
jun 23 21:15:33 pc systemd[1]: Started autofs.service - Automounts filesystems on demand.

Any thoughts about this?

Would you like it to auto-mount at boot time or only after you try to use the NFS share?

Only when needed.

I ended up resorting to SystemD automount. It was actually simpler.

I added the following entry to FSTab with the x-systemd.automount option.

192.168.8.10:/mnt/main/data /home/user/data nfs rw,soft,nconnect=4,rsize=8192,wsize=8192,actimeo=1800,x-systemd.automount 0 0

Then, I reload SystemD (systemctl daemon-reload).

With this, two units were created automatically: home-user-data.mount and home-user-data.automount.

I guess the resulting effect should be similar to AutoFS.

Nevertheless, I would appreciate hearing any thoughts on the odd AutoFS behavior.

I use the same, but there is one annoying thing:
When the external system is not available (off, unplugged or whatever) your computer takes a very long time when booting. It tries to make connection for a certain time, could well be 30 secs, and when that has failed it will continue.
This doesn’t affect you of course when the external system is always on, like mine, but I thought I mention it.

1 Like

A few extra helpful options I often use:

  • _netdev is a shortcut that includes multiple target units, telling systemd to wait until the network is up before attempting to mount.
  • x-systemd.device-timeout=5 reduces the timeout to 5 seconds.
  • nofail covers the extreme case where the NFS server isn’t available for a while.
  • x-systemd.idle-timeout=3600 tries to unmount the share if it’s been idle for 3,600 seconds.

(The time value defaults to seconds if there’s no unit specified – e.g. “3600”, “3600s”, “60min” and “1h” are all valid equivalents.)

1 Like

Awesome tip!

I’ve updated my FSTab entry with these options.

192.168.8.10:/mnt/main/data /home/user/data nfs rw,soft,nconnect=4,rsize=8192,wsize=8192,actimeo=1800,x-systemd.automount,x-systemd.device-timeout=5,x-systemd.idle-timeout=600,_netdev,nofail 0 0

Thanks.


BTW, these were my main references:

When you automount with systemd, you don’t have to add the mount to fstab. Only creating the mount and automount files in the systemd directory would suffice.

1 Like

But then, I would have to manually add those unit files.

Since the FSTab options create the unit files automatically, I found it easier to add them.