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

EvanVanVan

Patron
Joined
Feb 1, 2014
Messages
211

TheDubiousDubber

Contributor
Joined
Sep 11, 2014
Messages
193
Try using _ instead of -.

Also, this thread is on the plex forums, https://forums.plex.tv/index.php/topic/102532-how-to-install-plex-in-a-freenas-jail/ that has other/different helpful information. One post specifically addresses your latest problem.

Thank you! This is why I love this forum. Always people willing to help out.

For the record, those of you installing PlexPass version the instructions are as follows

Now, to install Plex, run the following command:
cd /usr/ports/multimedia/plexmediaserver-plexpass/ && 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_plexpass_enable="YES" >> /etc/rc.conf

Next, start Plex with the following:
service plexmediaserver_plexpass start
 

sremick

Patron
Joined
Sep 24, 2014
Messages
323
Today I successfully migrated the database from the .PBI Plex installation to the Jail created following your tutorial.

This procedure could be done to restore the database from a backup too (e.g. from a snapshot).

Here's what I did.

Will this work even if the two versions of the Plex Media Server are not exactly the same? I'd like to try it on a test install where I started with the plug-in but now want to continue testing with the manual jail method so I can stay current w/ PMS more easily.

Plug-in is 0.9.9.13 but ports version is 0.9.13.0 (PlexPass) and I wonder about just copying the config data from the older version into the new.
 

panz

Guru
Joined
May 24, 2013
Messages
556
I don't know if PlexPass introduces "something" into the .xml conf file that could be incompatible with the .pbi plugin, so I'm not going to trust the procedure described above.
 

sremick

Patron
Joined
Sep 24, 2014
Messages
323
So after reading this thread and others, I decided to set up Plex on my new producting FreeNAS server in a jail versus using the plug-in. Everything has been working fine.

Question, though: What's the proper method for upgrading the jail itself (not Plex) when the underlying FreeNAS/FreeBSD version goes through a major update (such as to 9.3 when it comes out)? There's also the jail template. It'd be good to get some guidance on proper maintenance for those of us who go this route. :) Thanks
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
A jail is not a plugin. Plugins aren't designed to be upgraded by you (but some people do it anyway). Jails are designed to be upgraded by you as there is no automated upgrade path at all.

Plugins are easy mode. Jails are advanced mode. ;)
 

sremick

Patron
Joined
Sep 24, 2014
Messages
323
A jail is not a plugin.

I know that. :p

Jails are designed to be upgraded by you as there is no automated upgrade path at all.

...and that was my question. ;) But to be clear: I was wondering about any sort of "deeper" upgrading that needs to take place. If by "upgrading the jail" you're really just meaning "upgrading the ports running inside the jail" then I'm already comfortable with that and good to go. If the worst I need expect after a major FreeNAS upgrade (9.2 -> 9.3, or 9.3 -> 10.0) is perhaps a forced-rebuild of all the ports inside my jail, that's typical enough and I'm experienced there.
 

enemy85

Guru
Joined
Jun 10, 2011
Messages
757
Good evening,
after having my plex jail manually installed as described in the first post up and running ok for few months, today i decided to upgrade it.
I followed the OP instructions and i did
# cd /usr/ports/ports-mgmt/portupgrade/ && make install clean

# portsnap fetch update

and everything was ok, but when i did
# portupgrade -a

it started with the upgrades, but after the first couple that went ok, it ended up with this:

Code:
Found saved configuration for libiconv-1.14_4                                                                                
===>   libiconv-1.14_4 depends on file: /usr/local/sbin/pkg - not found                                                            
===>    Verifying install for /usr/local/sbin/pkg in /usr/ports/ports-mgmt/pkg                                                     
You are about to convert your system to pkg while you have ports/packages                                                          
installed with the old pkg_install tools.                                                                                          
                                                                                                                                   
To switch to pkg:                                                                                                                  
    1) Install ports-mgmt/pkg                                                                                                      
       cd ports-mgmt/pkg && make UPGRADEPKG=1 install clean                                                                        
    2) Convert your package database by running pkg2ng                                                                             
                                                                                                                                   
*** [pre-everything] Error code 1                                                                                                  
                                                                                                                                   
Stop in /usr/ports/ports-mgmt/pkg.                                                                                                 
*** [pkg-depends] Error code 1                                                                                                     
                                                                                                                                   
Stop in /usr/ports/converters/libiconv.                                                                                            
*** [stage] Error code 1                                                                                                           
                                                                                                                                   
Stop in /usr/ports/converters/libiconv.                                                                                            
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20141126-39692-1w3ih50 env UPGRADE_TOOL=portupgrade UPGRADE_POR
T=libiconv-1.14_3 UPGRADE_PORT_VER=1.14_3 make                                                                                     
** Fix the problem and try again.                                                                                                  
--->  Skipping 'devel/p5-Locale-gettext' (p5-Locale-gettext-1.05_3) because a requisite package 'perl5-5.16.3_10' (lang/perl5.16) fa
iled (specify -k to force)                                                                                                         
--->  Skipping 'devel/gmake' (gmake-3.82_1) because a requisite package 'libiconv-1.14_3' (converters/libiconv) failed (specify -k t
o force)                                                                                                                           
** Listing the failed packages (-:ignored / *:skipped / !:failed)                                                                  
        ! databases/db48 (db41-4.1.25_4)        (unknown build error)                                                              
        ! lang/perl5.16 (perl5-5.16.3_10)       (unknown build error)                                                              
        ! textproc/libyaml (libyaml-0.1.6)      (unknown build error)                                                              
        ! multimedia/plexmediaserver (plexmediaserver-0.9.9.7.429)      (unknown build error)                                      
        ! devel/libffi (libffi-3.0.13_1)        (unknown build error)                                                              
        * lang/ruby19 (ruby-1.9.3.484_2,1)                                                                                         
        * databases/ruby-bdb (ruby19-bdb-0.6.6_3)                                                                                  
        * ports-mgmt/portupgrade (portupgrade-2.4.12_1,2)                                                                          
        ! converters/libiconv (libiconv-1.14_3) (unknown build error)                                                              
        * devel/p5-Locale-gettext (p5-Locale-gettext-1.05_3)                                                                       
        * devel/gmake (gmake-3.82_1)                           


what should i do?
thanks for the help
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
You need to figure out why the failed packages failed to compile. I will warn you this won't be easy if you've never had to troubleshoot bad compiles before. ;)

That's why I use pkg-ng whenever I possibly can. Much lower chance of a failed compile if you don't have to compile it. ;)

Also, according to the error you need to get out of the old pkg system. I don't know the exact steps but if you google around you can probably find out how to do the conversion.
 

enemy85

Guru
Joined
Jun 10, 2011
Messages
757
First, thanks for the reply.
I installed the plex jail this way because i read it was then "easier" (read "less time") to upgrade compared to the plugin.
Should i try to switch to the pkg install as suggested by the upgrade failed process? (Option #1) oor convert the packkage database? (Option #2)
I'm willing to understand what the problem is and learn how to solve it, just need a little guide.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Honestly, I don't know. I started off using pkg-ng because I knew the old pkg system was going bye-bye. I've never had to do a conversion but if I were in your shoes I'd blow the jail away and do a new jail that is pkg-ng from the start. Better to use something you can trust than potentially have it appear to work and later it be broken. :P
 

enemy85

Guru
Joined
Jun 10, 2011
Messages
757
Ok, i think i'll try to mess a little bit with the conversion first, and if goes wrong i'll start again with the pkg-ng.
(I will have to destroy the jail in any case).
But i have to search and study how to install plex in a jail with the pkg-ng method, just knew that one
 

enemy85

Guru
Joined
Jun 10, 2011
Messages
757
Code:
root@plex:/ # cd ports-mgmt/pkg && make UPGRADEPKG=1 install clean                                                                 
ports-mgmt/pkg: No such file or directory.                                                                                         
root@plex:/ # pkg install ports-mgmt/pkg                                                                                           
pkg: PACKAGESITE in pkg.conf is no longer supported.  Convert to the new repository style.  See pkg.conf(5)                        
pkg: Cannot parse configuration file!                                                                                              
root@plex:/ # pkg2ng                                                                                                               
pkg: PACKAGESITE in pkg.conf is no longer supported.  Convert to the new repository style.  See pkg.conf(5)                        
pkg: Cannot parse configuration file!                                                                                              
Analysing shared libraries, this will take a while...                                                                              
pkg: PACKAGESITE in pkg.conf is no longer supported.  Convert to the new repository style.  See pkg.conf(5)                        
pkg: Cannot parse configuration file!                                                                                              
root@plex:/ #                                                                                                                      
                


as reported, none of the method suggested i found worked, so I think the only solution would be to nuke my jail and start again...
 

sremick

Patron
Joined
Sep 24, 2014
Messages
323

enemy85

Guru
Joined
Jun 10, 2011
Messages
757
following @sremick suggestion i found this link where is explained how to solve the problem and convert the database.
Here what I did:

1) deleted the packagesite line from /usr/local/etc/pkg.conf (through the vi editor);
2) # pkg install ports-mgmt/pkg
3) # pkg2ng
4) and finally # portupgrade -a

As soon as it will finish to install/upgrade all the packages, i'll see how it works (if it works...) and if everything is ok for a while, in case not, i'll nuke the jail and start from scratch as CJ suggested.
Thanks everybody for the help!!!
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Latest update to the PBI jail didn't work out so well, so have followed this guide and created my own - thanks!

Copying database across from PBI jail as we speak, so fingers crossed it just works and I can trash the old one...

ps: and it did :)
 
Last edited:
Joined
Mar 6, 2014
Messages
686
Thank you very much!

Using your excellent howto and the info in the comments, i wrote down the steps for FreeNAS 9.3:

Configure jails
First off, navigate to your FreeNAS WebUI in your browser. Click on the "Jails" button on the top bar, and in the Jails tab, click the the "Configuration" button. From there, select a "Jail Root" that is suitable to where you want your jails to be stored. Then click the Advanced button and fill in the network settings to match your environment. Do not use dhcp and choose a range that is not in your router's dhcp range/.

Create fhe jail
Still in the "Jails" tab, click the “Jails” buton and then click the "Add Jails" button.
In the popup, configure your jail name: plex
Click the “Advanced” button and theck what IP address will be assigned to the jail
Check these settings:
  • Autostart & VIMAGE: Checked (default)
  • NAT: Unchecked (default)
Then click "Ok".
The first time you create a jail, it will take some time, as some templates will be downloaded.
For more information on creating jails in FreeNAS, visit http://doc.freenas.org/index.php/Adding_Jails

Inside the jail
Once the jail is created, navigate to the FreeNAS shell prompt, either through the FreeNAS WebUI Shell or via SSH. In the shell prompt, view the currently installed jails:
jls
You should see something like this:
1 - plex /mnt/tank/jails/plex

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

First we update pkg (installed version is 1.3.7). To check the version:
pkg -v
You should see something like this:
1.3.7

Update the repository and upgrade the pkg version:
pkg update && pkg upgrade
you have to confirm several steps with typing 'y' <enter>

Check the new version:
pkg -v
You should see something like this:
1.4.0

Next, download & extract the ports tree (this includes the files to compile Plex). Since this is the first time, run the following:
portsnap fetch extract

next time, to download & update the ports tree, run:
portsnap fetch update

To be able to update the insstalled port(s) later, we install the tool portupgrade:
cd /usr/ports/ports-mgmt/portupgrade/ && make install clean
Follow on-screen instructions – just accept default values

To upgrade all ports at once, use the following:
portupgrade -a
Follow on-screen instructions – just accept default values

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

Install Plex
Now, to install Plex, run the following command:
cd /usr/ports/multimedia/plexmediaserver/ && make install clean
cd /usr/ports/multimedia/plexmediaserver-plexpass/ && 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
echo plexmediaserver_plexpass_enable="YES" >> /etc/rc.conf

Next, start Plex with the following:
service plexmediaserver start
service plexmediaserver_plexpass 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

Storage
Add storage to the jail
http://doc.freenas.org/index.php/Adding_Jails#Adding_Storage

In this example the group owner of the mounted storage is media, the ID of this group is 2000, which you can lookup in the accounts of the FreeNAS WebUI
To give plex access to this mount, you have to create the goup media, with id 2000 in the jail and add the plex user to the group. To do this, start by editing /etc/group with this command in the jail shell:
ee /etc/group

Then add this to the bottom of the file (without the line numver and dot):
Code:
media:*:2000:plex


to exit the editor, hit <Esc> and then in the menu that appears, hit <a>, you will be prompted to save the file

Now, restart the plex service:
service plexmediaserver restart

That is it, you can now add your storage in the Plex web GUI
 
Last edited:
Joined
Mar 6, 2014
Messages
686
Credits go to Cosmo_Kramer. I just altered a little bit for 9.3. But i'm glad it was of use for you! :)
 
Top