Automount HOME directories on NFS server
This post is aimed to help administrators to keep Linux home directories in a centralized location and mounting them when needed by using the Automounter. NOTE: Each user should have unique uid/gid
NFS Server: Any NFS Server will do just fine. I will use NetApp NFS since this is for a production environment. filer.example.com
RHEL Client: RHEL 5.3 64bit rhelbox.example.com
Users: john uid=2100 gid=2100 alex uid=2101 gid=2101
NetApp NFS Server Setup: 1) Create a volume to host your home directories
filer> vol create homedirs aggr1 200g
- Enter the following in your /etc/exports file to export this to the specific RHEL client.
filer> exportfs -p rw=rhelbox.example.com,root=rhelbox.example.com /vol/homedirs filer> exportfs -a
RHEL Client Configuration:
- As root mount the volume anywhere in the system. (This is only to create the home directories and assign the proper ownership, then unmount.) [root@rhelbox ~]# mkdir /mnt/homedirs [root@rhelbox ~]# mount ny1afilerd1:/vol/homedirs /mnt/homedirs/ [root@rhelbox ~]# mount … filer:/vol/homedirs on /mnt/homedirs type nfs (rw,addr=rhelbox.example.com)
- Create the home directories and assign proper ownership [root@rhelbox ~]# mkdir /mnt/homedirs/{john,alex}
[root@rhelbox ~]# id john uid=2100(john) gid=2100 groups=2100 [root@rhelbox ~]# chown 2100:2100 /mnt/homedirs/john/
[root@rhelbox ~]# id alex uid=2101(alex) gid=2101 groups=2101 [root@rhelbox~]# chown 2101:2101 /mnt/homedirs/alex/
- Copy the files from /etc/skel to the new home directory [root@rhelbox ~]# for i in john alex; do cp /etc/skel/.* /mnt/homedirs/$i/; done
- Unmount the temporary folder [root@rhelbox~]# umount /mnt/homedirs [root@rhelbox~]# rmdir /mnt/homedirs
- Configure the Automounter Enter the following in /etc/auto.master /home /etc/auto.home –timeout=60
Create /etc/auto.home and populate as follows: * -fstype=nfs,rw,nosuid,soft filer.example.com:/vol/homedirs/&
- Restart the automounter [root@rhelbox ~]# service autofs restart
- That should be it, lets give it a try [root@rhelbox ~]# su - john [john@rhelbox ~]$ ls -A .bash_history .bash_logout .bash_profile .bashrc