mount.cifs: permission denied after upgrading to 20.10

5,287

Try:

mount.cifs //192.168.2.2/C /mnt/mountpoint -o credentials=/home/ubuntu/.smbcredentials,iocharset=utf8 

If you get an error, you might be missing a utility:

sudo apt-get install cifs-utils

If you get a no such file or directory error, create the mountpoint:

mkdir -p /mnt/mountpoint

If you get a permission denied error, check the permissions:

ls -ld /mnt/mountpoint

You might have to change it:

sudo chown `whoami` /mnt/mountpoint 
sudo chmod 700 /mnt/mountpoint

Then try again. (Run man chmod to learn more.)

If it still doesn't work, tweak your options until it does. Also try with sudo for good measure, but it shouldn't be necessary.

For an easy:

mount /mnt/moutpoint

Make sure the mount you want is in /etc/fstab. If not, add it. man fstab for the format. Eg.

//192.168.2.2/C /mnt/mountpoint cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8 2 1

Where ~/.smbcredentials contains:

user=myuser
password=mypass
domain=WORKGROUP

(Remember to chmod 600 ~/.smbcredentials)

Then mount again:

mount /mnt/mountpoint

No need to be in a fstab, sudo or mount group.

Share:
5,287

Related videos on Youtube

IncrediblyConvoluted
Author by

IncrediblyConvoluted

Updated on September 18, 2022

Comments

  • IncrediblyConvoluted
    IncrediblyConvoluted over 1 year

    I have a NAS that up to version 19 I could mount at startup through fstab with this command:

    //192.168.1.99/data /home/user/data cifs username=uname,password=upwd,uid=user,file_mode=0660,dir_mode=0775 0 0
    

    After having upgraded to 20.10, this has stopped working, and a check using mount -a returns: mount.cifs: permission denied.

    I am still able to mount the drive using sudo mount -a, but how can I modify fstab to make it work again?

    • Terrance
      Terrance over 3 years
      I would check the owner and permissions of the /home/user/data folder. According to the man mount for "Non-superuser" mounts as long as you have the user specified in fstab it should work.
    • IncrediblyConvoluted
      IncrediblyConvoluted over 3 years
      That actually did the trick, many thanks! I wonder why there was no need for an fstab group before?
    • alebal
      alebal over 3 years
      I have the same problem but I didn't understand how to solve it, can you explain it to a non-Linux expert? What should I add to my fstab?
    • IncrediblyConvoluted
      IncrediblyConvoluted over 3 years
      @alebal, you need to create a group named fstab and add your userid to it. sudo groupadd fstab will create the group sudo adduser yourusername fstab will add you to the group
    • alebal
      alebal over 3 years
      @IncrediblyConvoluted I ran your commands, but after reboot still:mount.cifs: permission denied. I use this format: //fritz-nas/fritz.nas/PENNA_USB/FRITZ/NAS /media/NAS cifs username=myusername,password=mypassword,uid=1000,gid=1000,se‌​c=ntlmv2,iocharset=u‌​tf8,vers=1.0 0 0, is something missing? It has always worked and with sudo mount -a it still works but at boot I don't have permission to access.
    • alebal
      alebal over 3 years
      @IncrediblyConvoluted Still blocked... please help...
    • IncrediblyConvoluted
      IncrediblyConvoluted over 3 years
      @alebal I'm afraid I can't help further than that, my knowledge ends right here. Hopefully someone else will be able to answer
    • alebal
      alebal over 3 years
      same problem in raspberry pi with raspberry os
    • Dagelf
      Dagelf over 3 years
      sudo chown myusername /media/NAS; sudo chmod 700 /media/NAS
    • alebal
      alebal over 3 years
      Today even on LMDE, after a weird reboot of router and pc... weird...
  • alebal
    alebal over 3 years
    Don't seems to work... says: sudo mount -a mount error(2): No such file or directory Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) but all dir are correct, they work with the other format just don't work on boot...
  • Dagelf
    Dagelf over 3 years
    You definitely made a typo somewhere. Please share the string that doesn't work, and the one that works...
  • alebal
    alebal over 3 years
    //fritz-nas/fritz.nas/PENNA_USB/FRITZ/NAS /media/NAS cifs username=myuser,password=mypssw,uid=1000,gid=1000,sec=ntlmv2‌​,iocharset=utf8,vers‌​=1.0 0 0 this work with sudo mount -a, but not on boot
  • alebal
    alebal over 3 years
    #//fritz-nas/fritz.nas/PENNA_USB/FRITZ/NAS /media/NAS cifs credentials=/home/pi/.smbcredentials,iocharset=utf8 2 1 this show the error with sudo mount -a