NFS automount not working after sleep

I just did a clean install of Leap 15.5
I have 2 NFS mounts that after sleep do not connect automatically, and I need to reconnect them manually with mount -a every single time.

This is the mounts on my fstab

192.168.1.29:/home/server/External-Disk /home/cepiolidus/External nfs defaults 0 0
192.168.1.29:/home/server/Storage /home/cepiolidus/Storage nfs defaults 0 0

I assume they should not “automount” (what ever you mean with that), but they should still be mounted after sleep. When they aren’t, for whatever reason, there is no automount configured, thus no wonder root must then do it by command.

While I can not say why they become unmounted, I can offer you a simple way to automount them. And that will work as soon as they are needed. Earlier this was configured using /etc/auto.master (and that still functions), but nowadays one can use systemd-automount configured in `/etc/fstab.

I will give you an example configuration:

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

I guess you can adapt to your use.

Are you using wicked or NetworkManager?

I will try this and report.
Thank you

Network Manager

Show

systemctl is-enabled nfs-client.target

returns disabled

That is not how you post results of command execution. You do not describe - you copy and paste here the full command and its complete output.

Anyway, that is the reason your filesytems are unmounted. There is /usr/lib/NetworkManager/dispatcher.d/nfs script that unconditionally unmounts when interfaces go down, but only mounts back when nfs-client.target is enabled.

I suppose, the simplest fix would be to enable this unit.

My apologies.
can you guide me on how to enable it?

systemctl enable nfs-client.target

Thank you.
this fixed the issue!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.