Mounting cifs drive gives: mount error(22): Invalid argument
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=0770However 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?
49 Answers
maybe this helps with this, mount error(22): Invalid argument... possible error is the
argument/s (mode) on mount command.
check your logs on the errors encountered.
tail -f /var/log/kern.logremove the invalid argument
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.
I had the same issue on Arch Linux, with this message in log:
kernel: CIFS VFS: cifs_mount failed w/return code = -22For 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 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.
I was using a wrong URL. It should have been: //
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 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 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 0to
# 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 0the error I got was under dmesg was CIFS: Unknown mount option "umask=0777"
note that umask is no longer allowed
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.orgAfter that I was able to successfully mount the target.