Ubuntu: Proper fstab entry to mount a samba share on boot?
Channel: Roel Van de Paar
Date: 17/06/2019

Ubuntu: Proper fstab entry to mount a samba share on boot?


Question: I am a little confused on the proper fstab entry for a samba share in Ubuntu
12.04
    * I can get the drive to mount manually by using:
      sudo mount -t cifs //192.168.2.2/raid_drive /mnt/homeserver -
      o username=jon,password=password
    * So I tried putting this in fstab:
      //192.168.2.2/raid_drive /mnt/homeserver cifs
      username=jon,password=password,iocharset=utf8,mode=0777,dir_mode=07‌​77 0
      0
    * Which gives me this error in syslog:
      kernel: [ 2217.925354] CIFS: Unknown mount option mode
      kernel: [ 2217.936345] CIFS VFS: default security mechanism requested.
      The default security mechanism will be upgraded from ntlm to ntlmv2 in
      kernel release 3.3
    * This http://www.justlinux.com/nhf/Filesystems/
      Mounting_smbfs_Shares_Permanently.html says to use smbfs although I
      believe smbfs is deprecated?
What is a common fstab configuration for a samba share in Ubuntu 12.04?
EDIT:
Using the accepted answer below I was initially getting this error message
(from dmesg):
[   45.520883] CIFS VFS: Error connecting to socket. Aborting operation
[   45.520990] CIFS VFS: cifs_mount failed w/return code = -115
although it turns out this was due to network connectivity issues, and not
related to improper fstab entry.

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 4 people ==
Your initial problem is in the option mode, as syslog says in the first line.
What you probably meant was file_mode, see man mount.cifs for more information.
The credential approach mentioned by Eliah is indeed better than using username
and password, but I don't think it interferes with the other options like
file_mode or dir_mode.

With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user Vitor (https://askubuntu.com/users/125032), user russnash (https://askubuntu.com/users/73797), user jpetersen (https://askubuntu.com/users/54187), user Jorge Castro (https://askubuntu.com/users/235), user Eric Carvalho (https://askubuntu.com/users/65926), and the Stack Exchange Network (http://stackoverflow.com/questions/157128). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.