Mount SMB Shares in Ubuntu Linux

Mount smb shares in ubuntu linux.

Mounting SMB shares with no credentials

  1. Install required packages:
sudo apt install cifs-utils 
  1. Create folder to mount
sudo mkdir /media/plex
  1. Mount SMB share with non-credential access:
sudo mount -t cifs -o rw,vers=3.0,guest //192.168.1.5/share /media/plex
  1. Remount on system reboot
sudo vi /etc/fstab 

Enter the below value at the end of the line:

//192.168.1.5/share /media/plex  cifs  username=guest,password=,nofail,x-systemd.automount,x-systemd.requires=network-online.target,x-systemd.device-timeout=1  0  0

Mounting SMB shares with credentials

Follow steps 1 and 2 from above.

  1. Create credential file
vi /root/.mysmbcreds 

Enter values as shown in the below example:

username=johnsmith
password=mysupersecretpassword
  1. Mount SMB share with credentials:
sudo mount -t cifs -o rw,vers=3.0,credentials=/root/.mysmbcreds //192.168.1.5/share /media/plex 
  1. Remount on system reboot
sudo vi /etc/fstab 

Enter the below value at the end of the line:

//192.168.1.5/share /media/plex cifs  credentials=/root/.mysmbcreds,nofail,x-systemd.automount,x-systemd.requires=network-online.target,x-systemd.device-timeout=1  0  0

Leave a Comment

Scroll to Top