Automount Home Directories Over NFS in RHEL7/CentOS7

Automount Home Directories Over NFS in Linux

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 are not going discuss about nfs configuration on server end. please refer the link Installing and Configuring the NFS Server on RHEL7/CentOS7

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

Incoming Keywords : Automount Home Directories Over NFS in Linux, Mounting NFS File Systems using autofs, autofs configuration, setting up autofs with nfs, how to configure autofs in rhel7, auto mounting an nfs share using autofs, autofs automount, linux automount nfs share

Related Something You missed?

Server 7104714692133825937