Skip to content
Network Shares

Network Shares

How to mount SMB network shares in Linux:

If the network share is an SMB share install the cifs-utils support:

1
sudo apt install -y cifs-utils

Create a mount point:

1
sudo mkdir -p /mnt/SMBshare

Create a credentials file:

1
sudo nano /etc/credentials/creds-SMBshare

Put this in it:

1
2
username=USERNAME
password=YOUR_SMB_PASSWORD

Lock it down:

1
sudo chmod 600 /etc/credentials/creds-SMBshare

Now add an /etc/fstab entry:

1
//<SMB share host IP or FQDN>/Media /mnt/SMBshare cifs credentials=/etc/credentials/creds-SMBshare,uid=1000,gid=1000,iocharset=utf8,file_mode=0664,dir_mode=0775,vers=3.0,nofail,_netdev,x-systemd.automount 0 0

If this mount is for apps, set uid/gid to the service account they run as, for example:

1
//<SMB share host IP or FQDN>/Media /mnt/SMBshare cifs credentials=/etc/credentials/creds-SMBshare,uid=<service account name>,gid=<group name for service account>,iocharset=utf8,file_mode=0664,dir_mode=0775,vers=3.0,nofail,_netdev,x-systemd.automount 0 0

Then test without rebooting:

1
2
3
sudo systemctl daemon-reload
sudo mount -a
mount | grep /mnt/media

Useful Checks If it fails:

1
2
3
 sudo journalctl -u smbd -b
 sudo dmesg | tail
 sudo mount -a -v