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

17

47

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.

Plumbism answered 18/7, 2011 at 14:22 Comment(0)
D
45

I ran into this problem when using a host name and solved it by using an IP address. E.g.:

use

mount -t cifs //192.168.1.15/share

rather than

mount -t cifs //servername/share

Another possible solution is to install

cifs-utils

.

Dodder answered 9/11, 2012 at 15:52 Comment(2)
On some systems you need to install samba3-cifsmount instead of cifs-utils.Shippen
cifs-utils also fixed it in Ubuntu 16.04. Isn't it great that - in the absence of meaningful error messages which might help actually suggest a solution rather than just say "yeah, something didn't work" - we have to look on the internet for a clue. Can mount really not go "ah, yeah, I can't do that because i'm missing something important"? In my case it was "upgrading" from Ubuntu 14.04 to 16.04 which broke it.Haemo
C
26

Ah, the dreaded -22. Basically this seems to be used as a catchall for "something didn't work", although technically it's referred to as an invalid argument.

The client does IMHO a very poor job of telling you the actual problem. (This may not be its fault - it doesn't always have access to that information).

However -- have you checked the logs on the server/machine you are connecting to?

I was connecting to an OS X samba server, and learned from what I found in the logs there that it was necessary to specify additional options under -o as follows:

nounix,sec=ntlmssp

Among the things these settings enable are "allow long names", and "ignore UNIX filename endings"...sec is to specify security flags.

Another possibility is that you're trying to access a filesystem of a type that mount.cifs can't actually handle.

Chadwick answered 8/10, 2012 at 20:52 Comment(4)
bugzilla.redhat.com/show_bug.cgi?id=832741 and bbs.archlinux.org/viewtopic.php?id=160047 both describe sec=ntlm as needed in many cases.Groundless
The OS X bit here is pretty important... this solved it for me as well. Truly those error messages being so obscure and unhelpful is really polluting and obscuring the problem reports and solutions for related problems.Bombastic
This is indeed a very unspecific error code. In my case it popped up when trying to mount through an interface that had an ip that the server would not listen to (which seems always to be problematic with smb/cifs). Once the client had only one interface (with an ip in the same network the server would listen to) the issue disappeared.Veljkov
Let me reiterate @Marius' comment: the OS X bit here is really important if you are trying to connect say a Pi to OS X.Exotoxin
K
10

For RHEL/Centos install package - "cifs-utils"

Kellogg answered 8/8, 2012 at 8:50 Comment(0)
A
9

Maybe move the target?

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

Or maybe this solution? (Ubuntu, Debian methods)

sudo apt-get install smbfs

Or for CentOS, RedHat, Fedora try:

sudo yum install samba-client
Amphitrite answered 18/7, 2011 at 14:25 Comment(0)
O
9

I had a similar issue on Ubuntu 12.04 with the "mount" package (version 2.20.1-1ubuntu3). It happened when I was trying to mount the server share using its hostname rahter than its IP.

Another way to solve the issue on Ubuntu was to install the cifs-utils package. That way I could also mount the samba share using the exact same command line (or fstab) but with hostname.

sudo mount -t cifs //hostname/share -o username=user,password=pwd /mnt/share
Odds answered 23/10, 2012 at 13:5 Comment(2)
Installing cifs-utils solved the problem. Do you know the root cause?Softhearted
For good measure I installed cifs-utils plus suggested packages. That did it for me. Ubuntu 12.10 sudo apt-get --install-suggests install cifs-utilsOffstage
F
7

Just did a clean install of Ubuntu 12.04 LTS and got this trying to hook up my Linux HTPC.

Solved it by running: sudo apt-get install cifs-utils then remounting it.

Franciskus answered 5/3, 2013 at 12:46 Comment(0)
V
7

CIFS returns code "-22" in many cases (not only invalid arguments).

For me installing keyutils did the trick:

apt-get install keyutils

My distribution is "Ubuntu 14.04.2 LTS".

I figured this out by increasing the logging verbosity of CIFS:

echo 7 > /proc/fs/cifs/cifsFYI
# disable again via:
#echo 0 > /proc/fs/cifs/cifsFYI

Documentation on the bitmask ("7") for cifsFYI can be found here: https://www.kernel.org/doc/readme/Documentation-filesystems-cifs-README

After trying to mount once more dmesg included more helpful information:

Dec 7 12:34:20 pc1471 kernel: [ 5442.667417] CIFS VFS: dns_resolve_server_name_to_ip: unable to resolve:

Another maybe helpful link:

http://vlkan.com/blog/post/2015/01/08/smb-mount-troubleshoot/

Vigen answered 9/6, 2015 at 18:46 Comment(2)
Thank you for the debugging tip! I was using value 9 as found somewhere and it was not being verbose. 7 did the trick on Ubuntu 14.04!Handshaker
apt-get install keyutils helped me with Ubuntu 18. ThanksMckelvey
S
3

I have Ubuntu Server 12.10 x64 installed as a VMware VM, running on OS X 10.8 (Mountain Lion).

On the Mac, in SYSTEM PREFERENCES > SHARING > FILE SHARING (on), I added a folder to share. For my tests, I created a new folder within my Public folder called "ubuntu".

In Ubuntu, I issued the following commands:

sudo mkdir /media/target
sudo mount.cifs //10.0.20.3/ubuntu /media/target -o username=davidallie,nounix,sec=ntlmssp,rw

Ubuntu prompted me for the password and, once entered, mounted the folder. I then ran:

df -H

which allowed me to verify the mounts and mount-points.

Swaim answered 26/4, 2013 at 18:8 Comment(0)
U
3

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.

Upside answered 16/7, 2022 at 6:34 Comment(2)
I can confirm that adding the option vers=2.0 is solving the problem on Pop!_OS 22.04 with kernel v5.18.10.Blooming
Thank you very much, I'll update my answer.Upside
N
2

Just experience the problem on RHEL 5. You don't need to install the samba suite, just the samba-client and any dependencies.

Nassi answered 6/9, 2011 at 17:5 Comment(0)
A
2

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>
Aruwimi answered 12/11, 2013 at 23:40 Comment(0)
S
2

Many answers, but wasn't work for me.

Solution: My NAS didn't support Samba 3.0, on which my mount switch automatically.

So I downgraded smb version:

mount -t cifs //192.168.0.2/Share -o rw,vers=1.0,username=*****,password=******* /media/1

It's work.

Saiff answered 24/1, 2023 at 23:57 Comment(0)
F
1

Try run the comamnd:

$modinfo cifs


filename:       /lib/modules/3.2.0-60-virtual/kernel/fs/cifs/cifs.ko
version:        1.76
description:    VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows
license:        GPL
author:         Steve French <[email protected]>
srcversion:     9435BBC2F61D29F06643803
depends:        
intree:         Y
vermagic:       3.2.0-60-virtual SMP mod_unload modversions 686 
parm:           CIFSMaxBufSize:Network buffer size (not including header). Default: 16384 Range: 8192 to 130048 (int)
parm:           cifs_min_rcv:Network buffers in pool. Default: 4 Range: 1 to 64 (int)
parm:           cifs_min_small:Small network buffers in pool. Default: 30 Range: 2 to 256 (int)
parm:           cifs_max_pending:Simultaneous requests to server. Default: 32767 Range: 2 to 32767. (int)
parm:           echo_retries:Number of echo attempts before giving up and reconnecting server. Default: 5. 0 means never reconnect. (ushort)
parm:           enable_oplocks:Enable or disable oplocks (bool). Default:y/Y/1 (bool)

If your getting any error then cifs is not installed. Just check with your admin. I thought it helps out.

Ferrante answered 1/12, 2014 at 13:17 Comment(0)
H
1

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

Hedve answered 18/7, 2022 at 8:51 Comment(0)
D
0

You need to install cifs-utils first , just as follows: sudo yum install cifs-utils

Drag answered 4/11, 2015 at 8:20 Comment(0)
A
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
Accuse answered 12/5, 2018 at 16:44 Comment(0)
O
0

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>
Obscenity answered 27/8, 2018 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.