Mounting samba share permanently (Ubuntu 16.04 LTS)

Here is how to mount a windows/samba share permanently with your /etc/fstab:

First install the cifs-utils package:

# apt-get install cifs-utils

now create a credential file containing your user and password

# vim /home/myuser/.smbcredentials

add following lines:

username=myuser
password=mypassword
domain=mydomain (optional)

then secure its permissions:

# chmod 600 /home/myuser/.smbcredentials

after that open your /etc/fstab and add following line to it:

//servername/share /mymountpoint cifs vers=3.0,sec=ntlmssp,credentials=/home/myuser/.smbcredentials,iocharset=utf8 0 0

as a final step run

# sudo mount -a

Some explanations on the fstab line:

vers: this specifies the SMB protocol version, in my case version 3.0
sec: sets the security for the password hashes, here NTLMv2 password hash inside raw NTLM
credentials: sets the file with your credentials
iocharst: sets the encoding to UTF-8

(refer to man mount.cifs for parameter details)