Watch all our Tutorials and Training Videos for Free on our Youtube Channel, Get Online Web Tools for Free on swebtools.com

Search Suggest

Automount Home Directories Over NFS in RHEL7 / CentOS7

automount in linux, automount configuration in linux, automount home directories linux, automount home directory ldap, automount home directories nfs

Automount Home Directories Over NFS in RHEL7

In this article, We will explain you about the Autofs service and helps you to Automount Home Directories Over NFS in Linux.

Mounting NFS File Systems using autofs

Autofs is a service offered us to automatically mount the filesystem when they need. It can also unmount the filesystem when not in use for a particular predefined timeout value.

But there is an alternate method to mount NFS is using fstab which is well known method. If you mount the filesystem using fstab, filesystem will be mounted automatically after the reboot. It doesn’t matter we use the filesystem or not.

If you mount the NFS filesystem using autofs, filesystem will be mounted when someone is accessing it and automatically unmount when not in use after the timeout value.

Best example for autofs is mounting the home directory shares over nfs for individual users  when they log into the server.

Main configuration file of autofs is /etc/auto.master. Each line specified in the master file defines a mount point and separate map file for each filesystems to be mounted.

Each entry in auto.master has three fields.

The first field is the mount point.
The second field is the location of the map file.
the third field can contain information such as a timeout value. It is optional.

Assume that our NFS server hostname is "nfsserver" and sharing the folder "/home" over NFS. we have already discussed about Installing and Configuring the NFS Server on RHEL7/CentOS7 and also How to Create a LDAP Users and Groups using LDIF file, so we will not discuss those topics here, please refer those links.

Make sure username, UID and GID of the users are same on the server and client end. If not create users on centralized LDAP server, please refer the link Configure OpenLDAP Server on RHEL7/CentOS7

Automount Home Directories Over NFS in RHEL7 / CentOS7

Now Login into the client and follow the below steps.

1. Verify the autofs is installed and running.
[root@nfsclient ~]# rpm -qa | grep -i autofs

If you didnt get any output for the above command, then autofs package is not installed. Install the autofs package using YUM to avoid dependencies, if YUM not configured, Please refer the link Configure YUM repo server on RHEL7
[root@nfsclient ~]# yum -y install autofs
[root@nfsclient ~]# rpm -qa | grep -i autofs
autofs-5.0.7-54.el7.x86_64
Yes, autofs is installed. Now go to the next step.

2. Append the master configuration file /etc/auto.master to specify the mount point and location of the map file.
/home  /etc/home.map

Where the /home directory acts as a home directory for all the NFS users on the client.

3. Create the map file home.map and add the below parameters.
* -fstype=nfs,rw,nosuid,soft  nfsserver:/home/&

4. Enable and Start the autofs service.
[root@nfsclient ~]# systemctl enable autofs
[root@nfsclient ~]# systemctl start autofs

5. Login in with some user and verify the home directory contents.

Thats all about Mounting NFS File Systems using autofs.

Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.