AutoFS on CENTOS 7

Posted: July 19, 2015 in Linux

This is extension of my prevoius article.In this one we will configure client computer  ( to automount folder located on remote computer (

AutoFS service is alternative to /etc/fstab mount points.Unlike /etc/fstab method, AutoFS mounts filesystem when user access it and unmount them after a period of inactivity.

On server side ( we installed nfs-util package.

We will create folder which will be accessible to remote system

mkdir /myfolder

Add this folder to /etc/export file:




/myfolder is exported to as read-write

Export the entries defined in the /etc/exports file and pass them to to rpc.mountd (if NFSv2 or NFSv3) for the  mounting process, then to rpc.nfsd where the file systems are made available to remote users.

exportfs -avr

exportfs command  writes filesystems to  /var/lib/nfs/etab file

[root@squid myfolder]# cat /var/lib/nfs/etab

Restart nfs service (firewall port was opened in previous article)

Client configuration:

On client ( install autofs package

yum install autofs -y

By default,autofs configuration file is empty,add followowing entries to /etc/sysconfig/autofs file:

# Init syatem options
# If the kernel supports using the autofs miscellanous device
# and you wish to use it you must set this configuration option
# to "yes" otherwise it will not be used.
# Use OPTIONS to add automount(8) command line options that
# will be used when the daemon is started.

MASTER_MAP_NAME="auto.master"  #defines default primary configuration file
TIMEOUT=300 #the maximum idle time (in seconds) after which filesystem is unmounted
NEGATIVE_TIMEOUT=60 #negative timeout for failed mount attempts (default 60)
LOGGING="verbose" #enable logging (read logs to /var/log/messages 
MOUNT_NFS_DEFAULT_PROTOCOL=4 #default protocol used by mount.nfs
BROWSE_MODE="yes" #set to yes by default. Set it to NO and autofs only creates mount points when something is actually mounted on them

Remote shares must be configured in /etc/auto.master  file

# Sample auto.master file
# This is a ‘master’ automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
/- /etc/  #add this line to tell autofs service where to look up for mounting entries
/misc /etc/auto.misc
# NOTE: mounts done from a hosts map will be mounted with the
# “nosuid” and “nodev” options unless the “suid” and “dev”
# options are explicitly given.
/net -hosts
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
# Include central master map if it can be found using
# nsswitch sources.
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#+auto.master #comment this line for NFS shares or you’ll get “unable to read auto.master file”

Create directory named /folder on client.Create /etc/ file to define our share from

/folder -fstype=nfs,rw

In local directory (/folder) will be mounted folder from remote machine ( as read write (rw) as nfs file system

Start autofs service and check if mount was successful:

systemctl start autofs;mount | grep "folder"
/etc/ on /folder type autofs (rw,relatime,fd=7,pgrp=4064,timeout=300,minproto=5,maxproto=5,direct) on /folder type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=,local_lock=none,addr=

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s