Nis and autofs manual restart after a reboot

autofsnis

I have a minor inconvenience involving NIS and autofs. I pull my home directory from an NFS server. It all works fine, except that I have to manually restart nis and autofs after each reboot. So after the system starts up, I need to switch to a console (or ssh into the machine) and do

sudo service nis restart
sudo service autofs restart

After this, everything works like a charm, with no problems.

If I don't do that, I can't get past the login screen. To give an example, I have two users on the system, call them localuser (password and home directory on the machine) and remoteuser (password on the remote machine, home directory on NFS).
Now, after a fresh reboot, I can log in as localuser with no problems. If I try to login as remoteuser, my password is accepted but no home directory is found, so if I try to log in using GNOME, I get an instant logout. I can still log in as remoteuser remotely or after switching to a text terminal (ctrl+alt+f1), but no home directory is found. After restarting NIS and autofs as mentioned above, I can log in as remoteuser with no further problems until a reboot.

So my question is: how do I avoid manually restarting these services after each reboot?

I have been using this computer as a standalone machine, and then moved it to a network, so I imagine some network settings were configured before I installed autofs.
I am using Ubuntu 12.04, but I had a similar problem on a different machine running older versions of Ubuntu.

Best Answer

I had this problem in 14.04.

If your distribution uses Upstart for starting processes, go to /etc/init/autofs.conf and change the line that says

start on runlevel [2345]

to

start on (local-filesystems and net-device-up IFACE!=lo)

This will make Upstart wait with launching autofs until filesystem and networking is available.

Now, I don't use nis, but I assume this is your main problem. It was for many people. Sorry for reviving this old post. Just thought this information needed to be here

Related Question