67

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?

Niels Kristian
  • 1,039
  • 3
  • 11
  • 16

9 Answers9

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

Avinash Raj
  • 80,446
user278458
  • 821
  • 6
  • 3
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.

drgrog
  • 2,985
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
Zanna
  • 72,312
Igor Golovin
  • 201
  • 2
  • 2
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.

pzkpfw
  • 5,743
3

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
2

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

Niels Kristian
  • 1,039
  • 3
  • 11
  • 16
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

Mr Heelis
  • 131
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
muru
  • 207,228
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.

jschnasse
  • 391
  • 2
  • 4
  • 11