(Tutorial) How To Install Plex in a FreeNAS 11.2 Jail

GlassVial

Dabbler
Joined
Sep 25, 2016
Messages
16
I have never had issues with upgrading a plugin. Try restarting NAS and trying again. How comfortable are you with BSD? If you have a good understanding, running Plex in a standard jail is pretty straight forward.

Already restarted when I updated it the other day (and now I have to flash my controller firmware to P21, but that's another project for another day). Not all that comfortable with BSD, most of my experience with FreeNAS is from the web browser.
 

Drew Heath

Explorer
Joined
Mar 7, 2016
Messages
80
Already restarted when I updated it the other day (and now I have to flash my controller firmware to P21, but that's another project for another day). Not all that comfortable with BSD, most of my experience with FreeNAS is from the web browser.
If you have any comfort with the command line (in any system), read the first post of this thread. The main thing you will need to do if you can get Plex running in a jail (vs the plugin) is migration of your metadata. Check this out for info: https://support.plex.tv/hc/en-us/articles/201370363-Move-an-Install-to-Another-System
 

Raheel

Dabbler
Joined
Sep 24, 2016
Messages
21
Having some problems creating libraries within Plex.
I have a Media Volume which has some folders. Lets call it MoviesFolder. I also have a DataSet called Movies in this volume.

When I point Plex to the Movies Data Set, it doesn't recognize any movies. But when I point it to MoviesFolder, it detects the movies.

The permissions for both the volume and the Dataset is the same. Can anyone help why the dataset route doesn't work?
 
Last edited:

Raheel

Dabbler
Joined
Sep 24, 2016
Messages
21
Having some problems creating libraries within Plex.
I have a Media Volume which has some folders. Lets call it MoviesFolder. I also have a DataSet called Movies in this volume.

When I point Plex to the Movies Data Set, it doesn't recognize any movies. But when I point it to MoviesFolder, it detects the movies.

The permissions for both the volume and the Dataset is the same. Can anyone help why the dataset route doesn't work?

Never mind, I figured it out!
 

JoeB

Contributor
Joined
Oct 16, 2014
Messages
121
I've just completed moving from a plugin jail to a standard jail in FreeNAS 9.10.1.

Here is what I did:

old plugin jail name: plexmediaserver_1
new standard jail name: plex


SSH into freenas.

Code:
# Stop plugin plex:
jexec plexmediaserver_1 service plexmediaserver stop

# Backup to a tar the existing plex data inc. settings etc (note the last full stop is required) :
tar cvfzp /mnt/vol1/backup/Plex-`date \+%Y-\%m-\%d`.tar.gz -C /mnt/vol1/jails/plexmediaserver_1/var/db/plexdata/ .


This creates a file on my server named '/mnt/vol1/backup/Plex-2016-10-15.tar.gz'

Change /mnt/vol1/backup/ to where you would like the tar to be placed. Note this may take a long time, several mins, and will be a few GB in size. If you have created thumbnails for videos (plex web gui -> server -> library -> Generate xxx thumbnails) it may take a very long time to complete and will be a very large file, like 10's or 100's of GB).

I then stopped the plexmediaserver_1 plugin jail to stop me editing the wrong jail by mistake (FreeNAS web GUI -> Jails -> button at the bottom).

Now I followed post #1 instructions as follows:
Create a standard jail, call it 'plex', go to advanced and set an IP address.

Now do this:
Code:
# enter new plex jail
jexec plex

# update everything, then install plex
pkg update && pkg upgrade -y
pkg install plexmediaserver

# ensure pms starts when the jail starts.
sysrc plexmediaserver_enable=YES
echo plexmediaserver_enable="YES" >> /etc/rc.conf

# Check its working before copying over the settings:
service plexmediaserver start
# go to <ip address>:32000/web and check plex is there, if it is, proceed...

# stop plex.
service plexmediaserver stop

# leave the jail:
exit

# delete any data created in the NEW jail when we test-started plex:
rm -rf "/mnt/vol1/jails/plex/usr/local/plexdata/Plex Media Server"

# extract the tar we created eariler, as before, this may take a while:
tar xCvz /mnt/vol1/jails/plex/usr/local/plexdata/ -f /mnt/vol1/backup/Plex-2016-10-15.tar.gz

#
# Go into the Freenas web GUI and recreate any storage that is
# for the plexmediaserver_1 jail, exactly the same for the 'plex' jail.
#

# start plex:
jexec plex service plexmediaserver start


Now if you go back to <ip address>:32000/web, it should be the same as it was when installed in the plugin.

Feel free to delete the plexmediaserver_1 plugin jail when you're happy it all works, and also any storage for plexmediaserver_1 using the web gui.
 
Last edited:

Raheel

Dabbler
Joined
Sep 24, 2016
Messages
21
I've just completed moving from a plugin jail to a standard jail in FreeNAS 9.10.1.

Are there any benefits for doing this?
 

JoeB

Contributor
Joined
Oct 16, 2014
Messages
121
I was having issues with the plugins showing that plex was disabled when it was in fact running, and I lost the ability to stop/start/update plex.
I backed up to tar, installed a fresh install of plex plugin, imported the tar etc and a few weeks later, the plugins screen was again out of sync with what was actually happening. Seems to happen each time I update plex for some reason...

So for me, it needed to be done. Other than that, i have no idea if there are any advantages to doing this.

I've had these issues with other plugins too, not just plex. Seems there are faults with the plugin system in freenas, or i'm just really unlucky!
 

Stephen304

Dabbler
Joined
Oct 25, 2015
Messages
16
So I tried to update since 1.2.6 came out not too long ago, but pkg says plexmediaserver-plexpass is up to date, even though I have 1.2.4 and 1.2.6 is on freshports. Do I have to wait longer or am I doing something wrong?


root@Plex:~ # pkg update
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.

root@Plex:~ # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Checking for upgrades (0 candidates): 100%
Processing candidates (0 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.

root@Plex:~ # pkg upgrade plexmediaserver-plexpass
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Checking integrity... done (0 conflicting)
Your packages are up to date.

root@Plex:~ # pkg version -v | grep plexpass
plexmediaserver-plexpass-1.2.4.2949 > succeeds port (port has 0.9.16.3.1840)
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
pkg's usually take a little longer to update than the ports. I've just updated from 1.1.4 to 1.2.6 using portupgrade -a
 

Stephen304

Dabbler
Joined
Oct 25, 2015
Messages
16
pkg's usually take a little longer to update than the ports. I've just updated from 1.1.4 to 1.2.6 using portupgrade -a
Ah, I assumed that pkg would be updated too as the freshports site shows the pkg install command on the package page, which shows 1.2.6.

Can I use freshports if I installed initially with pkg or should I just wait for pkg to be updated?
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
You can update using either method as far as I am aware, or at least I've used both on my jail successfully :D
 

Stephen304

Dabbler
Joined
Oct 25, 2015
Messages
16
You can update using either method as far as I am aware, or at least I've used both on my jail successfully :D
Thanks, it looks like doing "portupgrade -a" automatically uninstalled what I had via pkg before installing the freshports version - I'll probably just use portupgrade from now on :D
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
That might explain why it seemed to take so long this time :D I usually use pkg upgrade as I don't tend to update it so quickly, but I liked the look of some of the new functionality (specifically controlling remote bandwidth) and also tend to notice earlier now it notifies of a pending upgrade.
 

EvanVanVan

Patron
Joined
Feb 1, 2014
Messages
211
Let's say freshports is even too slow for me (There's an update available for PMS-plexpass that hasn't been updated on freshports yet), how would I go about changing the "PlexMediaServer-1.2.7.2987-1bef33a-freebsd-amd64.tar.bz2" that I downloaded from the Plex Server GUI into a installable port? Is it a complicated process and is there a tutorial for doing it?
 

Stephen304

Dabbler
Joined
Oct 25, 2015
Messages
16
Let's say freshports is even too slow for me (There's an update available for PMS-plexpass that hasn't been updated on freshports yet), how would I go about changing the "PlexMediaServer-1.2.7.2987-1bef33a-freebsd-amd64.tar.bz2" that I downloaded from the Plex Server GUI into a installable port? Is it a complicated process and is there a tutorial for doing it?

If freshports are anything like the arch linux AUR (I suspect it's the same concept), then to update manually you would have to edit the makefile and various package info files, checksum files, etc in the freshports tree to reflect the new download url, checksums, version numbers, etc, of the new update. You might also have to do some additional steps as well, and then manually build the package in the freshports tree using make. You can check the freshports git history to see how it's changed due to previous updates - I took a look before and I'm not sure how much was manual and how much was automatic, but it should give you an idea.

I personally don't think it's worth the effort unless you really want to learn all about how the package builds and how to debug it if it doesn't build properly or has random errors.
 

EvanVanVan

Patron
Joined
Feb 1, 2014
Messages
211
If freshports are anything like the arch linux AUR (I suspect it's the same concept), then to update manually you would have to edit the makefile and various package info files, checksum files, etc in the freshports tree to reflect the new download url, checksums, version numbers, etc, of the new update. You might also have to do some additional steps as well, and then manually build the package in the freshports tree using make. You can check the freshports git history to see how it's changed due to previous updates - I took a look before and I'm not sure how much was manual and how much was automatic, but it should give you an idea.

I personally don't think it's worth the effort unless you really want to learn all about how the package builds and how to debug it if it doesn't build properly or has random errors.
Definitely sounds like it's more effort than it's worth, especially since only 4.5 hrs after posting that said-update was on freshports lol. Thanks for the info though.
 

yonkoc

Explorer
Joined
Oct 26, 2011
Messages
52
How To Install Plex in a FreeNAS 9.3 Jail:

First off, navigate to your FreeNAS WebUI in your browser.

Next, click on the "Jails" button on the top bar, and then click on the "Configuration" tab.

From there, select a "Jail Root" that is suitable to where you want your jails to be stored. Then click on "Advanced Mode" to expose the network settings. Then fill in the network settings to match your environment. Then click on "Save".

Next, click on the "Jails" tab and then click on the "Add Jails" button.
From there, a window will popup with options to configure your jail. Click on "Advanced Mode".

Then select the following options:
Jail Name: plex
IPv4 Address: 192.168.x.x (Anything that isn't taken and isn't in your DHCP scope)
Autostart: Checked (default)
VIMAGE: Checked (default)


Then click "Ok".
For more information on creating jails in FreeNAS, visit: http://doc.freenas.org/9.3/freenas_jails.html#adding-jails


Once the jail is created, navigate to a shell prompt, either through the FreeNAS WebUI Shell or via SSH.
Once at a shell prompt, view the currently installed jails with the following command:

jls

You should see something like this:

Code:
JID  IP Address	  Hostname					  Path
1	-			   plex						  /mnt/Jails/plex


In this case, the plex jail has a JID of 1, so to get a shell prompt in the jail, use the following command:
jexec 1 tcsh

Next, to update the jail's packages, run the following command:
pkg update && pkg upgrade -y

Now, to install Plex, run the following command:
pkg install multimedia/plexmediaserver

Once that is complete, you need to setup Plex to start automatically when the jail starts with the following command:
echo plexmediaserver_enable="YES" >> /etc/rc.conf

Next, start Plex with the following command:
service plexmediaserver start

Plex is now ready to use and you can navigate to it with this URL:
http://192.168.x.x:32400/web

Once you tie a Plex account with your server, you will be able to access Plex internally and externally via:
https://plex.tv/web



Accessing Mounted Storage In Your Jail With Plex:
To add storage to your FreeNAS Jail, start by following this documentation: http://doc.freenas.org/9.3/freenas_jails.html#add-storage

After mounting the storage in your jail, it may be tempting to grant your files 777 access to give Plex access to them. With that said, don’t do it; there is an easy work around. Basically, you can add groups to the jail with the same GroupID as the ones on the host system.

Once at a shell prompt within the jail, find out what the GroupID is of the group that is assigned permissions on the mount with this command:
ls -l /mnt

You’ll then see a list of mount points such as this one:
Code:
drwxrwx---+ 7 1002 1001 8 Mar 3 18:35 Media


The column with 1002 is the UserID, and 1001 is the GroupID. If you want Plex to have access to the Media mount, you need need to create the Media group in the jail with a GroupID of 1001, and have the plex user in it.

To do this, run the following command (where 1001 is the GroupID):
pw groupadd Media -g 1001 && pw usermod plex -G plex,Media

After running the command, you can look at the permissions of the mount again by using:
ls -l /mnt

Now, you should see the following instead:
Code:
drwxrwx---+  4 root  Media   4 Feb 21  2014 Media


Finally, restart Plex:
service plexmediaserver restart

You are now done. Plex will now have access to the Media mount.


Upgrading Plex:

When new releases of Plex come out, you may update without losing your data and preferences. To check if a new release of Plex is available, visit this page:
http://www.freshports.org/multimedia/plexmediaserver/

First off, stop Plex with the following command:
service plexmediaserver stop

To actually update Plex, run the following command:
pkg update && pkg upgrade multimedia/plexmediaserver

Lastly, start Plex again with the following command:
service plexmediaserver start

Awesome tutorial.

I just want to give me $0.02. My setup.
My movies reside in their own dataset /mnt/NAS/Movies
Jails reside in their own dataset. /mnt/NAS/JailsRoot
Followed your tutorial up to "starting the plexmediaserver service". Felt everything was overcomplicated with users/groups after that. Here's what I did. Mounted the storage for the jail as follows:
Source was the Movies dataset (in my case: /mnt/NAS/Movies)
Destination was /media/Movies in the jail.
Mounted as read only so the jail does not end up crapping out all my Movies.
I ftp-ed into the freenas with Filezilla went into /mnt/NAS/Movies and changed permissions to ALL movie files to 604. This grants owner read/write and public (read: jail) read permissions. These are the minimum I found to allow the jail to see the files w/o modifying them. The Plex plugin pulled all the metadata. As a test I changed permissions to one of my movies back to 600 and the movie disappeared from the plex database when I re-scanned. Bringing them back to 604, movie returns. I believe that's good enough for what I'm doing but please let me know if you think there is a problem?
 

IceBoosteR

Guru
Joined
Sep 27, 2016
Messages
503
[...]
As a test I changed permissions to one of my movies back to 600 and the movie disappeared from the plex database when I re-scanned. Bringing them back to 604, movie returns. I believe that's good enough for what I'm doing but please let me know if you think there is a problem?
For the theory, this sounds good. But please consider, you have made your movies readable for everyone, because plex does access you files from the jail, and has not the permissions to access them through a group where you could use 640 to restrict the access. But I did not get this to work, maybe someone has better ideas here ;).
 

urdel62

Explorer
Joined
Nov 27, 2016
Messages
53
Hello,
Thanks for this tutorial.
I'm a bit stuck after mounting the storage.
When I run this command : ls -l /mnt in my 'plex' jail all I get is this :
upload_2017-1-9_0-3-16.png

Before that I created plex user and group in freenas, add plex user in Media group which is the group owner of the source storage of the jail.
Someone know what s wrong ?

Thanks,
 

urdel62

Explorer
Joined
Nov 27, 2016
Messages
53
Hello,
Looking for help :)
My server is on but it seems it can't access the data.
My jail is set up as follows :
- source in mnt/Storage1/Medias (in this repertory the plex repertory has been created )
- Destination in jails/plex/Destination
I created a Medias group in the jail with the user plex

Freenas setup :
- plex user and group created
- Medias storage has permission 770 with group owner Medias (containing plex user)

I can add a movie in Medias repertory but not in plex one.
And permission is denied to restart the server.
Does someone knows what s not working.

Thank you,
 
Top