Newbie question : autofs is not working

General support questions
Post Reply
cozsmin
Posts: 5
Joined: 2020/02/05 15:44:40

Newbie question : autofs is not working

Post by cozsmin » 2023/05/24 13:19:30

Hello ladies and gents ,

I was following the tutorial from https://youtu.be/yS9C5k1Jc5Y , so my setup is : NFS server centos 7, NFS client centos 7.
Both have firewall disabled between them , also enforcing is permissive on both .
NFS server IP : 192.168.122.1
NFS client IP : 192.168.122.10

Mounting manually works without a problem .

Trying with autofs is another thing ..

Here is the config on NFS client :

/etc/auto.master contents :

Code: Select all

+dir:/etc/auto.master.d
+auto.master
/etc/auto.master.d/home.autofs contents :

Code: Select all

/home	/etc/autofs.home
/etc/autofs.home contents :

Code: Select all

*	-rw	192.168.122.1:/home/&
After i restart the autofs dameon , the "/home" directory is empty

But it looks mounted :

Code: Select all

[root@nfs-client etc]# df -h /home
Filesystem        Size  Used Avail Use% Mounted on
/etc/autofs.home     0     0     0    - /home
Daemon does look up and fine :

service autofs status

Code: Select all

[root@nfs-client etc]# service autofs status 
Redirecting to /bin/systemctl status autofs.service
● autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-05-24 15:50:58 EEST; 17min ago
 Main PID: 2624 (automount)
   CGroup: /system.slice/autofs.service
           └─2624 /usr/sbin/automount --systemd-service --dont-check-daemon

May 24 15:50:58 nfs-client systemd[1]: Starting Automounts filesystems on demand...
May 24 15:50:58 nfs-client systemd[1]: Started Automounts filesystems on demand.
So i tried to run the autofs manually with "/usr/sbin/automount -dvf" to get more logs out of it :

Code: Select all

[root@nfs-client etc]# service autofs stop
Redirecting to /bin/systemctl stop autofs.service
[root@nfs-client etc]# 
[root@nfs-client etc]# /usr/sbin/automount -dvf 
Starting automounter version 5.0.7-116.el7_9.1, master map auto.master
using kernel protocol version 5.02
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
include_file: lookup(dir): include: /etc/auto.master.d/home.autofs
lookup_nss_read_master: reading master file /etc/auto.master.d/home.autofs
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /home
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_nss_read_master: reading master nisplus auto.master
lookup_nss_read_master: no map - continuing to next source
lookup_nss_read_master: reading master sss auto.master
lookup_nss_read_master: no map - continuing to next source
master_do_mount: mounting /home
automount_path_to_fifo: fifo name /run/autofs.fifo-home
lookup_nss_read_map: reading map file /etc/autofs.home
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
mounted indirect on /home with timeout 300, freq 75 seconds
st_ready: st_ready(): state = 0 path /home
Someone may help me here ? i am totally lost .....

tunk
Posts: 1215
Joined: 2017/02/22 15:08:17

Re: Newbie question : autofs is not working

Post by tunk » 2023/05/24 17:55:28

With NFS mounts I usually put them in /etc/fstab.
And IIRC with the "soft,bg" options.

User avatar
TrevorH
Site Admin
Posts: 33277
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Newbie question : autofs is not working

Post by TrevorH » 2023/05/24 18:11:21

Autofs doesn't mount stuff until it is referenced unless you include the 'ghost' parameter. Try ls -la /home/somevaliduser/
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

cozsmin
Posts: 5
Joined: 2020/02/05 15:44:40

Re: Newbie question : autofs is not working

Post by cozsmin » 2023/05/24 18:46:47

Hi TrevorH ,

You are THE MAN

User avatar
TrevorH
Site Admin
Posts: 33277
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Newbie question : autofs is not working

Post by TrevorH » 2023/05/25 00:14:23

Also, tunk
With NFS mounts I usually put them in /etc/fstab.
That has the drawback that if the server is offline or inaccessible you can end up with hung mounts that don't respond and sometimes never recover. If you use autofs then you can do things like add a timeout to the connection so that after, say, 10 minutes of inactivity, it umounts it for you. That way the connection isn't there to hang if the server goes away. And of course, next time it's referenced, it gets mounted again. so auitofs has an overhead and slight delay in that it has to make a new connection and mount it when it's referenced, set against the advantage of being less prone to error.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4552
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Newbie question : autofs is not working

Post by jlehtone » 2023/05/25 14:52:24

Adding noauto,nofail,x-systemd.automount,x-systemd.idle-timeout=300 to options of /etc/fstab
entry makes systemd generate an automount unit on boot. That is an alternative to autofs.


The map in OP post does use wildcard (* &). That is kind of convenient -- one rule for many mounts.
One could just direct mount the '/home', although that is not quite the same.

The entries in /etc/auto.master.d/*.autofs can have options. E.g. browse or nobrowse
to control the ghosting.

Post Reply