Mounting Samba Share in Linux for Startup

General | Updated March 2026

Mounting a Samba (SMB/CIFS) share on a Linux server lets you access files from a Windows server or NAS device as if they were local. This guide covers how to mount a Samba share manually, make it persist across reboots via /etc/fstab, and troubleshoot common connection issues.

01. Prerequisites

Install the CIFS utilities package if it's not already present:

# CentOS/CloudLinux
yum install cifs-utils -y

# Ubuntu/Debian
apt install cifs-utils -y

Create a mount point directory:

mkdir -p /mnt/share

02. Manual Mount

# Basic mount
mount -t cifs //192.168.1.50/SharedFolder /mnt/share -o username=admin,password=MyPassword

# With SMB version specified (required for many modern servers)
mount -t cifs //192.168.1.50/SharedFolder /mnt/share -o username=admin,password=MyPassword,vers=3.0

# With domain authentication
mount -t cifs //192.168.1.50/SharedFolder /mnt/share -o username=admin,password=MyPassword,domain=MYDOMAIN,vers=3.0

# Read-only mount
mount -t cifs //192.168.1.50/SharedFolder /mnt/share -o username=admin,password=MyPassword,vers=3.0,ro

Verify the mount:

df -h /mnt/share
ls -la /mnt/share

To unmount:

umount /mnt/share

03. Persistent Mount via fstab

To make the mount survive reboots, add an entry to /etc/fstab:

//192.168.1.50/SharedFolder /mnt/share cifs credentials=/root/.smbcredentials,vers=3.0,uid=1000,gid=1000,iocharset=utf8 0 0

Key options:

credentials=/root/.smbcredentials - Path to a file containing the username and password (see next section).

vers=3.0 - SMB protocol version. Use 3.0 for modern Windows servers, 2.1 for older ones. Omitting this may default to SMB1, which many servers disable for security.

uid=1000,gid=1000 - Set the owner of mounted files to a specific user/group ID. Useful when web applications need to read the files.

iocharset=utf8 - Handle filenames with special characters correctly.

After adding the fstab entry, test it without rebooting:

mount -a

If mount -a succeeds without errors, the fstab entry is correct and will work on reboot.

Warning

If the remote server is unreachable during boot, the mount will fail and can delay the boot process. Add _netdev,nofail to the options to tell Linux this is a network mount and to continue booting even if it fails: credentials=/root/.smbcredentials,vers=3.0,_netdev,nofail 0 0

04. Securing Credentials

Never put passwords directly in /etc/fstab because fstab is world-readable. Use a credentials file instead:

# Create the credentials file
cat > /root/.smbcredentials <<EOF
username=admin
password=MyPassword
domain=MYDOMAIN
EOF

# Restrict permissions so only root can read it
chmod 600 /root/.smbcredentials

Reference this file in fstab with the credentials= option as shown above.

05. Troubleshooting

mount error(13): Permission denied

Wrong username, password, or the user doesn't have permission to access the share. Verify credentials by testing from a Windows machine first. Also try adding sec=ntlmssp to the mount options.

mount error(112): Host is down

The remote server isn't reachable or SMB ports (445, 139) are blocked by a firewall. Test connectivity: ping 192.168.1.50 and nc -zv 192.168.1.50 445.

mount error(95): Operation not supported

SMB version mismatch. The server may not support the version you specified. Try different versions: vers=2.1, vers=2.0, or vers=1.0 (least secure, last resort).

Permission Issues on Mounted Files

Files on the mount show as owned by root and web applications can't access them. Add uid and gid options matching the user that needs access. For cPanel accounts, find the UID with id username.

Mount Disappears After Reboot

Check that the fstab entry is correct with mount -a. If the remote server isn't available during boot, add _netdev,nofail to the options. Also check if cifs-utils is installed, as it may not be available during early boot if installed from a non-default repo.

Need Help With Network Storage?

If you need to connect your VPS or dedicated server to network storage, open a support ticket with the remote server details and we can help configure the mount.

Open a Support Ticket

Quick Recap: Mounting Samba Shares

  1. Install cifs-utils - yum install cifs-utils
  2. Create mount point - mkdir -p /mnt/share
  3. Use a credentials file - Never put passwords in fstab directly
  4. Specify SMB version - Use vers=3.0 for modern servers
  5. Add _netdev,nofail - Prevents boot delays if the remote server is down

Last updated March 2026 · Browse all General articles

  • 2 Users Found This Useful

Was this answer helpful?

Related Articles

Why Do I Get Emails for Cron Jobs

Hosting Control Panel | Updated March 2026 Every time a cron job runs on your Ultra Web...

Updated My Site But Still See Old Pages

General | Updated March 2026 You updated your website, but when you visit it you still see...

Firewall and Security Protection

General | Updated March 2026 Every server in our hosting fleet is protected by multiple...

Do you support TeamSpeak?

Not Supported | 2026 Not Available on Shared Hosting TeamSpeak requires a persistent...

When I type in my domain it goes to ultrawebhosting.com

General | Updated 2026 If you type your domain name into a browser and see the Ultra Web...



Save 30% on web hosting - Use coupon code Hosting30