Best Method to Automount NFS on Wi-Fi Client

I have a laptop (OpenSUSE Tumbleweed) connected to the LAN via WI-FI. Elsewhere on this LAN is an Ubuntu Server sharing directories via NFS. What is the best way for my client to reliably automount the NFS shares after reboot/resume?

On my clients that are connected via Ethernet, I just use the NFS Client tool in YaST which configures /etc/fstab. This is rock solid and works great. However, for Wi-Fi clients, the wireless connection is established after /etc/fstab tries to mount the drives, so it never works. After some research here and here, I determined that I should use /etc/auto.master instead. This will mount drives on demand, thus avoiding any premature attempts before Wi-Fi is up and running. This worked great for a while, but lately, for reasons unknown, it doesn’t function after reboots. I have to run “systemctl restart autofs” every time I reboot if I want my mounts to work again.

Again, doing research, I found this thread from 2018 which suggests the preferred setup is to do a systemd automount. How should I properly set up this Wi-Fi client so it reliably automounts my shared drives? If /etc/auto.master is the way to go, then how do I get it to work without needing to restart autofs every time?

I looks as if Automount (no, not what many people mean with this term, but the original meaning of Automount in Unix) could help you.
That is, it mounts when needed (some process needing a file from the NAS).

I use the systemd version of it. Example:

boven.henm.xs4all.nl:/home/wij             /home/wij  nfs   noauto,nofail,x-systemd.automount,x-systemd.mount-timeout=10,x-systemd.idle-timeout=5min          0  0

The extra options are:

  • noauto because we refrain from mounting at boot;
  • nofail as an extra, may not be needed;
  • x-systemd.automount to let systemd-automount do it’s work: mount when required;
  • x-systemd.mount-timeout=10 time before it errors because of e.g. NFS server down;;
  • x-systemd.idle-timeout=5min after 5 minutes of no usage the fs will be unmounted (to be mounted auto at next access)

See also:

man systemd.automount
man systemd.mount

That is not quite correct. This is true if you are using NetworkManager with user connections. It is not true if you are using other network management (like wicked) or you are using NetworkManager with system connections. KDE Plasma applet defaults to user connections for wireless (I believe, it is the only frontend which does it) but it can be changed in connection properties.

systemd automount is based in the same kernel autofs, it provides less features than automountd, but for the simple cases it is probably OK. What is best for you is really up to you.

You need to find out why it is not started on boot. If you provide output of

journalctl -b --no-pager --full

someone may look at it. Low hanging fruits - is autofs service enabled at all?

Quoting manual page

Note that if x-systemd.automount (see above) is used, neither auto nor noauto have any effect.

nofail will likely be ignored for the same reason.

Actually you do want to mount on boot - as autofs. Otherwise there is little reason in setting up automount in the first place.

Ok, then leave it out. Nothing will be changed.

I checked YaST > Services and saw ‘autofs’ start mode was set to manual. I changed that to On Boot and it works as it should now. The drives mount after reboot. Thank you for the suggestion and I’m glad this one was easy.

Since hcvv suggested systemd Automount, should I be using that instead? Is there any advantage over what I’m doing now? Or should I just stick with what I have since it’s working?

When it works and when you understand your configuration and thus are used to it, leave it as it is. They are just two alternatives and I assume that good old automounter will function for the forseeable future.

Way too much hassle with automount!

Use a systemd service instead. A Seagate model ST8000VN004-2M2101 is added to /etc/fstab:

erlangen:~ # grep /HDD /etc/fstab 
UUID=2260f160-cc05-47cc-9893-cc32c050177d  /HDD                    btrfs  user,noauto                   0  0
erlangen:~ # 

Option noauto inhibits automatic mounting of the drive on boot. For some reasons the drive is deleted from the bus and scanned for on some occasions, such as backup.

Sometimes auto-mounting is desirable. The following systemd service performs this task when enabled:

erlangen:~ # systemctl cat HDD.automount 
# /etc/systemd/system/HDD.automount
[Automount] 
Where=/HDD
TimeoutIdleSec=1min

[Install]
RequiredBy=local-fs.target
erlangen:~ # 

Two sections with three declarations accomplish the task.

erlangen:~ # systemctl status HDD.automount 
● HDD.automount
    Loaded: loaded (/etc/systemd/system/HDD.automount; enabled; preset: disabled)
    Active: active (running) since Fri 2023-05-26 06:54:14 CEST; 33s ago
  Triggers: ● HDD.mount
     Where: /HDD

May 26 06:54:14 erlangen systemd[1]: Set up automount HDD.automount.
May 26 06:54:34 erlangen systemd[1]: HDD.automount: Got automount request for /HDD, triggered by 22251 (ls)
erlangen:~ # 
erlangen:~ # systemctl status autofs
○ autofs.service - Automounts filesystems on demand
     Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; preset: disabled)
     Active: inactive (dead)
erlangen:~ #