Cyberon.org - Notebook


Plex icon

Installation of Plex Media Server in a TrueNAS Jail.

Revised on: September 16, 2024


It's pretty straightforward to install Plex Media Server (PMS) in a TrueNAS jail. However despite being located in a jail, PMS needs to have access to the folder in the TrueNAS root where you keep your movies. As example it might be the folder /mnt/name_of_your_zfs_pool/downloads. That's why we will allow the jail to mount that folder 'downloads' on a folder in the jail, for example the folder /media.
In order to configure PLEX, you need to have a (free) PLEX account. I'll explain how to get one and how to point the Plex Media Server to this media folder.

This is how it's all done:

  1. Creation of a new jail for Plex Media Server.
    As we speak, my server is running TrueNAS core 13.0-U6.2. As an example let's assume your WiFi router has IP4 address 192.168.0.1 and you want to give your new jail the name PLEX  with IP4 address 192.168.0.99. Take care to change these addresses in accordance with your own (WiFi) network.
    To create a new jail, open TrueNAS, go to Jails and click Add. In the new screen click "Advanced Jail Creation".
    Make the following changes under the various headings:
    Basic Properties:
       Name: PLEX
       Jail Type: Default(Clone Jail)
       Release: select the latest
       Checkmark VNET
       vnet_default_interface: auto
       IPv4 interface: vnet0
       IPv4 Address: 192.168.0.99
       IPv4 Netmask: 24
       IPv4 Default Router: auto or 192.168.0.1
       IPv6 Default Router: auto
       
    Jail Properties:
       allow_set_hostname: put a checkmark
    			   
    Network Properties:
    	interfaces: vnet0:bridge0
    	host_hostname: PLEX
    	resolver: etc/resolv.conf
    	ip4.saddrsel: checkmark
    	ip6.saddrsel: checkmark
    	ip4: New
    	ip6: New
    			   
    Custom Properties:
    	checkmark host_time
    			   
    Click SAVE.
    If everything is OK you will find your new PLEX jail under Jails. Click ">" at the end of the line and start the Jail. After a successful start you may open it's Shell.
  2. Installation of Plex Media Server in the new TrueNAS Jail.
    Open the shell of the new PLEX jail and type the following commands:
       - pkg
       - pkg install nano
       - pkg install plexmediaserver
       - sysrc plexmediaserver_enable=YES
    

    The sysrc command enables automatic start of the plexmediaserver each time you restart the jail. Type
    - service plexmediaserver start
    and open in the browser on your Mac or PC the address of the PMS jail. In my case http://192.168.0.99:32400/web. You should see the PMS GUI webinterface. Don't login yet, but return to the PLEX jail shell and type exit.
  3. Mounting the download folder in the root on /media in the jail.
    Stop the jail and click MountPoints -> Actions -> Add.
    In the GUI that opened, click under 'Source' /mnt, click your zfs pool and click downloads. Under 'Destination' click media. Click SUBMIT, check if the result is as expected, if so click Jails, start the PLEX jail and open it's Shell.
    Enter the following commands:
       - cd /media
       - ls
    
    and you should see the content of the folder download in the root.

  4. How to update Plex Media Server in the jail.
    To update the Plex Media Server we will use a shell script in the jail. It's a script that can be downloaded from github.  Open the shell of the PLEX jail and execute the following commands:
    $ cd /usr/local/plexdata
    $ fetch https://raw.githubusercontent.com/mstinaff/PMS_Updater/master/PMS_Updater.sh
    $ sh PMS_Updater.sh -v -a
    
    Upon execution of the last command, Plex Media Server will be updated.
    If lateron the PMS GUI indicates there is another update available, you only have to execute these two commands in the PLEX Jail:
    $ cd /usr/local/plexdata
    $ sh PMS_Updater.sh -v -a

  5. Get your free Plex account and configure your PMS.
    Getting your account:
    To create your free Plex account, open https://www.plex.tv/sign-up in your browser. Login with an email address and a new password. Upon completion, Plex will send an email to verify your address.
    Configuration of your PMS:
    Open PMS in your browser and sign in with your account. Click 'More' at the left and click the wrench at upper right to open 'Settings'. In the column left go to 'Manage' and click 'Libraries'. Click 'Films' and add your /media folder as Library. Click Save and open the Home screen of PMS. Under PLEX click 'Films' and there they are!