45

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?

  • 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 '14 at 15:57
  • 4
    Mount should really return a better error message. Knowing which argument is invalid would make this error message so much more helpful. – Gregory Arenius Jul 6 '18 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 '19 at 11:29
  • 2
    dmesg | tail tells you a bit more about which option is giving you trouble. – HongboZhu Jul 15 '19 at 12:24
65

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

  • 9
    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 '17 at 23:27
  • 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 '18 at 13:15
7

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
5

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

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

2

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.