5

I've setup autofs on Centos 7. However, it seems like after reboot, it took some time to mount /home/ directory, even when I 'cd' into it. It only succeeds after 3 tries:

[root@localhost ~] cd /home/<user>
-bash: cd: /home/<user>: No such file or directory

and, autofs is enabled, so I expect it to start after reboot:

[root@localhost etc]# systemctl status autofs
autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled)
   Active: active (running) since Tue 2015-07-21 10:34:38 HKT; 1h 13min ago
  Process: 1379 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
 Main PID: 1385 (automount)
   CGroup: /system.slice/autofs.service
           └─1385 /usr/sbin/automount --pid-file /run/autofs.pid

Jul 21 10:34:38 localhost.localdomain systemd[1]: Starting Automounts filesystems on demand...
Jul 21 10:34:38 localhost.localdomain automount[1385]: setautomntent: lookup(sss): setautomntent: No such file or directory
Jul 21 10:34:38 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.

Here is /etc/auto.master:

/misc /etc/auto.misc
/net  -hosts
+dir:/etc/auto.master.d
/home /etc/auto.home
/san /etc/auto.san
+auto.master

/etc/auto.master:

* -fstype=nfs,rw 192.254.100.4:/home_external/user_home_local/&

/etc/auto.san:

mysql_db 192.254.100.4:/san_external/mysqldb

I suspect for similar reasons, when mysql starts after reboot, it has an error saying it can't 'cd' into /san/mysql_db/. But a manual restart on mysql after the machine is booted up works. Any ideas? thanks vm

8

I experienced something similar.

That is, logins of users with automounted home directories hung right after reboot, until such time as I manually started rpcbind with "systemctl start rpcbind". This is with all the most recent Cent7 updates as of today.

I found that modifying the autofs unit file to depend on rpcbind and some other services fixed my problem. See the "Requires=network.target rpc-statd.service rpcbind.service" line in the "After" code block below...

Before: /usr/lib/systemd/system/autofs.service

[Unit]
Description=Automounts filesystems on demand
After=network.target ypbind.service sssd.service

[Service]
Type=forking
PIDFile=/run/autofs.pid
EnvironmentFile=-/etc/sysconfig/autofs
ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid
ExecReload=/usr/bin/kill -HUP $MAINPID
TimeoutSec=180

[Install]
WantedBy=multi-user.target

After: /usr/lib/systemd/system/autofs.service

[Unit]
Description=Automounts filesystems on demand
Requires=network.target rpc-statd.service rpcbind.service
After=network.target ypbind.service sssd.service

[Service]
Type=forking
PIDFile=/run/autofs.pid
EnvironmentFile=-/etc/sysconfig/autofs
ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid
ExecReload=/usr/bin/kill -HUP $MAINPID
TimeoutSec=180

[Install]
WantedBy=multi-user.target

Hat tip: https://www.centos.org/forums/viewtopic.php?f=47&t=51789

2

This is the root cause of the problem:

  • systemd starts sssd first
  • sssd is configured as a forking process in sssd. sssd doesn't signal systemd when it's fully loaded. After startup systemd considers sssd as loaded and continues the startup process.
  • In some cases it can take a while before sssd is loaded and starts answering autofs/passwd/... nss queries. I have seen systems where it takes up to 5 seconds.
  • if autofs starts before sssd is loaded the autofs map is not available.

There are several ways to fix this:

  • the clean solution is that sssd implements systemd signaling so it can notify systemd when it's fully loaded
  • try to speed up sssd loading. Check your sssd configuration to check if there is a reason why it loads so slow.
  • the hacky solution is to artifically add sufficient delay before autofs starts. (This is how the previous answer works. It just adds another service before autofs so sssd receives some more time.) This is not sufficient in some cases. Another solution is suggested in bug https://bugzilla.redhat.com/show_bug.cgi?id=1189767. Add

    ExecStartPre=/bin/sleep 10
    

    to your sssd.unit

  • pagure.io/SSSD/sssd/c/… should supposedly solve this. but running centos 7.5 with sssd-1.16.0-19.el7_5.8 and autofs-5.0.7-83.el7 autofs still tries to read mount maps from sss before it is ready – azzid Oct 16 '18 at 9:03

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.