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

Error 401 Unauthorized

Error 401: Unauthorized   A 401 error means the server requires authentication to access the...

Set CORS header to Allow Access for any Incoming Domain

The following may be used to set to always set the CORS header for any incoming domains without...

Enable AllowOverride

AllowOverride and .htaccess Support   AllowOverride is already enabled on all of our hosting...

Why is my account suspended?

Why Is My Hosting Account Suspended?   If your website shows a suspension notice, your...

Why can I not ping my domain?

Why You Cannot Ping Your Domain   If the ping command does not respond when you try to ping...



Save 30% on web hosting - Use coupon code Hosting30