Having permissions issues with Samba - Ubuntu mount works, fstab mount is read-only

I have a Samba share hosted on a server in my apartment, running Debian. I’m trying to mount it through fstab so it shows up in my normal file tree, but when it mounts, I’m operating as read-only.

The Ubuntu file manager is also able to mount it, and in there I’m able to write as much as I like.

My fstab has:

//192.168.0.12/sambashare /mnt/samba cifs username={my_name},password={my_pass},file_mode=0777,dir_mode=0777 0 0

And if I cd /mnt/samba and ls, I see all the files there. If I touch testfile.txt it gives a permission error.

On the other hand, if I open the file window and open the sambashare (which shows up in the same place where I’d see a flash drive), I can interact with it all I want. If I then right click and Open in Terminal, this shows that it’s been mounted to:
/run/user/1000/gvfs/smb-share:server=shepard,share=sambashare

And once I’m in there, I can touch testfile.txt all I want.

How do I debug the two different ways it’s being mounted, and make the /mnt/samba version properly give me write permissions?

try adding rw to your mount options

//192.168.0.12/sambashare /mnt/samba cifs username={my_name},password={my_pass},file_mode=0777,dir_mode=0777,rw 0 0

Even better, move the credentials out of a world readable file :smiley:

//192.168.0.12/sambashare /mnt/samba cifs      file_mode=0777,dir_mode=0777,rw,credentials=/root/credentials.txt     0     0

The credential file has three lines

username=<username>
password=<password>
domain=<domain name or workgroup  netbios name>

For a more advanced option, here’s a modified version of what I have used that automounts as needed and has some performance tweaks… see the link at the bottom for full explanations of the options.

Warning: some of the size tweaks in this example may exceed the samba defaults (I don’t remember), if they don’t work, just remove them unless you can run 10Gbit+ speeds.

//192.168.0.12		/mnt/samba		cifs		rw,noauto,x-systemd.automount,x-systemd.mount-timeout=30,_netdev,x-systemd.idle-timeout=15min,iocharset=utf8,file_mode=0770,dir_mode=0770,nostrictsync,rsize=8388608,wsize=8388608,bsize=16777216,vers=3.1.1,credentials=/root/creds/nas_credentials.txt	0	0

see mount.cifs(8) - Linux man page for all the details

hope this helps

2 Likes

Thanks! On the man page I found “noperm: Client does not do permission checks.” which sounds perfect, since the file manager’s automatic mounting on the side (to the /run/user… directory) indicates that the server is happy to supply the files. I changed my fstab to add noperm and ditched the file_mode and dir_mode, it now seems to be behaving as intended. I didn’t realize “mount.cifs” was the man page to look at so thanks for pointing me in that direction.