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

Why is the server load status red?

The server load status will be red if the server is under a little more stress than usual. This...

What are these vt directories?

Those are FrontPage extension directories. If you have and no longer need them you can uninstall...

Change your Websites Favorite Icon

How to change your website's icon for your internet browser. Create a 16x16 pixel icon image...

Sub-Domain times out

When you add a sub-domain and it times out make sure you do not have redirection set from that...

SSL - Creating a CSR in Windows 2003

Creating the CSR IIS Windows 2003 or 2000 Server: From Administrative Tools, run the Internet...