linux_wiki:auto_mount_network_shares

This is an old revision of the document!


Auto Mount Network Shares

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

  • Enterprise Linux 6/7
  • Network server with shared directory (NFS or CIFS)

Install Required Packages

Pre-reqs:

  • Assuming that all client/server regular nfs/cifs mounting works before continuing. See below for configuration.


Install autofs

yum install autofs

Autofs Config

/etc/auto.master ⇒ Main map file.

  • First column = name of the mount point on the local client system
  • Second column = config file that controls its mounting
  • Third column (optional) = default mount options for all mounts defined in config file

Example

# File: /etc/auto.master
 
/-     /etc/auto.direct
/home  /etc/auto.home --timeout=600
  • Direct Maps ⇒ Network file systems that are mounted from different servers or that don't all start with the same file system path on the same server.
    • Above example: /- /etc/auto.direct
  • Indirect Maps ⇒ Directories on the remote server that can all be mounted under the same local mount point.
    • Above example: /home /etc/auto.home –timeout=600

Note: All direct map entries must be defined as “/-” in the auto.master file.

# File: /etc/auto.direct
 
/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
  • First column ⇒ local mount point
  • Second column ⇒ mount options
  • Third column ⇒ remote shared directory

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
 
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/& 
  • The “&” is replaced by the key in the first column (yoda)


All wild cards (Asterisk and Ampersand Wildcards)

*    192.168.1.151:/home/&
  • The “&” is replaced by the key in the first column (*)
  • “*” is assigned the value that triggered access. If someone tried to access /home/luke, then “luke” will be the value of the key in the first column (“*”)

Start Auto Mounter

  • EL7
    systemctl start autofs
  • EL6
    service autofs start

Enable Auto Mounter on boot

  • EL7
    systemctl enable autofs
  • EL6
    chkconfig autofs on

Reload Auto Mount Config (to enable changes)

  • EL7
    systemctl reload autofs
  • EL6
    service autofs reload

  • linux_wiki/auto_mount_network_shares.1455853653.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)