Problem with permissions on a mounted SMB share

feo

Honorary Master
Joined
Jan 22, 2006
Messages
13,722
Reaction score
109
Location
Pretoria, South Africa
OK so long story short...

I have a raspberry pi with Raspbian on it. I automount a folder from my NAS on startup (by editing the fstab file) but the problem is the owner is root.

e.g drwxr-xr-x 1 root root 0 Nov 26 19:28 NAS

Now I have a service running that will periodically try to move folders/files from the raspberry pi into the mounted NAS folder but because of the permissions (I think) it can't move it.

How do I change the permissions on /media/NAS (and all subfolders) so that anyone can read from and write to it?

Sorry if this is a dumb question but I've literally been using Linux for a week only.

PS. sudo chmod -R 777 /media/NAS doesn't work...it just has no effect whatsoever...

HELP!
 
append
noatime,user,exec,dev,suid,gid=users,umask=000 0 0
to permit anyone to write to that mounted directory. You may need a , first if you already have other options set.
 
Last edited:
maybe root does not have ownership but i think it would have told you. "Permission Denied"

you take ownership using chown
 
append

to permit anyone to write to that mounted directory. You may need a , first if you already have other options set.

I used a line in fstab like this:

Code:
/home-server-ip/path/to/folder /path/to/mount cifs

So it should be something like:

Code:
/home-server-ip/path/to/folder /path/to/mount cifs,uid=something,gid=something

Correct?

I'm using Raspbian so I need help with the exact syntax.
 
Have a look at: http://www.samba.org/samba/docs/man/Samba-Guide/
On the samba server, you can create a user/group that have access to the shared path.
If you look at the link, and the "No frills ..." example, then you see that they share a path with the following options.
Code:
force user = abmas
force group = office
This means the samba process will write to this share using this credentials.

If you set up your system according to the closest example, then you should get it working.
If you have troubles, post your global and share portion of the smb.conf file.
 
Have a look at: http://www.samba.org/samba/docs/man/Samba-Guide/
On the samba server, you can create a user/group that have access to the shared path.
If you look at the link, and the "No frills ..." example, then you see that they share a path with the following options.
Code:
force user = abmas
force group = office
This means the samba process will write to this share using this credentials.

If you set up your system according to the closest example, then you should get it working.
If you have troubles, post your global and share portion of the smb.conf file.

I'm a complete n00b so that link scares me.

I'll post my config when I'm home a bit later but for now, I just need to know if I can mount an SMB but giving read, write and execute access to ANYONE.

That will solve all my problems...
 
Have you done the necessary mods to smb.conf? Changing fstab is not going to help you if smb.conf is not setup properly.
 
try this. *Just a test*


Make a backup of your current smb.conf file normally found in /etc/samaba/smb.conf

Make a new smb.conf file and paste the following into it and then save.

then change the path = to the path where drives are normally mounted.

Code:
security = users

[share1]
comment = This is a test share
path = /media/vol1
writable = yes
browsable = yes

then run chmod 777... on the folder which you are sharing

add you linux user to samba.
Code:
smbpasswd -a linuxusername


Then in the prompt type
Code:
 sudo smbd restart
or
Code:
sudo samba stop
then
Code:
sudo samba start

then go to the link from windows \\linuxservername\sharename (share name = the name you specified in smb.conf in the above example it will be \\linuxservername\share1

when it asks for the password then enter the servername\linuxusername and then the linux username password
 
Try giving the user ownership of the mount with the chown command.
As root user execute:

chown "newOwner":"optionalGroup" /media/NAS
 
I used a line in fstab like this:

Code:
/home-server-ip/path/to/folder /path/to/mount cifs

So it should be something like:

Code:
/home-server-ip/path/to/folder /path/to/mount cifs,uid=something,gid=something

Correct?

Seems fine.

But lets go through the whole setup. I'd setup the smb.conf on the server pc:
Code:
.
.
security=user     /*the default setting is fine too*/
.
.
[NAS]
     path = /path/to/dir
     valid users = username
     read only = no    /**writeable=yes would work, but i don't like that grammar:P**/
     guest ok = no     /**or yes, depending on your preference, but then read only=yes would do for me**/

Now if you use the valid users option, in terminal:
Code:
sudo chown username:username /path/to/dir

In client pc's fstab:
Code:
//home-server-ip/NAS /path/to/mount cifs username=username,password=password,uid=1000,gid=1000
As I'm not too worried about security, I'd put the username and password in the fstab. An alternate way is to write a text file, say smbcredentials.txt, and use that file in the fstab line (forgot the syntax, but easily google-able). The uid=1000 is usually (for *buntu that is) the uid of the user account set during installation. If you would like a different user account to have permissions, on the client pc:
Code:
id otheruser
get it's uid, and use that in the fstab.

Will test on a VM (have to set one up for computations later) and let you know.

On another note, I'm thinking since you want to copy files from the raspi to the main server periodically, why not try a cronjob (scheduled) rsync without the --delete option? That's one of the fun things of *nix, plenty of interesting ways to do just about anything.

Even better, an NFS export would work without you needing to deal with permissions. Same as samba, but the uid of owner of server folder is writeable by client pc's user with the same same uid.
E.g. Say 'jack' (with uid=1736) is owner of folder '/srv/pirates' on server pc and you export (share with network) that folder, then client pc's user 'sparrow' with uid=1736 can write to the mounted folder. No permissions need to be set, you just need to make sure of common uid's.

Ok I've been rambling too long

Update: tested it, and it works. For some reason couldn't take a screenshot in my VM :(
 
Last edited:
Sorry for such a late reply but I edited the fstab file to the following which works (root is still the owner but everyone has permissions to do everything in the share):

Code:
//192.168.0.102/TV\040Shows /media/NAS cifs username=admin,password=admin,file_mode=0777,dir_mode=0777 0 0

I tried the uid and gid option of the owner who I want to give write access to and sure enough, it mounts with that user as the owner.

So both these options work.
 
Top
Sign up to the MyBroadband newsletter
X