Installing and Mounting an SMB/CIFS Share

Pre-requisites

Required Packages

sudo apt-get update
sudo apt-get install cifs-utils

File Directories

sudo mkdir /mnt/storage
sudo chmod -R 777 /mnt/storage

Mounting SMB/CIFS at Boot

  1. First we need to create a credentials file that will have your credentials for the SMB/CIFS Share
sudo touch /root/.smbcredentials
sudo nano /root/.smbcredentials

The following will be your Windows SMB Credentials and Domain. If you do not have a Domain associated, you will remove that part.

username=
password=
domain=
  1. Now we need to change the permisisons so that only root can read the file.
sudo chmod 700 /root/.smbcredentials
  1. Now we need to add access the /etc/fstab file.
sudo nano /etc/fstab

Add the following line towards the bottom.

//HostIP/storage /mnt/storage        cifs    credentials=/root/.smbcredentials,uid=33,gid=33,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
  1. Last step will be to mount the new share.
mount -a

If you are getting any error while mounting like " host not found ", add the version number towards the end after dir_mode=0777

ex: //HostIP/storage /mnt/storage        cifs    credentials=/root/.smbcredentials,uid=33,gid=33,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,vers=3.0 0 0

Back to Ubuntu Guides