Samba Sharing -Folder Permissions issue - Raspbian

Server Version#: 4.12.3

This isn’t exactly a Plex issue but it’s related and maybe someone has experienced it.
I am using Plex Media Server for the Raspberry Pi. I had to set up my external drives (connected to my Raspberry Pi) using this website:

The reason that I am linking that site is because it may have something to do with my situation.
I am using a Mac to connect via samba but I cannot write to any of the external hard drive folders.
When setting up samba sharing on the Raspberry Pi, here is what I added to my smb.conf file:

[Plex]
path = /disks
writeable=Yes
create mask=0777
directory mask=0777
public=no

Can anyone assist me in figuring out why I cannot write to any subfolders in the /disks folder?

Is there a user plex on the SMB server ?
IIRC, SMB needs a username when not public.

I should have also mentioned that I am a novice when it comes to Linux, still an early learner.
Can you please dumb it down for me?

This is the guide that I used to setup the smb sharing (I followed it step by step but customized my info):

The username coming from Plex is plex.
Somewhere in the SMB server account control, a username plex needs to exist.

Think of having two sign-on’s for a Windows machine; one for you and one for someone else.

In this case, SMB needs to allow for your username and for username plex or whichever username is access it from the Mac.

That makes a whole heck of a lot of sense.
I also didn’t mention that I can see files and folders when browsing on the Mac, I just cannot write to them.

How do I check the SMB server account control?

Not sure which you’ll need but a google of

Setting up smb server account

gave a number of choices which seem to be how-to & tutorial in nature.

I just noticed something that may be tied to it. I cannot actually write to any of the same folders in the file explorer on Raspbian OS. Could it be because they are in the root? Maybe that’s tied to the problem.

Without knowing intimate details of how you’ve configured things, it’s almost impossible to tell.

If the Pi is Linux, what does /etc/fstab and permissions on the base directories (before the mounts) look like?

Then,

sudo ls -la /disks

This will show top level.

Here is /etc/fstab

proc /proc proc defaults 0 0
/dev/mmcblk0p6 /boot vfat defaults 0 2
/dev/mmcblk0p7 / ext4 defaults,noatime 0 1

Addtions for external and internal drives

Mount Plex - 1 (hfsplus) at /disks/plex1 for Plexetc/fstab

UUID=e4ace203-4bd2-3de6-a6dd-d8132f6a2129 /disks/plex1 hfsplus defaults,auto,rw,nofail 0 1

Mount Plex - 2 (hfsplus) at /disks/plex2 for Plex

UUID=f343a40a-1a74-3757-88a5-3e80efb2e63d /disks/plex2 hfsplus defaults,auto,rw,nofail 0 1

a swapfile is not a swap partition, no line here

use dphys-swapfile swap[on|off] for that

Here is the sudo ls -la /disks command:

total 24
drwxr-xr-x 4 pi pi 4096 Jan 18 21:10 .
drwxr-xr-x 22 root root 4096 Jan 1 22:17 …
-rwxrw-rw- 1 pi pi 4096 Jan 18 21:10 ._.DS_Store
-rwxrw-rw- 1 pi pi 10244 Jan 18 21:41 .DS_Store
drwxrwxr-x 1 root root 16 Dec 18 19:52 plex1
drwxrwxr-x 1 root root 16 Jan 5 16:59 plex2

Here’s a quick tutorial on how those permission letters (first column) work:

drwxrwxr-x
||||||||||
|||||||||+-- Everyone can traverse the directory or execute the file (if a program or script)
||||||||+--- Everyone has no write access
|||||||+---- Everyone has read access
||||||+----- All users in the 'group'  (directory listing colume 4 'root') can traverse 
|||||+------ All users in the 'group' can write 
||||+------- All users in the 'group' can read
|||+-------- The owner can traverse or execute
||+----------The owner can write
|+-----------The owner can read

d = directory
- = file

These are encoded as octal (4+2+1) for each triplet.
This is where numbers like `777`, `755` or `644` come from. 

What you show me above:

  1. User pi owns the directory itself.
  2. User root owns plex1 and plex2
  3. User root (the super user) doesn’t need permissions but user pi does so it can’t access plex1 or plex2.

Which user name is doing the writing? pi or another username ?

In addition to @ChuckPa 's comments, in order for a journaled HFS partition to be mounted writeable on Linux, in addition to rw you must include force in your mount options. For example:

UUID=e4ace203-4bd2-3de6-a6dd-d8132f6a2129 /disks/plex1 hfsplus defaults,auto,force,rw,,nofail 0 1

It would also probably be a good idea to run fsck.hfsplus on the disks to ensure they are error free (for each disk):

sudo fsck.hfsplus -f /dev/sdaX

Where X is the partition number, and assuming it was detected as disk sda (it likely won’t be, at least for the second disk. Check the output of lsblk to see what you should use here.

Also, as Chuck alluded to, you’ll likely need to adjust your permissions for the folders to which you are mounting the disks (before and after mounting). It may be easiest to give ownership to the ‘plex’ user and then add user ‘pi’ to the ‘plex’ group.

Before mounting:

sudo usermod -a -G plex pi
sudo chown plex:plex /disks/plex1
sudo chown plex:plex /disks/plex2

After mounting:

sudo chown -R plex:plex /disks/plex1
sudo chown -R plex:plex /disks/plex2

Warning: After running the last two commands, all directories and files on the disks will be owned by ‘plex’. However, since ‘pi’ has been added to that group, it will have rwx permissions. You can also do it the other way around and give ownership to ‘pi’ and add ‘plex’ to the ‘pi’ group.

Finally, I wouldn’t necessarily recommend using hfsplus on Linux, where read/write access is needed. My own experiences with it have been mixed. It seems to like to lose its writability on a whim and fall back to read-only mode. I’ve not experienced any data errors, but I’ve not had the confidence to use it very often. My primary system is a Mac and when I need a file system to share between it and my Linux installs, I generally use ExFat. It has limitations of its own, but it is mature on both systems and well-supported, in my experience. However, if it is your goal to use the drives exclusively on Linux, it would likely be best to go ahead and format them with the ext4 file system. All existing data on them would be lost, obviously.

Thanks for the information.
When I am logging in on my Mac, I am logging in with the username Pi

Thank you I will look into this tomorrow.

So is it possible to log in through my Mac as a root user? pi is defined as my login when I log in with my Mac.

OR, can you please tell me how I could adjust my configuration so that any user can write to any folder? I have complete control over my setup so I am not worried about any users writing.
I want this process to be as simple as sending a file from my Mac to the two drives with zero limitations.

I am not opposed to reforatting my drive as ExFat either. But will I still have write permission issues in the root folders?

What is the best way to do this?

There may be something in your SMB configuration you could adjust to allow you to connect as root, I’m not sure; however, there is no need to. If you can successfully connect as ‘pi’, just adjust the permissions on the folders as I suggested above, just give ownership to that user instead.

Before mounting:

sudo usermod -a -G pi plex
sudo chown pi:pi /disks/plex1
sudo chown pi:pi /disks/plex2

And after mounting:

sudo chown -R pi:pi /disks/plex1
sudo chown -R pi:pi /disks/plex2

User pi should now have full access to the disks as should user plex, but virtue of being a member of group pi.

As for formatting your disks to ExFat, that’s up to you. It’s well-supported and portable across platforms; you could even mount it on Windows should you need to. I’d personally feel more comfortable with ExFat than hfsplus on Linux, but that’s just my opinion.

Thank you I am going to try that.
Another novice issue, I am trying to unmount the drives so I can run the first few commands, but I keep running into this issue.
How can I unmount?

Try sudo umount /disks/plex1 instead. Unless you add the user option to your mount options, only root can mount and unmount.

It says ‘Target is Busy’.
I suppose I could just power down and disconnect the hard drives…then power up without them.

That means that the mounted directory is in use. Make sure to disconnect from your Mac if haven’t already and that you don’t have any terminals open to /disks/plex1(2).

Yeah as soon as I sent that message, I realized what happened.
So now I ran everything and I can write to /disks/plex1 and /disks/plex2.

However, I can’t write to any subfolders within /plex1 or /plex2.
I keep my content in different sub folders.

Can I do that or do I need to run all of those commands above on each individual folder?