Table of Contents

FreeNAS - Plex - Install Plex in a Jail

Navigate to Jails → Configuration.

Select a Jail Root that is suitable to where you want your jails to be stored.

Fill in the network settings to match your environment.

Navigate to Jails → Add Jails.

A window will popup with options to configure your jail.

Select the following:

Click “Ok”.

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:

1 - plex /mnt/tank/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 download the ports tree (this includes the files to compile Plex), run the following:

portsnap fetch extract

Now, to install Plex, run the following command:

cd /usr/ports/multimedia/plexmediaserver/ && make install clean

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:

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/index.html

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/index.php/Adding_Jails#Adding_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:

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, start by editing /etc/group with this command:

ee /etc/group

Then add this to the bottom of the file:

Media:*:1001:plex

After saving the file, you can look at the permissions of the mount again by using:

ls -l /mnt

Now, you should see the following instead:

drwxrwx---+ 7 1002 Media 8 Mar 3 18:35 Media

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

NOTE: If Plex cannot access your mounts after properly setting up your permissions, it may need to be restarted with the following command:

service plexmediaserver restart

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 via ports, visit this page: http://www.freshports.org/multimedia/plexmediaserver/ 51

To upgrade Plex, first install a tool called portupgrade with this command:

cd /usr/ports/ports-mgmt/portupgrade/ && make install clean

When configuration dialog boxes appear, accept the defaults.

Next, you have to update the FreeBSD port tree with this command:

portsnap fetch update

Then to upgrade all ports at once, use the following:

portupgrade -a

Alternatively, you can have portupgrade prompt you before upgrading each port with this:

portupgrade -ai

Afterwards, your ports, including Plex, should be up to date.


References

Information on creating jails in FreeNAS

https://forums.plex.tv/t/how-to-install-plex-in-a-freenas-jail/60641/4