CentOS 6: How to automatically mount a SMB/CIFS Share

Install necessary packages

yum install samba-client samba-common autofs

Create a mount point

mkdir /mnt/cifs_share

Create an entry in the /etc/auto.master file

/mnt/cifs_share /etc/auto.cifs --timeout=600 --ghost

Create /etc/auto.cifs configuration file

share_data -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt
://<Host Name>/<Folder Name>

Create /etc/credentials.txt file

username=DOMAIN/User
password=Password

Secure the credentials.txt file

chmod 0700 /etc/credentials.txt

Restart the automounter service

/etc/init.d/autofs restart

References: