Page 1 of 1

NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 8:00 am
by cmcau
I'm trying to get my "NAS" working properly - really it's a USB HDD plugged into my router that I have mounted for the Pi to access.

My ultimate objective is to get Transmission to write to the HDD directly, but I've got a more fundamental problem to fix first (maybe it's just my lack of understanding of what's going on).

As root, I can create folders and files on the NAS (folders are created with 777 permissions, files with 755)

When I login as pi, obviously I can navigate around the folder structure, but can't edit any files.

When Transmission is running (as a daemon), it has a similar problem - it can create folders and files, but the files are 755 so then it can't write to them.

The Pi is on a private network, not viewable on the internet (so security is less of an issue) ... is there a simple way around my problem ?

Basically, so that the general users (debian-transmission and pi) have write access to the files on the NAS.

Re: NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 8:19 am
by JimmyN
You have to set ownership/permissions when the share is mounted on the Pi. If you don't specify user/group/permissions in the mount command then everything belongs to root, since root mounted it. Trying to change the permissions after it's mounted doesn't work, as you have seen.
Can you show us the line you're using to mount the share?

Re: NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 8:38 am
by cmcau
Here's the contents of /etc/fstab :

Code: Select all

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
//192.168.20.1/usb0_1 /mnt/NAS cifs username=pi,password=raspberry 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
The username & password were set to a user defined on the router, but I changed it to pi/raspberry and rebooted but the problem still exists.

Re: NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 8:58 am
by cmcau
I don't know if this helps, but while I was trying some other things I ran mount (when logged in as pi) and this was the result:

Code: Select all

//192.168.20.1/usb0_1 on /mnt/NAS type cifs (rw,relatime,vers=1.0,cache=strict,username=pi,domain=BRCM-SAMBA_TEST,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.20.1,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=65536,actimeo=1)
There's a few other lines, but this is the line relating to the NAS mount

Re: NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 11:21 am
by JimmyN
The username and password are to access the drive on the router. Add a user id to the mount command so the mounted files will belong to "pi", rather than "root".

Code: Select all

//192.168.20.1/usb0_1 /mnt/NAS cifs username=pi,password=raspberry,uid=pi,gid=pi 0 0

Re: NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 11:37 am
by cmcau
Awesome JimmyN, that was what I was after, it's working perfectly now :)

Is there any way on this forum to give you some kudos ?

Re: NAS Permissions .... getting them right :(

Posted: Fri Mar 25, 2016 11:45 am
by JimmyN
cmcau wrote: Is there any way on this forum to give you some kudos ?
Thanks, but hopefully no. It would just swell my head up and then my hat wouldn't fit.