How to configure (autofs) auto mount nfs in Linux

Configure Auto mount NFS directory in Linux

  • All the resources of the server is valuable and needs to be available for usage, when we mount a NFS directory over client the network resource gets busy , even when the work is finished the network resource will still be busy as mounting occupy it.
  • Autofs automatically mounts file systems for you when they are requested. This has a very handy feature: it’s great for handling removable media. Just CD to the right directory, or execute Is or do anything that sends a request to the mount point: and the daemon mounts it. After all, it’s the kind of job that’s beneath the dignity of a human being First; you need to install the “autofs” package. It should include some appropriate config files.

The files you need is /etc/auro. Master

Read also : How to Configure NFS server

Steps to configure auto mount at client side

Step1: Log into client side and check whether autofs is install or not, if not install autofs

  • Check whether autofs install or not

#rpm-q autofs


If it is not installed, install it by using yum or rpm

            #yum install autofs* -y

Step2: Edit the /etc/auto. master as follows

      #yum /etc/auto.master

mount nfs

Step3: Create /etc/auto.ktnfs file and /ktnfs directory if not created earlier

     #vim /etc/auto.ktnfs

mount nfs 


Stop and start the autofs service 

  • #service autofs stop
  • #service autofs start
  • #chkconfig autofs on


Step5: log into the given directory in etc/auto.master i.e. /ktnfs and check that if NFS is mounted by mount command


Note: Still NFS will not be mounted

Step6: Change the directory to the name given in /etc/auto.ktnfs i.e. ktnfs and then auto mounting will be done.

#cd ktnfs



How to remove mount nfs & NFS server

Step1: Remove all autofs details from all config file like /etc/auto. ,aster and/etc/auto.ktnfs

Step2: un-export all the directory which was exported earlier using following command



Note:- if you don’t have DNS and you don’t want use IP but want to use hostname instead, update hostname with its ip in /etc/hosts file and then you can use hostname instead of IP

                              Okay now finally we’ve done with all NFS activities.                                                                                                                                  



Leave a Reply

Your email address will not be published. Required fields are marked *