NIS created users without a home directory

Hi all,

So I have created two Centos machines. One is configured as a NIS master and the second is a NIS cleint. The NIS configs are all working perfectly.

I created a user nisuser on NIS Master and I can use it on the client. BUT it doesnt show a home directory . Ive been told there is something else like automount of autfs that I need to configure that will automount the home directory onto any client. I havent done any such configs.

Can you guys guide me as to what exactly I need to study or redirect me to a good tutorial ?

Regards

You're confounding NIS with NFS. The former allows hosts to share information services such as the user database and hostnames. The latter allows home directories to be shared (for instance).

The NIS Master and NFS master do not have to be the same host, but it's not unsual to make it so. On the NFS Master, you install the nfs tools and start the nfs service. You modify /etc/exports (man 5 exports) to tell NFS to export some path, ie /home:

/home  *(rw,no_root_squash)

On the other host, you modify /etc/fstab

... (previous fstab entries)
master:/home  /home    nfs  rw

Where "master" is the hostname of your NFS master. Then run mount:

# mount -a -t nfs

Let's say you have a user Joe, who is listed in the NIS user database and has a home directory on host "master" as /home/joe. When you login on the "client" host as user Joe, the home directory should be available. If the login process hangs or you get the error "No such directory" then something went wrong.

1 Like

I agree yo what you have said. But this is nfs. I am more interested in using automount/autofs. Can you guide me in that regard ?

So autofs builds on NFS in the way that each directory will be mounted "on demand" and unmounted after a few minutes of inactivity. It is largely a pointless technology, but it still has its uses. The server set up is essentially the same. For the client setup, don't use the fstab entry, but rather, configure autofs and enable the autofs daemon with chkconfig.

I haven't done this in a while, but the following might work:
/etc/auto.master

/home /etc/auto.home --timeout 600

To /etc/auto.home:

* -fstype=nfs master:/home/&

Then restart autofs

---------- Post updated at 10:46 PM ---------- Previous update was at 10:44 PM ----------

Here's a concise set of examples.
http://www.linux-consulting.com/Amd_AutoFS/autofs-5.html

Here is my client side configuration:

[root@Barium home]#
[root@Barium home]# cat /etc/auto.master
/home /etc/auto.home --timeout 600
[root@Barium home]# cat /etc/auto.home
* -fstype=nfs 192.168.1.10:/home/&
[root@Barium home]# ypwhich
Titanium
[root@Barium home]# cat /etc/hosts | grep Titanium
192.168.1.10 Titanium
[root@Barium home]# ypcat passwd
nisuser:$6$LZhXWN9NSvbnUZcu$Iryf0Xiez0GNBQAMzdUNpdA/.1kJIYiO.DnivPiUMPcV09J6jUBdqFDom51J5Ieo2w1h63SkhcNAK5TC6IxUu/:500:100::/home/nisuser:/bin/bash
[root@Barium home]#
[root@Barium home]#
[root@Barium home]# su - nisuser
su: warning: cannot change directory to /home/nisuser: No such file or directory
-bash-4.1$

Seems like it isnt working.

There is a caveat to working with autofs: The top-level directory must not exist before autofs is started. Try this (on the client): NOTE: THIS WILL DESTROY EVERYTHING IN /HOME ON THE CLIENT

service autofs stop
rm -rf /home
service autofs start

Then su - nisuser

It just went crazy :confused:

[root@Barium home]# service autofs stop
Stopping automount:                                        [  OK  ]
[root@Barium home]# rm -rf /home
[root@Barium home]# service autofs start
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Starting automount:                                        [  OK  ]
[root@Barium home]# su - nisuser
su: warning: cannot change directory to /home/nisuser: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
-bash-4.1$

OK, the problem is ... you were still in /home when you removed it.

  1. Log out from all other users.
  2. As root, change dir to /root or /
  3. Run lsof /home. If there are processes listed, kill them. (bash must be killed with -1)
  4. Now restart autofs

Try again.

Well I did it. But the issue still persists.

[root@Barium ~]# cd /
[root@Barium /]# lsof /home/
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
automount 26901 root   10r   DIR   0,18        0 42788 /home
[root@Barium /]# kill -9 26901
[root@Barium /]# service automount status
automount: unrecognized service
[root@Barium /]# service autofs status
automount dead but subsys locked
[root@Barium /]# service autofs stop
Stopping automount:                                        [  OK  ]
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]# service autofs start
Starting automount:                                        [  OK  ]
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]# lsof /home/
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
automount 27161 root   10r   DIR   0,18        0 44781 /home
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]#
[root@Barium /]# su - nisuser
su: warning: cannot change directory to /home/nisuser: No such file or directory

Do you know for sure that you can mount /home/nisuser on this host?

Try (as root):

mkdir /mnt/nisuser
chmod 755 /mnt/nisuser
mount titanium:/home/nisuser /mnt/nisuser
ls -l /mnt/nisuser

If it doesn't mount, there's a problem with the server side (check the exports file? Run exportfs -a ? Is NFS service running?)

If it does mount, the problem is apparently with autofs itself.