# First install autofs
yum install -y autofs cifs-utils
# Now enable and , if ready, start the daemon
systemctl enable autofs
The system is now ready for configuration.
Normally /etc/sysconfig/autofs
is ready to use. However to get more debug logging uncomment add these options.
# Use OPTIONS to add automount(8) command line options that
# will be used when the daemon is started.
#
OPTIONS="--debug --verbose"
#
/etc/auto.master
#
# 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).
#
/misc /etc/auto.misc
/vagrant /etc/auto.vagrant
#
# 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.
#
+dir:/etc/auto.master.d
#
# 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
To avoid hardcoding your credentials into world readable file create a credential file in your home.
# User credentials for SMB share
username=<username>
password=<password>
# Optional
domain=<domain name>
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage
# folder to mount = `provisioning`
# mount options = `-fstype=cifs,credentials=/home/vagrant/.secret`
# share URL = `://NLDT-11695/provisioning`
#
# Eventually add these options as well:
# sec=ntlmv2
# uid=<username or UID>
# gid=<groupname or GID>
# vers=1.0 Set SMB version to 1.0 if Kernel > 4.13
provisioning -fstype=cifs,rw,credentials=/home/vagrant/.secret ://NLDT-11695/provisioning
Start the autofs daemon with systemctl start autofs
Try ls <mounted directory>
, e.g ls /vagrant/provisioning
the automounter should now mount the share.
If anything goes wrong, check /var/log/messages
Once you configuration is running, you can uncomment the verbose logging options in
/etc/sysconfig/autofs
.
See also: