SMB permissions issue

Riffy

Cadet
Joined
Jun 1, 2023
Messages
8
I am just a bit confused right now about what I assume is a permissions error with my SMB share. I can mount it and connect to it fine on my ubuntu machine however I can only write to it if I sudo and get a permissions issue if I try anything as myself. I have myself in the permissions group on truenas scale as both uid and gid. Does my user need to be the owner to write to it? I thought they just had to be added to the permissions list and have smb login turned on?
 

asap2go

Patron
Joined
Jun 11, 2023
Messages
228
I am just a bit confused right now about what I assume is a permissions error with my SMB share. I can mount it and connect to it fine on my ubuntu machine however I can only write to it if I sudo and get a permissions issue if I try anything as myself. I have myself in the permissions group on truenas scale as both uid and gid. Does my user need to be the owner to write to it? I thought they just had to be added to the permissions list and have smb login turned on?
Question:
Is your user in the group root and did you set root in the ACL for the dataset? (I had the same issue you have when I did that for testing under windows)
 

Riffy

Cadet
Joined
Jun 1, 2023
Messages
8
Question:
Is your user in the group root and did you set root in the ACL for the dataset? (I had the same issue you have when I did that for testing under windows)
Root is owner of the dataset I am testing with and my user is just a user under the permissions but with full access. However the user itself is not in the root group, should I do that?
 
Joined
Oct 22, 2019
Messages
3,641
How are you mounting the SMB share on your Ubuntu client?
 
Joined
Oct 22, 2019
Messages
3,641
sudo mount -v -t cifs //192.168.10.150/test /mnt/truenas -o credentials=/etc/samba/smbcredentials
Include the parameters for the local user and group, and even permissions.

Something like this:
Code:
uid=1000,guid=1000,file_mode=0640,dir_mode=0750
 

Riffy

Cadet
Joined
Jun 1, 2023
Messages
8
Include the parameters for the local user and group, and even permissions.

Something like this:
Code:
uid=1000,guid=1000,file_mode=0640,dir_mode=0750
I was about to test this but I wanted to just clear up something. My default test user on truenas is uid3000 and gid3000 would I replace the 1000/1000 to 3000/3000 or just change the testing id to 1000?
 
Joined
Oct 22, 2019
Messages
3,641
You want to use the ID (or name) of the user and group on your local Ubuntu client. If the user/group on Ubuntu is 3000/3000, then yes, you would use that. However, if the local user/group on Ubuntu is 1000/1000, you would use that. So it's all about the Ubuntu system.
 

Riffy

Cadet
Joined
Jun 1, 2023
Messages
8
You want to use the ID (or name) of the user and group on your local Ubuntu client. If the user/group on Ubuntu is 3000/3000, then yes, you would use that. However, if the local user/group on Ubuntu is 1000/1000, you would use that. So it's all about the Ubuntu system.

Okay I think I see the issue then, let me make a truenas user with uid and gid 1000 to match the ubuntu user and try mounting it then and see if I can read/write as a normal user and not needing sudo.
 
Joined
Oct 22, 2019
Messages
3,641
For NFS? Sure, but you're using SMB. You don't need to match UIDs. (Think about Windows clients. How would they match the Unix UID on their local Windows user account? :wink:)
 

Riffy

Cadet
Joined
Jun 1, 2023
Messages
8
For NFS? Sure, but you're using SMB. You don't need to match UIDs. (Think about Windows clients. How would they match the Unix UID on their local Windows user account? :wink:)

Well that looks to be working, I can create and edit files as myself and not as root so this should work for my plan of a share to let docker containers use. Now my next question if you don't mind is how to get it to auto mount on boot, just fstab I assume? Also is NFS better than SMB? Every time I ask about this people are very firmly in one camp or the other without any real answer.
 
Joined
Oct 22, 2019
Messages
3,641
Now my next question if you don't mind is how to get it to auto mount on boot, just fstab I assume?
You can use the fstab, but include some systemd parameters so that it will cleanly automount whenever you attempt to access the share. (Otherwise, if for some reason the share/server is unrechable, it will hang.)

You can set your own timeout and idle settings.

An example:
noauto,nofail,x-systemd.automount,x-systemd.requires=network-online.target,x-systemd.device-timeout=15,x-systemd.idle-timeout=600

The 15 is to wait 15 seconds before giving up on attempting to connect. The 600 is to wait 10 minutes of idle (no activity) before automatically unmounting.

So wherever your mount path is, anytime you try to access it, it will automatically mount. Keep in mind that many applications will access the folder, such as "Recent locations" or "Photo editing programs", etc. It doesn't matter: anything that tries to access it will trigger an automount, even if you don't manually browse to the folder.
 
Last edited:

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
Well that looks to be working, I can create and edit files as myself and not as root so this should work for my plan of a share to let docker containers use. Now my next question if you don't mind is how to get it to auto mount on boot, just fstab I assume? Also is NFS better than SMB? Every time I ask about this people are very firmly in one camp or the other without any real answer.
I tend to use autofs as it only keeps it active when needed. Used it for 10 years now. I've not used the systemd method, not sure if either is better or not. autofs is old and reliable to me. Hard to teach old dog new tricks!

@winnielinnie have you used autofs and care to comment on differences?
 

anodos

Sambassador
iXsystems
Joined
Mar 6, 2014
Messages
9,553
The `noperm` mount option can be helpful for avoiding spurious permissions issues from kernel SMB client (there can be issues trying to impose a richer permissions model onto linux VFS). See man mount.cifs for more info.
 
Joined
Oct 22, 2019
Messages
3,641
@winnielinnie have you used autofs and care to comment on differences?
I used to used autofs until I switched to the systemd method.

It’s pretty much the same experience, but “the newer way” to automount. You can either use separate units or integrate it in your fstab. (Like with the example above.)
 
Top