What does cifs_mount failed w/return code = -22 indicate

Viewed 75064

I am trying

sudo mount -t cifs //<server>/<share> -o username=user@domain,password=**** /mnt/<mountpoint>

error message:

mount: wrong fs type, bad option, bad superblock on //server/share,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

The syslog has

 CIFS VFS: cifs_mount failed w/return code = -22

I am able to mount the same share on another centos system. I can ping the server, mount point directory has been created.

16 Answers

This has recently manifested thanks to a kernel bug in v5.18.8+, I was able to reproduce on v5.18.9 and v5.18.11.

Here is the relevant ticket on kernel.org, quote:

it appears that kernel 5.18.8 breaks cifs mounts on my machine. With 5.18.7, everything works fine. With 5.18.8, I am getting:

$ sudo mount /mnt/openmediavault/
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)

The relevant /etc/fstab line is:

//odroidxu4.local/julian /mnt/openmediavault cifs credentials=/home/julas/.credentials,uid=julas,gid=julas,vers=3.1.1,nobrl,_netdev,auto 0 0

Here is the offending commit, and here is the fix, which applies cleanly to v5.18.11. The cause is, from what I understand, a bug in old versions of the samba server in the negotiation protocol.

If this is your issue, you can:

  • patch your kernel yourself;
  • downgrade to v5.18.7;
  • switch to an LTS kernel;
  • use the userspace (and also really slow and awful) gvfs-smb;
  • upgrade the samba version on your server; or
  • add vers=2.0 to the mount.cifs options in /etc/fstab.

Note that while I haven't tried the last one personally, the venerable @SEBiGEM has confirmed in the comments that it works for v5.18.10.

Note also that I didn't try upgrading samba on the server at all because I hate touching the box it's running on - every time I upgrade anything everything breaks. Doing so might also not be an option for those with NAS appliances.


As a personal sidenote, it's a little sad that so many different things can cause -22. My answer is correct, but very very niche and specific to this point in time. I imagine in a month it will simply be useless noise.

Maybe it's too late, but simplest solution described in kernel bug 50631: in the latest code, unc mount parameter in mandatory. Modified command works for me:

sudo mount -t cifs //<server>/<share> -o username=user@domain,password=****,unc=\\\\<server>\\<share> /mnt/<mountpoint>

Adding the option vers=3.0 to the mount command worked for me: sudo mount -t cifs -v <src> <dst> -o ...,vers=3.0,...

I know this is old, but on older cifs-utils versions, you may have to add the following two lines to /etc/request-key.conf

create cifs.spnego * * /usr/sbin/cifs.upcall -c %k
create dns_resolver * * /usr/sbin/cifs.upcall %k

Workaround without installing additional packages (cifs-utils adds another 81mb in Debian Stretch):

$ FILESERVER_IP=$(getent hosts myfileserver.com | awk '{ print $1 ; exit }')

$ sudo mount -t cifs //${FILESERVER_IP}/<share> -o username=user@domain,password=**** /mnt/<mountpoint>
Related