Autofs is a service in Linux like operating system which automatically mounts the file system and remote shares when it is accessed. Main advantage of autofs is that you don’t need to mount file system at all time, file system is only mounted when it is in demand.
Autofs service reads two files Master map file ( /etc/auto.master ) and a map file like /etc/auto.misc or /etc/auto.xxxx.
In ‘/etc/auto.master’ file we have three different fields :
/<Mount-Point> <Map-file> <Timeout-Value>
In map file (/etc/auto.misc or /etc/auto.xxxx) also we have three different fields:
<Mount-Point> <Mount-Options> <Location_of_File System>
In this article we will mount the NFS share using autofs. NFS share ‘/db_backup‘ is exported from Fedora NFS Server (192.168.1.21). We are going to mount this nfs share on CentOS 7 Linux using autofs.
Step:1 Install autofs package
1 | % sudo yum install autofs |
Step:2 Edit the Master map file /etc/auto.master
1 | % cat /etc/auto.master |
Step:3 Create a map file /etc/auto.nfs
1 | % cat /etc/auto.nfs |
Use command showmount -e server
to show the NFS exported from server.
Step:4 Start autofs service
1 | % sudo systemctl start autofs.serivce |