NFS and autofs problem

I have problem with mounting NFS share with autofs.
I have:

[FONT=monospace]**/etc #**cat auto.master   
# 
# Sample auto.master file 
# This is a 'master' automounter map and it has the following format: 
# mount-point [map-type[,format]:]map [options] 
# For details of the format look at auto.master(5). 
# 
#/misc  /etc/auto.misc 
# 
# NOTE: mounts done from a hosts map will be mounted with the 
#       "nosuid" and "nodev" options unless the "suid" and "dev" 
#       options are explicitly given. 
# 
#/net   -hosts 
# 
# Include /etc/auto.master.d/*.autofs 
# To add an extra map using this mechanism you will need to add 
# two configuration items - one /etc/auto.master.d/extra.autofs file 
# (using the same line format as the auto.master file) 
# and a separate mount map (e.g. /etc/auto.extra or an auto.extra NIS map) 
# that is referred to by the extra.autofs file. 
# 
#+dir:/etc/auto.master.d 
# 
# If you have fedfs set up and the related binaries, either 
# built as part of autofs or installed from another package, 
# uncomment this line to use the fedfs program map to access 
# your fedfs mounts. 
#/nfs4  /usr/sbin/fedfs-map-nfs4 nobind 
# 
# Include central master map if it can be found using 
# nsswitch sources. 
# 
# Note that if there are entries for /net or /misc (as 
# above) in the included master map any keys that are the 
# same will not be seen as the first read key seen takes 
# precedence. 
# 
+auto.master 

/mnt/serwer /etc/auto.misc
[/FONT]
**/etc #** cat auto.misc  
# 
# This is an automounter map and it has the following format 
# key  -mount-options-separated-by-comma ] location 
# Details may be found in the autofs(5) manpage 

#cd             -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom 

# the following entries are samples to pique your imagination 
#linux          -ro,soft,intr           ftp.example.org:/pub/linux 
#boot           -fstype=ext2            :/dev/hda1 
#floppy         -fstype=auto            :/dev/fd0 
#floppy         -fstype=ext2            :/dev/fd0 
#e2floppy       -fstype=ext2            :/dev/fd0 
#jaz            -fstype=ext2            :/dev/sdc1 
#removable      -fstype=ext2            :/dev/hdd 

publiczny        -fstype=nfs4            192.168.1.2:/srv/net/dysk1/publiczny


systemctl status autofs  
**●** autofs.service - Automounts filesystems on demand 
     Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; vendor preset: disabled) 
     Active: **active (running)** since Thu 2020-10-15 20:38:58 CEST; 6s ago 
   Main PID: 4148 (automount) 
      Tasks: 4 (limit: 4915) 
     Memory: 3.0M 
     CGroup: /system.slice/autofs.service 
             └─4148 /usr/sbin/automount --systemd-service --dont-check-daemon 

paź 15 20:38:58 komp2 systemd[1]: Starting Automounts filesystems on demand... 
paź 15 20:38:58 komp2 systemd[1]: Started Automounts filesystems on demand. 
paź 15 20:39:05 komp2 automount[4148]: key "-" not found in map source(s).

I have nothing in:

**etc #** ls /mnt/serwer/ 
**/etc #**

When I make directory “publiczny” in Krusader i get connection.

**/mnt/serwer #** ls 
**publiczny**

mkdir - not working:

**mnt/serwer #** mkdir publiczny 
mkdir: nie można utworzyć katalogu „publiczny”: Brak dostępu
[FONT=monospace]**/etc #** ls /mnt/serwer/ 
**/etc #**
[/FONT]

Have You any idea what is wrong?

While I agree that the automounter should work, I use the systemd.automounter. The only thing to configure is an /etc/fstab entry similar to

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

I assume you can create your own based on this example.

Maybe a additional option of nfsvers=… is needed for your situation.

The _netdev option is not needed (systemd assumes this for nfs already), but it does not hurt either.

It is working here.


% tail -4 /etc/auto.master
# precedence.
#
/nfsmounts      /etc/auto.nfs
+auto.master

and


% cat /etc/auto.nfs
shared  -fstype=nfs homebase:/shared

I have nothing in:

**etc #** ls /mnt/serwer/ 
**/etc #**

Trying the equivalent here:


% ls /nfsmounts

% ls /nfsmounts/shared
acronis  D         iso      lost+found  nwr        stuff    unix-dar
Calibre  excludes  libvirt  Music       repostuff  torrent  ycr

As you can see, it doesn’t actually mount until I attempt to access an explicit path. I think there’s an option to change that behavior.

Nothing is wrong. That is exactly how indirect automount map is supposed to work. See description of “browse” option in “man auto.master”.

P.S. this is English forum. Please post English command output here.

Please stop recommending systemd every time you see word “automount”. Systemd automount unit is no replacement for automountd, it does not have notion of indirect maps (which is exactly what we are talking about here), it was created for the very limited use case and never was designed as full fledged automountd replacement.

It’s strange, because I have laptop with TUMBLEWEED and autofs working without problems.
I have identical (I think) configuration on laptop and computer. On laptop autofs is working, on computer not.
etc/fstab or Yast config isn’t good for me, because my server isn’t always accessible. When sever is not accessible, computer hang off for minute or when booting waiting 1,5min for each NFS share.

/mnt> ls serwer/publiczny 
ls: nie ma dostępu do 'serwer/publiczny': Nie ma takiego pliku ani katalogu
ls: can't access 'server / public': No such file or directory

On laptop I have:

systemctl status autofs
● autofs.service - Automounts filesystems on demand
     Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; vendor preset: disabled)
     Active: active (running) since Fri 2020-10-16 08:19:02 CEST; 5s ago
   Main PID: 3517 (automount)
      Tasks: 4 (limit: 4915)
     Memory: 52.5M
     CGroup: /system.slice/autofs.service
             └─3517 /usr/sbin/automount --systemd-service --dont-check-daemon

paź 16 08:19:02 LaptopRYZEN systemd[1]: Starting Automounts filesystems on demand...
paź 16 08:19:02 LaptopRYZEN automount[3517]: mount_autofs_indirect: failed to read map for /nfs4
paź 16 08:19:02 LaptopRYZEN automount[3517]: handle_mounts: mount of /nfs4 failed!
paź 16 08:19:02 LaptopRYZEN automount[3517]: master_do_mount: failed to startup mount
paź 16 08:19:02 LaptopRYZEN systemd[1]: Started Automounts filesystems on demand.

On computer:

**#** systemctl status autofs  
**●** autofs.service - Automounts filesystems on demand 
     Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; vendor preset: disabled) 
     Active: **active (running)** since Fri 2020-10-16 08:05:34 CEST; 21min ago 
   Main PID: 1654 (automount) 
      Tasks: 3 (limit: 4915) 
     Memory: 3.8M 
     CGroup: /system.slice/autofs.service 
             └─1654 /usr/sbin/automount --systemd-service --dont-check-daemon 

paź 16 08:05:34 komp2 systemd[1]: Starting Automounts filesystems on demand... 
paź 16 08:05:34 komp2 automount[1654]: syntax error in map near  mnt ] 
paź 16 08:05:34 komp2 systemd[1]: Started Automounts filesystems on demand. 

Maybe this is problem: ***syntax error in map near mnt ] ***?
Have You any suggestions or hints?

+1 to the comments mad by nrickert. That’s how automounting works ie the first user to issue a command that accesses a directory or file relating to /mnt/serwer/publiczny will cause it to be mounted (on demand).

I know, but it works on laptop but not on computer.
“ls” command is strong enough to mount on demand, but on computer not working, see my previous post.

PS.
It was simple.
I missed “/” in

/mnt/serwer /etc/auto.misc

So I had

mnt/serwer /etc/auto.misc

My fault.

Yes, I just saw your subsequent reply with more information. :wink:

That explains the “syntax error in map near mnt ]” error, and not apparent from what you shared in your opening post. Anyway, all good.

Thanks for your help.