Automount HOME directories on NFS server

1 minute read

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

  1. 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:

  1. 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)
  1. 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/

  1. 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
  1. Unmount the temporary folder [root@rhelbox~]# umount /mnt/homedirs [root@rhelbox~]# rmdir /mnt/homedirs
  1. 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/&

  1. Restart the automounter [root@rhelbox ~]# service autofs restart
  1. That should be it, lets give it a try [root@rhelbox ~]# su - john [john@rhelbox ~]$ ls -A .bash_history .bash_logout .bash_profile .bashrc