So I have an HDD mounted to /mnt/plex1. All folder inside that mount are owned by my main USER. Permissions were set to 755, but I wanted to change it so that plex could create optimized versions. I added user plex to my USERGROUP thinking that I could then set the permissions to 775 and everything would work beautifully…
So I added user plex to my usergroup:
sudo usermod -a -G USERGROUP plex
Then I checked if it worked:
groups plex
plex : plex video USERGROUP
It did.
I decided to start with one folder and see if it works:
sudo chmod -R /mnt/plex1/folder 775
I checked permissions with ls -al and everything seemed ok, but Plex still says it can’t write.
Then I set permissions to 777, and it worked, but that’s not the way it’s supposed to work.
Interestingly, when I set permissions back to 775 it could still convert files that were in the same directory. In other words, it was able to write to the directory ‘Plex versions’ which was created when permissions were set to 777.
So my question is, why can’t plex create new directories when permissions are set to 775?
Permissions on the mount point directory (plex1) with the disk unmounted is 777.
Permissions with the disk mounted (now permissions are in the mounted FS itself).
Best method here is to control with the setuid and setgid bits
Your username owns it, group plex has write permission.
Therefore, chown -R your-name:plex /mnt/plex1
followed by enabling the setuid and setgid bit flags for the directories (which will control how the files are created)
This works for just about anything… DVR, converting, whatever you wish
I’m currently trying to set it up, but I can already see that this is exactly what I need. I will post when/if I get it working.
One quick question though.
Would it be correct to say that these two commands would accomplish the same thing if the files are already owned by user named USER?
Yes it would accomplish the same IF already owned by $USER, however chown sets BOTH fields depending on argument 1 whereas chrp exists to change only the group.
Re: Question 2:
Plex’s primary group is plex. Being a member of group xxx means it has limited permissions.
setuid and setgid guarante owner and group are assigned specifically and independent of the umask of the writing process.
Thanks again. I thought this is gonna be easy, lol. I ran into a problem. Specifically concerning this command: sudo find ./mnt/plex1/kaledos1 -type d -exec chmod g+s {} \; find: ‘./mnt/plex1/kaledos1’: No such file or directory
Then I’ve tried: sudo find .//mnt/plex1/kaledos1 -type d -exec chmod g+s {} \;
and got the same error.
I then ran: sudo find /mnt/plex1/kaledos1 -type d -exec chmod g+s {} \;
and got no errors. So I’m assuming that dot before slash is a typo?
The problem is that it didn’t really work. plex still can’t write optimized versions to /mnt/plex1/kaledos1 or it’s subdirectories.
What I did before that:
Created new group ‘media’
added users plex and myuser to the group media
chown -R /mnt/plex1/kaledos1 myuser:media
You do need to understand that . refers “This, the current, directory”. (Current directory relative addressing)
If the pathname begins with /, then you really are referring to the top. (absolute addressing)
In all this, there is one other possible solution. This might actually be easiest for you as you learn linux.
Switch Plex to use your username. When it runs as your username, it’s now identical to Windows. Problem of ownership is moot. If your GUI / username can read/write the media, so will Plex.
Thanks for this suggestion. I’ll keep that in mind. In the meantime, I decided to instead of using my newly created group to change the group to plex, like in your original tutorial. Lo and behold. It worked! Now I would really like to know why it worked? Ot rather why my newly created group didn’t work?
I checked and both my-user and plex definitely belong to the new group. What could be the problem? Not that I really need to know, but I’m just curious.
Oh and btw, I did check if newly created files and folders inherited my newly created group ownership and they did. The configuration was the same as with plex group. There’s something else I’m missing.
Yes, you’re probably right. Obviously, as a complete Linux noob, I’m in no position to argue with you, but could it be that most people stop after the first method (assigning the group ‘plex’) and don’t create new groups?
The interesting thing I find is that even when chgrp -R plex /directory, instead of my new group(e.g. media), and set chmod g+s per your instructions, I still have to set permissions to 775, otherwise it doesn’t work, but it seems that in your example permissions are set to 755?
I found it. Thank you for sticking with me on this. When the process was updated, there was an oversight.
This additional information is applicable to satisfy your need.
Supplemental:
In the above example RWX (755) permissions were granted solely to the owner (chuck). Should you also wish to grant RWX permission to the group to allow both your username and Plex to write, you will need two additional changes.
The permissions for all directories set to 775 first
Your Plex configuration needs its default Linux umask changed to be 0002 (default is 0022). To change umask, please see “Customizing your Plex configuration”.
Omg, I’m such an idiot. I should have read it fully befofe asking! Thanks again, Chuck.
Btw, it seems like you’re a bit of a lone wolf here on this forum. Not much interaction from Plex in the player department, unfortunately. Kudos to you for actually helping users.