Plex for Raspberry Pi issues - Cannot find content

Actually, it was me that mentioned the find command and that was just a starting point for the debug process.

First, regardless of how you choose to proceed, I would recommend that you ensure that you have a backup copy of your drive since experimenting with the only copy you have is inherently dangerous.

I’ve never used an hfsplus formatted drive with Linux but it appears to be supported so that is not necessarily a problem. If it were me, though, I would use an ext4 filesystem as that is pretty much the de facto standard with Linux. That would require you to either repartition your existing drive (DANGER: This would result in a total loss of data, which means you need a copy of the drive before proceeding) or you could use another drive, partition and format it to use ext4 and then copy everything onto it.

Should you choose to proceed with the hfsplus formatted drive… look for a line in /etc/fstab that defines the mount point for /mnt/usb1. (fstab is what describes the drive to Linux and tells it where and how to mount it.) Most likely, you have specified ‘ro’ on that line instead of ‘rw’. To correct this, you need to edit /etc/fstab as root and change that to ‘rw’ instead (I recommend making a copy just in case you suffer fat finger syndrome.) After saving the modified file, as root, execute: “umount /dev/sda2” and then either “mount /mnt/usb1” or just “mount -a”. In theory, your problem ‘could’ be fixed at this point but, as BobSnot pointed out, possibly not if journaling is enabled. I also found this (mounting hfsplus rw on linux – rudis worklog) when I did a search for hfsplus filesytems under Linux. The dmesg command may give you a more definitive answer as to whether this is a viable alternative or not.

Speaking to the commands I gave you in my original reply, my assumption was that not all of the files/directories were owned by your account or plex so, in order to act upon ALL of them, you either needed to ‘su’ to root (which would require the root account to be defined as a login account which, by default, it is not under Linux) or you needed to prefix the commands that I gave with ‘sudo’ (which you appear to have done later, when you got the file system is mounted read-only error). The intent of the permissions that I gave you was to determine whether your problem was being caused by some combination of directory/file ownership and/or permissions. The reason for using find instead of just doing a recursive chmod is to ensure that the execute bit gets set correctly, depending upon whether the object is a directory or a file. Typically, you are going to want to have permissions of 755 on directories and 644 on files (read/write to owner and read only to everyone else for files, with the execute bit set for directories.) I intended to have you open up write permissions to directories to 777 temporarily, to see if it was an ownership problem and, later, change the permissions to 755 after any errant ownership was straightened out.

Given the above, you should consider the following when setting up the ownership and permissions of your library(ies):

  1. Out of the box, the plex account is defined as nologin, meaning you cannot directly login to it nor can you su to it, so you cannot directly issue commands using the plex account.
  2. If everything is owned by the account/group combination plex:plex (I’m betting it isn’t), you need to use ‘sudo’ (to run commands as either root or plex) to manage your files. If you are happy using sudo for every command you execute then run a recursive chown plex:plex and stop reading here.
  3. If everything is owned by an account/group other than plex:plex then you can manage your directories and files using that account but plex is going to have difficulties recording live tv and deleting files (you can allow users to do this this via settings in plex).

The caveat to #2 and #3 is if your personal account and plex are both members of the same group, all of your directories are owned by that same group and the group write bit is set on all of the directories, then both plex and your personal account (or any other account that is a member of the group, for that matter) can manage the files/directories.

The caveat to the caveat is that this applies ONLY to existing directories UNLESS you specifically manage the group ownership and group permissions of any new directories OR the setgid bit is set on the directories AND the umask in effect at the time any new directory is created is set to 002. Basically, setgid on a directory causes any directory created within it to take on the group ownership of the parent directory and the umask 002 causes directory permissions to default to 775 and file permissions to default to 664.

The caveat to the caveat to the caveat is that umask is not an absolute. It is more of a suggestion that can be overridden/ignored within scripting and/or executables, which appears to be the case with plex. Therefore, even if setgid is set on the parent directory and new directories are created with the desired group ownership, the group write bit is NOT set and only the plex account can manage the directory.

As I stated in my original reply, I have opted to keep ownership of my main (or ‘permanent’) libraries under my own account/group instead of plex:plex ownership. Doing so prevents anyone (i.e. a guest, family member, a pet randomly stepping on a remote control, etc.) from deleting any of my source files via the plex application, regardless of what the setting in plex may be set to. The only exception to this is my live tv/dvr library directories, which are under plex ownership with 777 permissions. This allows me to run a script under my own id via cron to convert the huge ts files down to a more manageable mp4 file, which is then stuffed into a recorded tv/movie library as appropriate. I opted for the wide open approach since the default umask for plex appears to be 022 and, well, I was just too lazy to figure out whether plex would respect a ‘umask 002’ command or not or where to add it if plex did. (Sorry ChuckPa, but this is a use case that contradicts you on the use of 777 permissions…) Because plex defaults to umask 022, I do periodically need to run a chmod on any new directories created by the dvr process so the scripting can manage the files within them. If anybody knows where I can add a umask 002 command and have it take effect, I would appreciate the information.

If I may comment to this?

I have never seen a reason to make plex:plex own ANY media either.

Proper application of permissions and use of groups will allow you to do anything.

There is ONE notable exception to this. When DVR records, it will be written as plex:plex unless the PMS configuration is customized.

In the toughest of configurations, use of the setuid bit or setgid bit on directories is a very powerful tool and can be employed to keep file ownership belonging to the owner (you) regardless which app may write there (contingent on the app’s group having write permission).

No worries. I was just describing how I manage permissions and why. I haven’t tried setting the umask for plex to see if it is respected or not but assuming it is, then I can simply add my account to the plex group and eliminate the need to periodically intervene with the root account. My assumption is that, if it is going to work at all, it needs to go in /var/lib/plexmediaserver/.bashrc, followed by a restart of plexmediaserver.

I caution you about changing the nologin nature of Plex to a shell account.
You’re inviting a security problem.

If you want to change something, I suggest doing it properly with a service override /etc/systemd/system/plexmediaserver.service.d/override.conf

Umask can be set in the override.

Thanks for the link. That is exactly what I was looking for. I wasn’t planning on changing plex to a login account. I was just going to create the .bashrc file and see if it worked. I don’t normally do much with systemd so the information is much appreciated.

This worked! Thank you!

Thank you @Blytsplyk and @ChuckPa and @BobSnot for all of your gracious knowledge . This was all a lot for me to take in. I am still learning. When I removed the journaling of the hard drive, everything started working perfectly.
Also, when I had edited my fstab file, I did have it set to ‘rw’ and not ‘ro’. I had reviewed this with @ChuckPa when he was helping me.
Everyones help is much appreciated

Hi @BobSnot. Last week, I had this working perfectly but now, I cannot write to the Movies folder. I can only write to the TV Shows folder that didn’t have the issue - pre me turning off journaling. The error that I get just rephrases the fact that I am trying to delete a file with “Permission Denied” at the end. I also cannot add any files to this folder. Any ideas?

verify your permissions again

find /mnt/usb1 -type d -exec chmod 777 {};

If you’re sticking with Linux, you might want to think about moving to a device with a native filesystem (e.g. ext4)

Thanks for the response.

There seems to be an error with the code?

pi@raspberrypi:~ $ find /mnt/usb1 -type d -exec chmod 777 {};
find: missing argument to `-exec'

Also, I would love to switch to a new file system but I use a Mac to load all of the content. I know that it cannot natively write to ext4 without a 3rd party app. But that’s an idea if it will solve these problems.

find /mnt/usb1 -type d -exec chmod 777 {} ;

sry, missed a \

I believe the \ was supposed to go before the ; so I ran that command.
I get this as a result. To note, there are no issues with the TV Shows folder but there are errors below for a couple of items.

pi@raspberrypi:~ $ find /mnt/usb1 -type d -exec chmod 777 {} \;
chmod: changing permissions of '/mnt/usb1/DamagedFiles': Operation not permitted
chmod: changing permissions of '/mnt/usb1/Movies': Operation not permitted
chmod: changing permissions of "/mnt/usb1/TV Shows/It's Always Sunny in Philadelphia": Operation not permitted
chmod: changing permissions of '/mnt/usb1/TV Shows/It'\''s Always Sunny in Philadelphia/Its.Always.Sunny.In.Philadelphia.S06.1080p.BluRay.x264-POW4HD[rartv]': Operation not permitted
chmod: changing permissions of '/mnt/usb1/TV Shows/It'\''s Always Sunny in Philadelphia/Its.Always.Sunny.in.Philadelphia.S07.1080p.BluRay.x264-RCSW[rartv]': Operation not permitted
chmod: changing permissions of '/mnt/usb1/TV Shows/It'\''s Always Sunny in Philadelphia/Its.Always.Sunny.in.Philadelphia.S08.1080p.BluRay.x264-ROVERS[rartv]': Operation not permitted
chmod: changing permissions of '/mnt/usb1/TV Shows/It'\''s Always Sunny in Philadelphia/Its.Always.Sunny.in.Philadelphia.S08.1080p.BluRay.x264-ROVERS[rartv]/Subs': Operation not permitted

@mercuryrsng

Which username owns the files?

If user pi (the user you’re running as), doesn’t own the file(s), you must use sudo

permissions of 777 is overkill and not how it should be done. (Media files are not executable programs)

If the drive is NTFS formatted, then you won’t be able to change permissions.
if the drive is ext4 formatted,

sudo find /mnt/usb1 -type d -exec chmod 755 {} \;
sudo find /mnt/sub1 -type f -exec chmod 644 {} \;

What do the PMS logs show?

I believe the username of Plex owns them, if I am not mistaken. Both of those commands ran without any error. However, on reboot…something not good happened. I can’t access any of the folders anymore. Every folder is showing as ‘node/x-corrupted type’ when I view its file properties …what does that mean? No files are playing…this doesn’t seem good at all. Is the drive toasted?

node-x-corrupted?

Sounds like it got shut down / unplugged before it was unmounted.

Time to unmount it and run fsck on the block device

So…I was setting this up for my brother to see if he liked the idea of Plex and how it works…I started out with a Raspberry Pi myself and have since moved on from the Raspberry Pi setup to a WD MyCloud EX2 Ultra NAS with Plex officially supported on it…and it works more beautifully than I could imagine. Tonight I had to just admit defeat with this Raspberry Pi setup and he ordered the same NAS that I have. I have never had an issue with this particular NAS and it works beautifully… I can play a 4K movie, add files to the hard drive and delete files at the same time…with no interruption in video. I can’t keep spending time going back and forth with this wonky setup that is clearly not going to work as well as the NAS.

With that being said, I am grateful for all of the help that I received from this community.

Thanks again!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.