Dec 26

AutoFS and Mounting in Linux/Redhat/CentOS

AutoFS and Mounting in Linux/Redhat/CentOS

echo "AutoFS - Automatic FS system Mounting - Dec 26th, 2017 by Sayed"

check if Autofs installed or not
yum list installed | grep autofs

I just installed; hence it is there
you can install with yum -y install autofs

944 yum -y install autofs

then you can enable autofs
946 systemctl status autofs
947 systemctl start autofs
948 systemctl enable autofs

enable - will start this service at reboot/system start

AutoFS in general does not use /etc/fstab
AutoFS uses /etc/mtab file
Also, AutoFS has some files under /etc and starting with auto. You can also define which file will contain the mounting mapping. the file that will act like /etc/fstab for autofs

AutoFS has direct mapping and indirect mapping
let's see some files under /etc for autofs

955 ls /etc/auto*

The files

/etc/ /etc/autofs.conf /etc/autofs_ldap_auth.conf /etc/auto.master /etc/auto.misc /etc/ /etc/auto.smb /etc/auto.master.d:

I saw to use /etc/auto.master for configuring which file will do the mapping for direct mounting.
I saw to use /etc/auto.misc for configuring which file will do the mapping for indirect mounting for AutoFS.

One more config file is under: /etc/sysconfig/autofs

961 cat /etc/sysconfig/autofs

the content
# Init system 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.

For mounting NFS i.e. remote/network file-systems/folders - we can use the regular mounting i.e. /etc/fstab and mount command. However, that is kinda manual. We can mount NFS using AutoFS that will be automatic mount

We use AutoFS for LDAP clients to auto mount Users' home directories. We just configure, then the mounting happens automatically. You remember that getent passwd user-name mounted the remote users' home directory into local system. we used /etc/auto.master to tell that auto.guests will have the mounting configurations. then on /etc/auto.guests file - we configured that users' home directories will be mounted on /home/guests. you can check our notes on LDAP client configuration

979 cat /etc/auto.master
980 vim /etc/auto.master

we added the following line on /etc/auto.master
/etc/auto.guests /etc/

it just tells that AutoFS will consult /etc/auto.guests file for direct mapping


984 vim /etc/auto.guests
we added the following line on /etc/auto.guests

it just tells remote /nfsrh will be automatically mounted to /home/guests
you can try to restart autofs

989 systemctl restart autofs


Indirect Map
indirectly mounted points are only visible when accessed
automatically mounts shares under one common parent directory
each indirect map put only one entry in the mtab file
local and indirect maps cannot exist in the same parent directory
for indirect mapping - you use /etc/auto.misc file

Skip to toolbar