CIFS mount problem, error cifs_mount failed w/return code = -2

Solution 1:

Your fstab entry looks okay and should work fine.

It ,however. appears that the mount is attempted prior to network connectivity becomes available ( systemd's connectivity in particular ). Hence these errors:

CIFS VFS: Error connecting to socket. Aborting operation.

and

systemd[1]: media-Nas.mount: Mount process exited, code=exited, status=32/n/a systemd[1]: media-Nas.mount: Failed with result 'exit-code'. systemd[1]: Failed to mount Mount CIFS Share.

This is due to the service systemd-networkd-wait-online being disabled.

Enable the service like so:

sudo systemctl enable systemd-networkd-wait-online

This should execute without errors.

After that reboot your system. Your network share should mount at boot now.

If the share is still not mounting, check:

systemctl status networkd-dispatcher.service systemd-networkd.service

And see if either service is disabled and enable them too. Then reboot your system.

Solution 2:

I too was having exact same issue. Though in my case CIFS share is hosted on ASUS RT AC68U with DD WRT 3.0

Here's how I solved the issue:

(1) Enabled these services (as I've disabled these in the past):

sudo systemctl enable systemd-networkd-wait-online

sudo systemctl enable systemd-networkd.service

sudo systemctl enable NetworkManager-wait-online.service

Note: If any of those services are masked, then you would need to first unmask, and then enable it.

You can find more on how to properly unmask here: [1] and [2].

(2) I commented out (removed) fstab entry for CIFS share, and created systemd mount for cifs share:

Note: Create a new file media-admn-nas.mount in the diretory /etc/systemd/system.

The filename must contain the mount point name where the slashes are replaced with “minus”. Mount-directory /media/admn/nas => media-admn-nas.mount

sudo nano /etc/systemd/system/media-admn-nas.mount

[Unit]
Description=CIFS Mount Service 
Requires=network-online.target systemd-networkd.service
After=network-online.target network-online.service media-admn-1\x2d6TB.mount remote-fs.target
Wants=network-online.target NetworkManager-wait-online.service

[Mount]
What=//192.168.1.1/nas
Where=/media/admn/nas
Options=rw,_netdev,auto,cache=none,vers=3.11,credentials=/home/admn/.smbcredentials,forceuid,forcegid,uid=1000,gid=1000
Type=cifs
TimeoutSec=15

[Install]
WantedBy=multi-user.target

Note-1: In my case, media-admn-1\x2d6TB.mount is an additional hard drive where I have mounted the cifs share, so I've added that as After= requirement.

Note-2: As I was still getting errors, I've added TimeoutSec=15

(3) Enable the mount:

sudo systemctl enable media-admn-nas.mount

sudo systemctl daemon-reload

(4) Reboot: 15 sec after a reboot, CIFS share should be mounted.

(5) Check status:

$ systemctl status media-admn-nas.mount
● media-admn-nas.mount - CIFS Mount Service
     Loaded: loaded (/etc/systemd/system/media-admn-nas.mount; enabled; vendor preset: enable>
     Active: active (mounted) since Sun 2021-01-31 10:37:52 IST; 1h 58min ago
      Where: /media/admn/nas
       What: //192.168.1.1/nas
      Tasks: 0 (limit: 19083)
     Memory: 12.0K
     CGroup: /system.slice/media-admn-nas.mount