Gilles' sysadmin & dev blog for Earth Science

Mount SMB-Shares automatically on Linux

Here’s a quick tip to automatically mount SMB-Shares on Linux system startup.

This will allow mounting the shared folders from Windows Storage Server 2016 on Ubuntu / Kubuntu 18.x.

First install the “cifs-utils” on Ubuntu-Linux with command:

#sudo apt update
#sudo apt install cifs-utils

To allow mounting the SMB-Share at Ubuntu startup edit “/etc/fstab” (in root mode) ¬†and add the following line:

//myWindowsServer.local/SMB-ShareName /mnt/mySMBDisc cifs comment=systemd.automount,username=smbUser,password=mySMBPasswd,uid=1001,gid=1001,iocharset=utf8,file_mode=0777,dir_mode=0777,rw,fsc,mfsymlinks,soft,nounix,vers=3.1.1 0 0	 	 

Replace “username” with your SMB-Login name and its password. Using file_mode and dir_mode avoids file & directory permission issues.

To automatically mount at startup don’t forget to add “comment=systemd.automount” or else automounting won’t work!

For more information take a look at mount.cifs man page:

man mount.cifs

Enjoy!