Cifs does not mount network device at boot
I have the following instruction written in /etc/fstab
used to mount a samba shared NAS at boot of my Ubuntu server
//192.168.100.104/creativelab /home/pec/CreativeLab cifs credentials=/home/pec/.creativelabcredentials,vers=1.0,sec=ntlm,_netdev,iocharset=utf8,users 0 0
It used to be working with Ubuntu 16.04, but when I upgraded my server to 18.04 stopped working.
I tried changing several options like vers=2.0
, vers=3.0
, sec=ntlmv2
, sec=ntlmssp
removing _netdev
, removing users
and infinite combinations of them, but none solved the problem.
If I digit sudo mount -a
once logged in I get the device mounted, while I get an error if I try to change vers
parameter in /etc/fstab
, but I cannot connect the share on boot.
dmesg
returns the following lines about cifs
[ 24.637155] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
[ 25.894015] e1000e: eno1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[ 25.894054] IPv6: ADDRCONF(NETDEV_CHANGE): eno1: link becomes ready
[ 26.713777] CIFS VFS: Dialect not supported by server. Consider specifying vers=1.0 or vers=2.0 on mount for accessing older servers
[ 26.713791] CIFS VFS: cifs_mount failed w/return code = -95
It seems like instruction vers=1.0
in /etc/fstab
is ignored.
I had a similar problem and since the _netdev
option did not help in my case, I wanted to share another very simple solution, which I found only after much fruitless tinkering with the _netdev param, the @reboot param of Crontab the sleep command, and the file rc.local):
There should be a folder with the name:
/etc/network/if-up.d
Any script you dump there will be executed only after the network link is up.
How it works: Just add a fstab entry with the common options (I had to use 'vers=3.0' as well but this is another story). Then write a simple executable script with the line mount -a
and dump it in the aforementioned dir.
Very simple and works like a charm in my case but it does not seem to be common knowledge.