Permission issues with Samba


8 posts
by arehexes » Wed Oct 31, 2012 11:02 pm
So I set up my Raspberry Pi as a samba server to soon use as a means to make a center place for all my hard drives (movies/music/games/code). I can get Windows to see the flash drive as a network drive i'm using as a test for now but I can't write to it.

I decided to test this and I can't "echo 'hi there' > /media/usbstick/text.txt" without permission errors (the folder owner is root) even with sudo.

Anyone have any ideas? (also the usb stick is FAT32).
Posts: 10
Joined: Tue Sep 18, 2012 12:11 am
by obcd » Thu Nov 01, 2012 10:27 am
I assume you added some stuff to the /etc/samba/smb.conf file to share the usb drive.
Somewhere in it, you have a create mask and directory mask.
Setting that to 775 and restarting samba usually fixes such issues for me.
I have no idea how bad this is for security.
Since you seem to be able to access the shared drive, I assume security=user is set in that file,
and the proper samba user accounts are created.
Posts: 890
Joined: Sun Jul 29, 2012 9:06 pm
by bredman » Thu Nov 01, 2012 10:41 am
This has nothing to do with Samba, it is caused by the fact that FAT drives do not support the concept of Linux file permissions.

To mount a FAT drive, you need to define the owner of the drive at mount time. For example, using the parameters uid=pi,gid=pi will allow the user pi to write to the drive.
Posts: 1413
Joined: Tue Jan 17, 2012 2:38 pm
by obcd » Thu Nov 01, 2012 12:05 pm
So you are saying that he wasn't able to create a file on the drive locally from within linux as well?
In that case I agree. Still, those settings in smb.conf make a difference as well.
What's the point in creating a folder if you can't write anything into it?
Posts: 890
Joined: Sun Jul 29, 2012 9:06 pm
by bredman » Thu Nov 01, 2012 1:08 pm
obcd wrote:So you are saying that he wasn't able to create a file on the drive locally from within linux as well?

If you look at the original post, he cannot write from windows (samba) and he cannot write from the RPi (mounted drive).
Posts: 1413
Joined: Tue Jan 17, 2012 2:38 pm
by obcd » Thu Nov 01, 2012 9:36 pm
no idea how I could have missed that. My mistake.
Posts: 890
Joined: Sun Jul 29, 2012 9:06 pm
by jesusdf » Thu Nov 01, 2012 10:11 pm
Make a folder for this mount point:

mkdir /mnt/usb

On fstab you need to add something like this:

/dev/sda1 /mnt/usb vfat relatime,defaults,uid=1000,gid=1000 0 0

On smb.conf, you can allow anyone write permissions (security=share and setting guest user=pi), or make it read only, or use the users security system (look for smbpasswd documentation).
User avatar
Posts: 6
Joined: Thu Nov 01, 2012 8:54 pm
by arehexes » Fri Nov 02, 2012 3:29 am
Yeah I found out FAT isn't good today while on break at work so I changed the drive to NTFS, this worries me cause my main media drive is FAT32...might get a new one to copy to and use the old one as a back up :/
Posts: 10
Joined: Tue Sep 18, 2012 12:11 am