Scripted installation of Plex Media Server

I wish I hadn’t been so stubborn about sticking close to plugins in the FreeNAS GUI. This script addresses all the issues you’ve identified with the Plex plugin. Love it!

Just one observation. This is an extract from the installation notes…

$PLEX_CONFIG_PATH need not exist before running this script; if it doesn’t, the script will create it. The script will also set ownership of that directory to the user/group IDs for Plex Media Server. If this directory already exists, it must not be using Windows permissions.

When I first ran the script, I went looking for the directory in the FreeNAS GUI. It wasn’t visible. I found it through the Shell instead. I decided to destroy the created jail and remove the directory. I then created $PLEX_CONF_PATH beforehand as a dataset rather than as a directory. The advantage for me is that I can easily see the size of Plex configuration data from the GUI under Storage > Pools. I found this step useful.

EDIT: I just spotted some discussion about this further up in the thread. While I understand your concern about not creating the dataset within the script, I wonder whether the installation notes could be revised to make this point more visible?

I made it through the install without issue and everything is running. However, I can’t seem to figure out the proper permissions to the share… rather the right user/group to assign rights to. I set @everyone to read access and that worked to view movies I had uploaded. I then tried auto uploading from my phone and that only worked if I gave everyone write access. So, I know it’s a permission issue. I tried to figure out the Plex User name/id but don’t know enough about FreeBSD to know where to look. Any help would be appreciated.

Your base FreeNAS system doesn’t have a user for Plex, which means that assigning permissions will be tricky. Your best bet is to create one, with a username of plex and a user ID of 972. Then you can add permissions for that user to write to your media dataset, rather than @everyone.

Good idea. I’ve added this:

Note that if the script creates $PLEX_CONFIG_PATH, it will create it as a directory, not as a dataset. This means that it will not appear in, e.g., the Storage section of the FreeNAS GUI, where you could easily see how much space it’s using, compression ratio, etc. If you want these capabilities, you should create the dataset before running the script, and then ensure that $PLEX_CONFIG_PATH is set appropriately.

Hi, I am reading though the script, as I like to understand them before I use them, and have a couple of questions, which I hope you can answer.

  1. The command to create the Jail (line 166) has ${DEVFS_RULESET} on it. I understand the rest but not sure what this is, can you expand my knowledge please by explaining it.

  2. I think I understand that lines 195 & 198 set the Plex MetaData directory to /config, which is where you mount the dataset holding this data, is that right?

  3. Not sure what the directory /configs is used for, can you explain?

  4. The package plexmediaserver_plexpass used to be for Plex Pass users for their additional features, has this now merged into the plexmediaserver package with the plexmediaserver_plexpass just being used as a BETA now?

Thanks,
Jonathan

This is used with the hardware transcode setup.

Correct, though whether it’s a dataset or a directory is up to the user.

It’s used temporarily for files that need to be copied into the jail–pkg.conf and the package update script.

Yes. The “normal” package provides the PlexPass features if you’re signed in to a PlexPass account, and doesn’t if you aren’t. The “Plexpass” package now acts as a beta. It gives early access to some new features (at least at times), but isn’t as stable.

1 Like

Dan, thanks for the clarifications.

Jonathan

Sorry Dan, another couple of questions for you. I seem to remember that Plex said to use Ports on FreeBSD to install the server, has this now changed to using pkg? Can’t see anything on the not-so-helpful Plex.tv support page.

As I want to move my old Plex metadata do I copy it to the new metadata location before or after running the script? And do I do it before accessing the 32400/web page?

Jonathan

I don’t remember ever seeing that, and I don’t see any reason to make this recommendation–other than that the port might be slightly more up-to-date.

I’d say before running the script would be best, though I don’t think there’s a strong argument either way.

No problems, I could swear I read it somewhere :), but pkg works just as well.

Will test this out tomorrow, thanks for putting up with my questions.

Jonathan

All working, thanks Dan!

1 Like

I followed the directions, created plex-config:

JAIL_IP=“192.168.1.124”
DEFAULT_GW_IP=“192.168.1.254”
POOL_PATH="/mnt/Pool.1-3TB"
PLEX_MEDIA_PATH="/mnt/Pool.1-3TB/Media"

I put the shell script and the plex-config in the same folder and ran the script. It went off and did it’s thing and I went away and did something else for a while. When I came back, there were no errors, but the shell window of the web GUI did not seem to have any indication I had just done something.
I can see that there is a jail called pms with Release = 11.3-RELEASE-p10.
There are two mount points:

Source: /mnt/Pool.1-3TB/plex_data, Destination: /mnt/Pool.1-3TB/iocage/jails/pms/root/config

and

Source: /mnt/Pool.1-3TB/Media, Destination: /mnt/Pool.1-3TB/iocage/jails/pms/root/media

Under Storage, I see my pool structure.
Plex Pool
Which looks sort of like I would expect it to (if I knew what to expect).
On my router I can see that the IP address 192.168.1.124 is in use and I can ping it.
When I go to

http://192.168.1.124:32400/web

I get nothing. The script instructions say to log in and configure my media server, but how to do that is left as an exercise to the interested reader.

Bottom line: I can’t tell if plex is running or not.

Suggestions?

Thanks,
–Jeff

Go to the Jails page in the GUI. See if the Plex jail is there (it will be called pms for Plex Media Server), and if it’s running.

Hi Dan, thanks for chiming in here.

Plex appears to be running. I have restarted it to no avail. EDIT drops a comprehensive menu of things I could change if I understood them.

I scanned that Ip address and 32400 is not open, nor are any of the other Plex ports. I can ping it though.

Everything I read indicates it should “just work” but there is something crucial I am missing here.

Bump?
I there a guide on how to back out what I have done and re-do or follow another way of getting Plex working?

I apologize; I apparently let this slip through the cracks. So the Plex jail is running, but it kind of looks like Plex itself isn’t running. Let’s test that. From the FreeNAS shell, run iocage console pms, and once that loads, service plexmediaserver status. If it says it is not running, try starting it with service plexmediaserver start.

1 Like

No apology necessary. I appreciate the help. So, hmmm…

root@pms:~ # service plexmediaserver status
plexmediaserver does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable

I knew this command was doomed to failure, but I couldn’t help myself.

root@pms:~ # service plexmediaserver start
plexmediaserver does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable

So I went looking and indeed plexmediaserver does not exist in /etc/rc.d or /usr/local/etc/rc.d – it’s not a matter of executability, it’t not there. Maybe I should delete the jail (how?) and start over.
Other suggestions welcome. Thanks!

That does suggest something’s gone very badly wrong with the script. Just for kicks, what happens if you run (in the jail) pkg install plexmediaserver?

This is copy/paste overkill but the output is instructive:

root@pms:~ # pkg install plexmediaserver
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/latest, please wait…
Verifying signature with trusted certificate pkg.freebsd.org.2013102301… done
[pms] Installing pkg-1.14.6…
[pms] Extracting pkg-1.14.6: 100%
Updating FreeBSD repository catalogue…
[pms] Fetching meta.conf: 100% 163 B 0.2kB/s 00:01
[pms] Fetching packagesite.txz: 100% 6 MiB 627.5kB/s 00:10
[pms] Extracting pkg-1.14.6: 100%
Updating FreeBSD repository catalogue…
[pms] Fetching meta.conf: 100% 163 B 0.2kB/s 00:01
[pms] Fetching packagesite.txz: 100% 6 MiB 627.5kB/s 00:10
Processing entries: 100%
FreeBSD repository update completed. 30836 packages processed.
All repositories are up to date.
Updating database digests format: 100%
The following 1 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
plexmediaserver: 1.19.4.2935
Number of packages to be installed: 1
The process will require 367 MiB more space.
96 MiB to be downloaded.
Proceed with this action? [y/N]: y
[pms] [1/1] Fetching plexmediaserver-1.19.4.2935.txz: 100% 96 MiB 685.4kB/s 02:27
Checking integrity… done (0 conflicting)
[pms] [1/1] Installing plexmediaserver-1.19.4.2935…
===> Creating groups.
Creating group ‘plex’ with gid ‘972’.
===> Creating users
Creating user ‘plex’ with uid ‘972’.
[pms] [1/1] Extracting plexmediaserver-1.19.4.2935: 100%
=====
Message from plexmediaserver-1.19.4.2935:

multimedia/plexmediaserver includes an RC script:
/usr/local/etc/rc.d/plexmediaserver
TO START PLEXMEDIASERVER ON BOOT:
sysrc plexmediaserver_enable=YES
START MANUALLY:
service plexmediaserver start
Once started, visit the following to configure:
http://localhost:32400/web
@@@ INTEL GPU OFFLOAD NOTES @@@
If you have a supported Intel GPU, you can leverage hardware
accelerated encoding/decoding in Plex Media Server on FreeBSD 12.0+.
The requirements are as follows:
* Install multimedia/drm-kmod: e.g., pkg install drm-fbsd12.0-kmod
* Enable loading of kernel module on boot: sysrc kld_list+=“i915kms”
** If Plex will run in a jail, you must load the module outside the jail!
* Load the kernel module now (although reboot is advised): kldload i915kms
* Add plex user to the video group: pw groupmod -n video -m plex
* For jails, make a devfs ruleset to expose /dev/dri/* devices.
e.g., /dev/devfs.rules on the host:
[plex_drm=10]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add path ‘dri*’ unhide
add path ‘dri/’ unhide
add path 'drm
’ unhide
add path ‘drm/*’ unhide
* Enable the devfs ruleset for your jail. e.g., devfs_ruleset=10 in your
/etc/jail.conf or for iocage, iocage set devfs_ruleset=“10”
Please refer to documentation for all other FreeBSD jail management utilities.
* Make sure hardware transcoding is enabled in the server settings
@@@ INTEL GPU OFFLOAD NOTES @@@
root@pms:~ #

Well that looks better. Now I try and start plex:

root@pms:~ # service plexmediaserver start
Cannot ‘start’ plexmediaserver. Set plexmediaserver_enable to YES in /etc/rc.conf or use ‘onestart’ instead of ‘start’.
root@pms:~ # service plexmediaserver onestart
Starting plexmediaserver.
root@pms:~ # service plexmediaserver status
Cannot ‘status’ plexmediaserver. Set plexmediaserver_enable to YES in /etc/rc.conf or use ‘onestatus’ instead of ‘status’.
root@pms:~ # service plexmediaserver onestatus
plexmediaserver is not running.
root@pms:~ #

I am not yet out of the woods and into the Movies yet. I will spend some time tinkering later today.

Thanks.