LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2019, 12:01 PM   #1
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Rep: Reputation: Disabled
Using Samba from rpi for 2 external drives, cannot get write access


If this is in the wrong location, my apologies. I have set up a rpi to utilize a lot of video and music files on two usb harddrives as a plex media server. I want to put more media on these drives from my main desktop elsewhere in my house. I set up samba and have tried to establish read and write permissions but no matter what I do, it says the folders are read-only.
I have been proud of myself setting up this rpi as it provides a lot of media on plex for me and my friends, but it would be a pain to load new media via a usb and plugging it in (down in my basement), etc. I'd rather just dump new media into the folders in my desktop's file browser.

If anyone has any suggestions how I can either a)change permissions to finally allow permanent write access to these usb drives via samba or b)change the conf file of samba to allow this, any help would be very much appreciated.
 
Old 02-24-2019, 05:38 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Show us how your samba server is configured...
Code:
cat /etc/samba/smb.conf
Just in case the following guide is useful to you...
https://howtoraspberrypi.com/create-...-pi-and-samba/
 
Old 02-24-2019, 06:37 PM   #3
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you for the response. I am not sure if it is convenient to include the full output with notations included, but I figure it's best to give the full picture. I am starting to think it's permissions for the drives themselves, but again, I am at a loss. Also thank you for the link, that's the general means I used to set it all up.

output of: cat /etc/samba/smb.conf
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
# commented-out examples in this file.
# - When such options are commented with ";", the proposed setting
# differs from the default Samba behaviour
# - When commented with "#", the proposed setting is the default
# behaviour of Samba but the option is considered important
# enough to be mentioned here
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic
# errors.

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
# wins support = no

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.
dns proxy = no

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
; interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself. However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
; bind interfaces only = yes



#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/log.%m

# Cap the size of the individual log files (in KiB).
max log size = 1000

# If you want Samba to only log through syslog then set the following
# parameter to 'yes'.
# syslog only = no

# We want Samba to log a minimum amount of information to syslog. Everything
# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
# through syslog you should set the following parameter to something higher.
syslog = 0

# Do something sensible when Samba crashes: mail the admin a backtrace
panic action = /usr/share/samba/panic-action %d


####### Authentication #######

security = user

# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone sever" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
server role = standalone server

# If you are using encrypted passwords, Samba will need to know what
# password database type you are using.
passdb backend = tdbsam

obey pam restrictions = yes

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
unix password sync = yes

# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
# sending the correct chat script for the passwd program in Debian Sarge).
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
pam password change = yes

# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
map to guest = bad user

########## Domains ###########

#
# The following settings only takes effect if 'server role = primary
# classic domain controller', 'server role = backup domain controller'
# or 'domain logons' is set
#

# It specifies the location of the user's
# profile directory from the client point of view) The following
# required a [profiles] share to be setup on the samba server (see
# below)
; logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
# logon path = \\%N\%U\profile

# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
; logon drive = H:
# logon home = \\%N\%U

# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
; logon script = logon.cmd

# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe. The example command creates a user account with a disabled Unix
# password; please adapt to your needs
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u

# This allows machine accounts to be created on the domain controller via the
# SAMR RPC pipe.
# The following assumes a "machines" group exists on the system
; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.
; add group script = /usr/sbin/addgroup --force-badname %g

############ Misc ############

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
; include = /home/samba/etc/smb.conf.%m

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
; idmap uid = 10000-20000
; idmap gid = 10000-20000
; template shell = /bin/bash

# Setup usershare options to enable non-root users to share folders
# with the net usershare command.

# Maximum number of usershare. 0 (default) means that usershare is disabled.
; usershare max shares = 100

# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
usershare allow guests = yes

#======================= Share Definitions =======================

[homes]
comment = Home Directories
browseable = yes
read only = no
writeable = yes
guest account = root
write list = pi

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = no

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directory mask = 0700

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# The following parameter makes sure that only "username" can connect
# to \\server\username
# This might need tweaking when using external authentication schemes
valid users = %S

# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
; comment = Network Logon Service
; path = /home/samba/netlogon
; guest ok = yes
; read only = no

# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
;[profiles]
; comment = Users profiles
; path = /home/samba/profiles
; guest ok = no
; browseable = no
; create mask = 0600
; directory mask = 0700

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
# Uncomment to allow remote administration of Windows print drivers.
# You may need to replace 'lpadmin' with the name of the group your
# admin users are members of.
# Please note that you also need to set appropriate Unix permissions
# to the drivers directory for these users to have write rights in it
; write list = root, @lpadmin

[public]
comment = public storage
path = /mnt
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no
writeable = yes
write = pi
guest ok = yes
write list = pi

[usbstorage2]
comment = plex content
path = /mnt/usbstorage2
valid users = @users
force group = users
create mask = 0661
directory mask = 0772
read only = no
writeable = yes
write = pi
guest ok = yes
write list = pi
 
Old 02-24-2019, 06:46 PM   #4
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Yes, Linux file system permissions do take precedence over samba permissions, so do check those as well.
 
Old 02-24-2019, 07:07 PM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
I note that you're wanting to allow guest r/w access to the public and usbstorage directories, and using 'security = user'. To access the shares defined in smb.conf make sure the relevant users exist in smbpasswd. They also need to be exist as users in the server.

A good reference...
https://help.ubuntu.com/community/Sa....28Advanced.29

Since you're also allowing guest access, you should define the guest user in the [global] section. For example
Code:
guest account = nobody
BTW, ff you have complete trust in your connecting users, this might be ok (beware the security risks of course)....

https://www.debuntu.org/samba-how-to...-userpassword/

...even if just for test purposes.
 
Old 02-28-2019, 06:51 PM   #6
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you for the response and sorry for the slow re response. Babies are demanding lol.
So I think it's the permissions for the usb drive itself. I went into the gui on the raspberry pi for my server and tried putting a new file into it and it said the same thing (folder is read-only), so i'm not sure what's going on. I think I need to use chown or something to change the permissions on the mounted drive. I am also thinking it has to do with how it's mounted, maybe changing permissions at the time that it is mounted. What can I use to test these theories? I really am not sure what to do beyond this.
 
Old 02-28-2019, 08:00 PM   #7
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Quote:
Thank you for the response and sorry for the slow re response. Babies are demanding lol.
Don't I know it....that time will pass, and they become demanding in other new ways

Quote:
What can I use to test these theories? I really am not sure what to do beyond this.
Post the share permissions eg
Code:
ls -l /path/to/share1
 
Old 02-28-2019, 08:52 PM   #8
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks again for all your help;

pi@raspberrypi:~ $ ls -l /mnt
total 36
drwxrwxrwx 1 pi pi 4096 Jan 11 2018 usbstorage
drwxr-xr-x 5 pi pi 32768 Dec 31 1969 usbstorage2
pi@raspberrypi:~ $
 
Old 03-01-2019, 01:38 AM   #9
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
The '[usbstorage2]' section of smb.conf has 'users' group configured, and the '[global]' section specifies the guest user as 'root' so the mount should match those AFAIU (refer to the Ubuntu reference I linked to in post #5)....

Code:
sudo chown -R root:users /mnt/usbstorage2
Code:
sudo chmod -R ug=rwx, o=rx /mnt/usbstorage2
 
1 members found this post helpful.
Old 03-05-2019, 04:37 PM   #10
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
ok i read through your answer and I am still confused, i'm sorry i don't have much background with all of this...

I did try the 'sudo chown...' command and that worked for a while, and i was happily transferring files but I tried again a couple days later and it was back to saying that the destination is read-only.

I tried adding into the samba conf file under global 'guest account = nobody' and still same result.

now i'm just plain confused why it's still saying that. Is it something I'm doing? not sure where to even go next...
 
Old 03-06-2019, 01:11 AM   #11
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
From the Ubuntu guide I linked to back in post #5...
Quote:
The user you specified with guest account in the [global] section must have write permissions on /path/to/share/point in order to write files to the share.
So check that is the case.
 
Old 03-06-2019, 01:20 AM   #12
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Another point that could be relevant here - Which filesystem is in use on the usb storage devices? Are you mounting via /etc/fstab? If so, show the relevant entries
Code:
cat /etc/fstab
and/or output from mount command
Code:
mount

Last edited by ferrari; 03-06-2019 at 01:23 AM.
 
Old 03-14-2019, 03:20 PM   #13
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
I thought i was using the same login credentials as I always do, when logging in directly on my raspberry pi. Same username, same password, so i'm not sure why I don't have write permissions when I log in as such. I am not sure how to ensure I have write permissions on the location under the [global] section. (also I know usbstorage is vfat, I don't really need write access for that one anyway bc it's filled to capacity anyway.)





cat /etc/fstab
proc /proc proc defaults 0 0
PARTUUID=40a9cc37-01 /boot vfat defaults 0 2
PARTUUID=40a9cc37-02 / ext4 defaults,noatime 0 1

UUID="D27431CF7431B6D7" /mnt/usbstorage ntfs nofail,uid=pi,gid=pi 0 0
UUID="D4C5-C47B" /mnt/usbstorage2 vfat nofail,uid=pi,gid=pi 0 0

# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that








mount
/dev/mmcblk0p2 on / type ext4 (rw,noatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=443724k,nr_inodes=110931,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
sunrpc on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mmcblk0p1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /mnt/usbstorage type fuseblk (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdb1 on /mnt/usbstorage2 type vfat (ro,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,er rors=remount-ro)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=89664k,mode=700,uid=1000,gid=1000)
 
Old 03-15-2019, 04:22 AM   #14
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,842

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Quote:
I am not sure how to ensure I have write permissions on the location under the [global] section. (also I know usbstorage is vfat, I don't really need write access for that one anyway bc it's filled to capacity anyway.)
Actually, your output shows that /mnt/usbstorage is using NTFS, while /mnt/usbstorage2 is VFAT. The mount output shows it is the vfat filesystem which is currently ro...

Code:
/dev/sda1 on /mnt/usbstorage type fuseblk (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
/dev/sdb1 on /mnt/usbstorage2 type vfat (ro,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,er rors=remount-ro)
As these are not native Linux filesystems, the permissions have to be faked.

https://wiki.archlinux.org/index.php...le_permissions

This will show the size and available space on the mounted filesystem...
Code:
df -h

Last edited by ferrari; 03-15-2019 at 04:25 AM.
 
Old 04-07-2019, 04:14 PM   #15
turealis
LQ Newbie
 
Registered: Feb 2019
Posts: 7

Original Poster
Rep: Reputation: Disabled
so if I do sudo nano /etc/fstab, this is the output:

GNU nano 2.7.4 File: /etc/fstab

proc /proc proc defaults 0 0
PARTUUID=40a9cc37-01 /boot vfat defaults 0 2
PARTUUID=40a9cc37-02 / ext4 defaults,noatime 0 1

UUID="D27431CF7431B6D7" /mnt/usbstorage ntfs nofail,uid=pi,gid=pi 0 0
UUID="D4C5-C47B" /mnt/usbstorage2 vfat nofail,uid=pi,gid=pi 0 0

# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that




so in the link, I believe the line that I could use to change my fstab file for each mount point is this:
/dev/NTFS-partition /mnt/windows ntfs-3g uid=userid,gid=groupid,dmask=022,fmask=133 0 0



Specifically, I think I could use 'uid=userid, gid=groupid, dmask=022, fmask=133' for each mount point.

so I suppose I would then change my fstab file to look like this instead:

UUID="D27431CF7431B6D7" /mnt/usbstorage ntfs nofail,uid=userid,gid=groupid, dmask=022, fmask=133 0 0
UUID="D4C5-C47B" /mnt/usbstorage2 vfat nofail,uid=userid,gid=groupid, dmask=022, fmask=133 0 0


Do you think this could allow access to these mount points, then, when using samba/ftp via other computers?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I can browse internet, but no access to names or addresses on lan. Rpi mike.adams Linux - Networking 15 07-26-2015 11:50 AM
RPi using ALSA-based SHAIRPORT cannot see sound card(s) JimfromIndy Linux - Newbie 3 07-25-2015 01:37 PM
LXer: Mini-PC taps RPi Compute Module and supports RPi 2 LXer Syndicated Linux News 0 02-22-2015 03:03 PM
Ubuntu 8.04 in windows network cannot get write access for all samba shares cliffsur Linux - Newbie 6 09-18-2008 12:29 PM
Windows cannot detect external hard drive, linux cannot write to it. HappyChickenFreak Linux - Hardware 1 01-28-2007 05:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration