General Information
Automatically mounting network shares with autofs. This is the client configuration and assumes a working server setup with NFS or CIFS shares already.
Checklist
Pre-reqs:
Install autofs
yum install autofs
The master map file contains entries that point to other config files for specific mount instructions.
Master Map File Contents
Example
# File: /etc/auto.master OR /etc/auto.master.d/<name>.autofs # Direct mounts: look in auto.direct for mappings /- /etc/auto.direct # Indirect mounts: look in auto.home for mappings of subdirectories of /home/ /home /etc/auto.home --timeout=600
Note: All direct map entries must be defined as “/-” in the /etc/auto.master or /etc/auto.master.d/<name>.autofs file.
# File: /etc/auto.direct # Reminder of master map contents for reference: # /- /etc/auto.direct # Direct mappings: local mountpoint from remote mountpoint /network-shares/nfs-share -rw 192.168.1.151:/data/nfs /network-shares/nfs-share2 -rw 192.168.1.151:/data/nfs2 /network-shares/cifs -fstype=cifs,rw,credentials=/root/.ssh/.cifs-share //192.168.1.151/cifs-share
Note: This example works best when implemented using LDAP authentication to ensure that user id's are matched up between NFS server and clients.
Naming local and remote directories
# File: /etc/auto.home # Reminder of master map contents for reference: # /home /etc/auto.home --timeout=600 # Indirect mappings: sub directories of /home/ yoda 192.168.1.151:/home/yoda luke 192.168.1.151:/home/luke vader 192.168.1.200:/home/vader
Naming local only (Ampersand Wildcard)
yoda 192.168.1.151:/home/&
All wild cards (Asterisk and Ampersand Wildcards)
* 192.168.1.151:/home/&
Start and Enable Auto Mounter on Boot
systemctl start autofs
systemctl enable autofs
service autofs start chkconfig autofs on
Reload Auto Mount Config (to enable changes made after service startup)
systemctl reload autofs
service autofs reload