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

cifsfstabmountsystemd

I have a CIFS mount that was working but has broken. It still mounts with sudo mount -a but not at boot. The CIFS share is hosted on openmediavault 5 on a raspberry pi 4. I'm not seeing any errors in the OMV logs.

My fstab entry looks like this:

//192.168.1.97/sharedrive /media/Nas cifs credentials=/home/brad/.smbcredentials,vers=3,_netdev,iocharset=utf8,auto,forceuid,forcegid,uid=1000,gid=5000,file_mode=0777,dir_mode=0777 0 0

DMESG output looks like this:

CIFS: Attempting to mount //192.168.1.97/sharedrive
CIFS VFS: Error connecting to socket. Aborting operation.
CIFS VFS: cifs_mount failed w/return code = -2

JOURNALCTL output looks like this:

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.

Any help would be hugely appreciated. Thanks!

edit:

output of systemctl status NetworkManager-wait-online.service

systemctl status NetworkManager-wait-online.service
● NetworkManager-wait-online.service - Network Manager Wait Online
     Loaded: loaded (/lib/systemd/system/NetworkManager-wait-online.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2021-01-29 17:42:32 EST; 43min ago
       Docs: man:nm-online(1)
    Process: 806 ExecStart=/usr/bin/nm-online -s -q --timeout=30 (code=exited, status=0/SUCCESS)
   Main PID: 806 (code=exited, status=0/SUCCESS)

Jan 29 17:42:26 HP-Laptop systemd[1]: Starting Network Manager Wait Online...
Jan 29 17:42:32 HP-Laptop systemd[1]: Finished Network Manager Wait Online.

output of systemd-networkd-wait-online

systemctl status systemd-networkd-wait-online
● systemd-networkd-wait-online.service - Wait for Network to be Configured
     Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:systemd-networkd-wait-online.service(8)

edit 2:

systemctl status systemd-networkd-wait-online
● systemd-networkd-wait-online.service - Wait for Network to be Configured
     Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; enabled; vendor preset: enabled)
     Active: active (exited) since Fri 2021-01-29 18:42:00 EST; 3min 54s ago
       Docs: man:systemd-networkd-wait-online.service(8)
    Process: 444 ExecStart=/lib/systemd/systemd-networkd-wait-online (code=exited, status=0/SUCCESS)
   Main PID: 444 (code=exited, status=0/SUCCESS)

Jan 29 18:42:00 HP-Laptop systemd[1]: Starting Wait for Network to be Configured...
Jan 29 18:42:00 HP-Laptop systemd[1]: Finished Wait for Network to be Configured.

EDIT 3:

The output of systemctl status networkd-dispatcher.service systemd-networkd.service

● networkd-dispatcher.service - Dispatcher daemon for systemd-networkd
     Loaded: loaded (/lib/systemd/system/networkd-dispatcher.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-01-29 19:19:51 EST; 1min 20s ago
   Main PID: 747 (networkd-dispat)
      Tasks: 1 (limit: 9072)
     Memory: 19.7M
     CGroup: /system.slice/networkd-dispatcher.service
             └─747 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers

Jan 29 19:19:51 HP-Laptop systemd[1]: Starting Dispatcher daemon for systemd-networkd...
Jan 29 19:19:51 HP-Laptop systemd[1]: Started Dispatcher daemon for systemd-networkd.
Jan 29 19:19:57 HP-Laptop networkd-dispatcher[747]: WARNING:Unknown index 3 seen, reloading interface list
Jan 29 19:20:00 HP-Laptop networkd-dispatcher[747]: WARNING:Unknown index 5 seen, reloading interface list
Jan 29 19:20:00 HP-Laptop networkd-dispatcher[747]: WARNING:Unknown index 6 seen, reloading interface list

● systemd-networkd.service - Network Service
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-01-29 19:19:49 EST; 1min 22s ago
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
   Main PID: 431 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 9072)
     Memory: 4.1M
     CGroup: /system.slice/systemd-networkd.service
             └─431 /lib/systemd/systemd-networkd

Best Answer

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.

Related Question