Centos 7 autofs mount doesn't work right after reboot
Solution 1:
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
Solution 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