Sometimes it is better to have a share automount when a program tries to access a share if the server is rebooted after mounting it can cause lockup issues and even slow boot.
autofs will always make sure your samba and NFS mounts are working. It's pretty slick.
autofs can be installed using yum, it is in the normal centos repo, no other repos are needed.
$ sudo yum install -y autofs
Autofs creates a few files under /etc, you will need to edit them with your favorite editor. (vi, joe, nano, vi, etc)
$ sudo vim /etc/auto.master
add the following under the existing /misc entry on line 7, and save the file.
to add automount points, you need to edit the file we told it to go to for /mnt (which is /etc/auto.cifs), here is an example file from my Linux desktop with a few shares. share1 -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.1.55/c share2 -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.0.1/image share3 -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.1.1/transfers share4 -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://192.168.0.1/users #The first column is what the share is called (where it is mounted in relation to its mount point (which is /mnt) #EXAMPLE the top line would mount the share to /mnt/share1 and cd'ing to the directory and doing a ls will auto mount the share
you will need to create the folders from column 1 of above, you can do it in one swipe like this:
$ sudo mkdir /mnt/share1 /mnt/share2 /mnt/share3 /mnt/share4
Once you are done, the service needs to be started, but won't… Why?!, it's because we did not create the credential file! doh! Let's do it now.
$ vim /etc/credentials.txt
let's add the following 2 lines to the credentials.txt file.
password=windowsorsamba_passwd (can use guest to mount guest shares.)
sudo chkconfig autofs on # to enable service on every boot. sudo service autofs start # start service now
sudo systemctl enable autofs # to enable service on every boot. sudo systemtl start autofs # start service now