64

I'm trying to run:

sudo mount -t cifs //user.my-backup.com /mnt/wal_drive -o iocharset=utf8,rw,credentials=/etc/backupcredentials.txt,uid=postgres,gid=postgres,file_mode=0660,dir_mode=0770

However I keep on getting the following error:

mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

What am I doing wrong?

4
  • 1
    Two possible problems: your source is an URL which either may not resolve or is not advertising Samba; and, the uid/gid need to be expressed numerically. Have you read the referred man page?
    – douggro
    Feb 27, 2014 at 15:57
  • 10
    Mount should really return a better error message. Knowing which argument is invalid would make this error message so much more helpful. Jul 6, 2018 at 21:23
  • 1
    Mount gives a generic error because the details are in the log. As it is said below, use tail -f /var/log/kern.log to understand what's going on.
    – Sam
    Feb 13, 2019 at 11:29
  • 3
    dmesg | tail tells you a bit more about which option is giving you trouble.
    – HongboZhu
    Jul 15, 2019 at 12:24

9 Answers 9

82

maybe this helps with this, mount error(22): Invalid argument... possible error is the argument/s (mode) on mount command.

  1. check your logs on the errors encountered.

    tail -f  /var/log/kern.log 
    
  2. remove the invalid argument

2
  • 11
    This worked for me. I found the error CIFS not working, kernel upgrade:No dialect specified on mount and resolved it by [adding] vers=1.0 to my /etc/fstab(bbs.archlinux.org/viewtopic.php?id=230952). I suspect it is caused by using kernel 4.13.
    – blaha
    Nov 13, 2017 at 23:27
  • 1
    Jeez, thank goodness for stackoverflow. Same problem on ubuntu. I added vers=2.0 and it works. Current mount.cifs is at 6.4. Probably some enhancements to credentials but not digging into CIFS now...
    – dturvene
    Jun 8, 2018 at 13:15
16

Another possible cause is the presence of sec=ntlm in /etc/fstab and it's incompatibility with newer SMB protocols like SMB3.

While not the OP's case, this can also cause mount error(22): Invalid argument errors, as it did for me after upgrading an old server.

Even though kern.log includes a suggestion to specify vers=1.0 on mount, it may be safer to remove or change sec=ntlm instead. Perhaps use the defaults to allow automatic negotiation of the SMB version and security, or specify compatible options such as vers=3.0,sec=ntlmssp.

Obviously this depends on your SMB server's features, but I would try and avoid vers=1.0 unless necessary.

2
  • 1
    This worked for me. I have a Synology DS918+. Enabled SMB3 on the NAS. Set vers=3.0 parameter and removed the sec=ntlm parameter. Thanks.
    – dgnorton
    Apr 12, 2020 at 14:48
  • 1
    You answer was very helpful to me. I removed sec=ntlm completely and then all my drives mounted. Thank you. May 9, 2020 at 4:55
10

I had the same issue on Arch Linux, with this message in log:

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

For me the solution was to specify older version of cifs (by default it was 3.0):

/etc/fstab:

//my-router/share /media/share cifs ver="2.1",rw,soft,uid=ele,gid=ele,file_mode=0770,dir_mode=0770,credentials=/etc/router-credentials.conf 0 0
2
  • Could you please explain your command? what "soft" , uid and other parts mean?
    – Luke
    Feb 21, 2020 at 7:24
  • 1
    1) soft - The program accessing a file on the cifs mounted file system will not hang when the server crashes and will return errors to the user application. 2) uid and gid - sets the uid that will own all files or directories on the mounted filesystem when the server does not provide ownership information. 3) file_mode and dir_mode works the same way as uid and gid. 4) 0 0 these fields are not used, and by convention set to 0 For more information please see mount.cifs man Feb 22, 2020 at 10:43
3

In my case, this issue was caused because I had mounted a directory full of symbolic links. After investigating the symbolic links in Windows, I got their "real" paths and mounted those instead.

2

I was using a wrong URL. It should have been: //user.my-backup.com/backup

1
  • Some file shares stop the use of the top level. I had to pick a sub folder to mount. Mar 30, 2023 at 10:56
2

You can add the version information for SMB to solve the issue. What i did is i added vers=1.0. This is SMB version 1 which works with all the smb drivers. For your case it will look something like this

sudo mount -t cifs //user.my-backup.com /mnt/wal_drive -o iocharset=utf8,rw,vers=1.0,credentials=/etc/backupcredentials.txt,uid=postgres,gid=postgre ,file_mode=0660,dir_mode=0770
1

After upgrading to Jessie Debian the package must have changed. I removed guid=0 from the following fstab mount and it all worked correct again.

//x.x.x.x/General/  /usr/local/share/general cifs uid=0,guid=0,rw,credentials=/etc/gen-cifspasswd 0 0
1

I am on CentOS I know this is Ubuntu but bear with me, this still comes top on google. People are correct to say that mount -a will give you the error.. on centos you then have to type # dmesg which will tell you what was actually wrong in detail

For me, I had to change

# cat /etc/centos-release
CentOS release 6.9 (Final)
# nano /etc/fstab
 ------------------------------------------------
 \\192.168.0.4\Work /mount/drive cifs user,rw,suid,uid=48,umask=0777,username=*****,password=******* 0 0

to

 # cat /etc/centos-release
 # CentOS Linux release 8.2.2004 (Core)
 # nano /etc/fstab
 ------------------------------------------------
 \\192.168.0.4\Work /mount/drive cifs user,rw,suid,uid=48,file_mode=0770,dir_mode=0770,username=*****,password=******* 0 0

the error I got was under dmesg was CIFS: Unknown mount option "umask=0777"

note that umask is no longer allowed

0

Same error when try to mount a directory that in fact was a symbolic link.

Solution: add domain name to search directive in /etc/resolv.conf

search example.org

After that I was able to successfully mount the target.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .