How to automatically mount a SMB/CIFS Share on CentOS

#Introduction

In this tutorial, How to automatically mount a SMB/CIFS Share on CentOS.

Prerequisite

Install necessary packages

yum install samba-client samba-common

Automatically mount a SMB/CIFS Share on CentOS

Install the Automounter

yum install autofs

Create a mount point

mkdir /data/cifs_share

Add an entry to the file /etc/auto.master, as follow:

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

create the file /etc/auto.cifs:

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

Confirm that the mount is being accessed correctly

mount

Conclusion

You have automatically mounted an SMB/CIFS Share on CentOS. I hope will this your helpful. Thank you for reading the DevopsRoles page!

, , ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.