Permissions issue with fstab CIFS mount but not when using mount command

5,219

I finally found the solution - this works in /etc/fstab:

//server/share /media/localdir cifs credentials=/home/myuser/.smbcredentials,,uid=1000,gid=1000 0 0
Share:
5,219

Related videos on Youtube

Ian M
Author by

Ian M

Updated on September 18, 2022

Comments

  • Ian M
    Ian M over 1 year

    I want to mount a Windows share using CIFS on my Ubuntu 17.04 machine. If I use the mount command below it works fine, and I can access the Windows share:

    sudo mount -t cifs //servername/sharename /home/myuser/mediafolder -o credentials=/home/myuser/.smbcredentials,dir_mode=0777,file_mode=0777
    

    If I attempt to make this permanent using the following entry in /etc/fstab I get a permissions error when I try to access the mount point at /home/myuser/mediafolder :

    //servername/sharename /home/myuser/mediafolder cifs credentials=/home/myuser/.smbcredentials,gid=1000,uid=1000,iocharset=utf8,file_mode=0777,dir_mode=0 0 0
    

    Why am I denied permissions with the 2nd approach?

    • guiverc
      guiverc over 6 years
      just a thought - does root have read access to your credentials file (you're not logged in at boot; it'll be root that tries to mount the samba share & thus needs to read the credentials file)
    • guiverc
      guiverc over 6 years
      probably a better guess.. don't mount to ~/mediafolder, but mount instead to /home/mediafolder and try it. (I forget where I read this; but as I recall there was a reason you couldn't mount to a home/user directory anymore documented in a samba updates years ago if my memory serves me)
    • Ian M
      Ian M over 6 years
      Yes root does have access to my .smbcredentials file. I tried mounting to a /home/media/* folder instead but get the same error - "ls: cannot open directory '/home/Media/Videos': Permission denied"
    • guiverc
      guiverc over 6 years
      did you sudo chmod a+rw /home/Media -R (or whatever permissions you want) before you tried to access it; as I'm assuming you created it with a 'sudo mkdir` & thus it'll be 'root' owned. Also I hope you didn't include a * in your mount point, nor a user directory; just a directory you created first (i used media as example instead of your mediafolder).
    • Ian M
      Ian M over 6 years
      I used chmod -R 777. I use the same folder when mounting from the command line and don't get permissions issues, so I'm guessing there isn't a permissions issue with that folder?
    • Ian M
      Ian M over 6 years
      ...and no I used "/home/media/videos"
    • guiverc
      guiverc over 6 years
      last thought (which maybe applies if you encrypt your /home) - to try /media (or a directory not in your /home partition). I had hoped you'd use a directory inside /home (/home/media) as it was as a directory (not subdirectory) I recalled in samba doco).
    • Ian M
      Ian M over 6 years
      Still no luck :0(
    • guiverc
      guiverc over 6 years
      try dropping your options (exclude credentials); if it works add them back slowly. (really obvious stuff is all I got; a vers= change was made to samba but shouldn't affect you)
    • Ian M
      Ian M over 6 years
      Still no luck. I've also discovered that if I run the mount commands in rc.local (i.e. at startup) - the same mount commands that work fine if I execute them in a terminal window - I also get the "permission denied" error when I try to access the mounted folder. It seems that the context in which the mount is being done is creating the permissions issue. ????