Mounting Samba Share in Linux for Startup

The following may be used to mount a samba share via your /etc/fstab file for bootup on CentOS/RedHat systems:

Create a password file for the windows mount point where desired:

Example:

 vi /root/smbpw.pass

with the following:

username=service_account
password=*********
domain=domaincontrollername


Install cifs and dependencies for samba support with the following:

 

yum install -y cifs-utils
mkdir /mnt/smb/
mkdir /mnt/smb/sharename
vi /etc/fstab

 

//windowsservername/sharedfolder/iftherearespacesuse\040 /mnt/smb/sharename cifs _netdev,x-systemd.after=network-online.target,rw,credentials=/root/smbpw.pass,dir_mode=0777,file_mode=0777 0 0

Once setup, use:

mount -a


To test mounting followed by:

df

 

to validate it was added. Reboot and verify. If it does not load on startup, adding the following to the /etc/rc.local is a great workaround:

sleep 15
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  mount -a #: mount all drives in /etc/fstab
fi

 

  • 2 Users Found This Useful

Was this answer helpful?

Related Articles

htaccess - Allow Let's Encrypt to Validate and Renew

When receiving the following Let's Encrypt error message:domain.com: The SSL certificate expires...

What are these htaccess files that keep popping up?

.htaccess files are default files the server uses to perform certain tasks. Features such as...

vBulletin fsockopen() [function.fsockopen]: unable to connect

When setting up mail in vBulletin be sure you are using localhost for the mail server along with...

How can I change the index listing in a directory?

You can change the initial page that is sent to client requests when a directory is accessed by...

Error 404 - File Not Found

Files are case sensitive. Make sure you are typing the address in correctly. Verify that the...