Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Step by step to install Plex & Transmission inside iocage Jail in FreeNAS 11.2-BETA3

Bibi40k

Member
Joined
Jan 26, 2018
Messages
120
Hi,
i decided to add a new tutorial to help us all create and maintain an Iocage Media Jail with Plex & Transmission.
I personally use VPN all the time, even to connect to my Plex server so i also recommend to you my first tutorial Step by step to install OpenVPN inside a Jail in FreeNAS 11.1-U1.
Please report inconsistency.
change-log: 0.3 - 2019.05.23 - make default transmission download dir configuration permanent (thanks to @itskando).
0.3 - 2019.05.23 - make default transmission download dir configuration permanent (thanks to @itskando).
0.2 - 2018.10.17 - adjusted fstab -a command so it can accepts path with spaces.
0.1 - 2018.10.16 - First release.
Note: I use ftp group because my media folder is also accessible via FTP.
Legend:
  1. Green text - should remain like it is
  2. Blue text - you may change it if you like
  3. Red text - needs to be changed by you
Requirements:
  1. FreeNAS 11.2-BETA3 ( may work with other versions either )
  2. FreeNAS User with ssh access and sudo
  3. SSH Client ( Putty for Windows and Terminal for MAC )
  4. Admin access to the router where FreeNAS exists
  5. Please follow this step by step tutorial before ask for help
Relevant data to use later in this tutorial ( use your own, this is just for reference )
  1. Home Network: 192.168.1.0/24 ( LAN where is your FreeNAS )
  2. Warden Jail (old one): MediaJail
  3. Iocage Jail (new one): Media
3,2,1.. START
First, we become root

Code:
% sudo -i
Password:
Warning: settings changed through the CLI are not written to
the configuration database and will be reset on reboot.

Then, we check UID and GID of media and ftp users (they are always the same, but i want to be as verbose as i can)
Code:
# getent passwd | cut -d':' -f1,3-4 | grep -E 'media|ftp'
ftp:14:14
media:8675309:8675309

We're ready to create our new Iocage Media Jail and map our existing Media folder inside.
Code:
# iocage create -n "Media" -r 11.2-RELEASE vnet="on" ip4_addr="vnet0|192.168.1.55/24" defaultrouter="192.168.1.1" boot="on"
Media successfully created!
* Starting Media
  + Started OK
  + Configuring VNET OK
  + Starting services OK
# iocage fstab -a Media "/mnt/Vol1-Z2/FTP" "/mnt/FTP" nullfs rw 0 0
Successfully added mount to Media's fstab

Now that the Jail is up and running, we go inside, update everything and install what we need.
Code:
# iocage console Media
...
Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier
Edit /etc/motd to change this login announcement.
# env ASSUME_ALWAYS_YES=YES pkg bootstrap
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[Media] Installing pkg-1.10.5_3...
[Media] Extracting pkg-1.10.5_3: 100%
# pkg update
...
Processing entries: 100%
FreeBSD repository update completed. 32565 packages processed.
All repositories are up to date.
# pkg upgrade -y
...
Checking integrity... done (0 conflicting)
Your packages are up to date.
# pkg install -y nano wget plexmediaserver transmission
...
Once started, visit the following to configure:
http://localhost:32400/web
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

We create the media user and add it to the ftp group.
Code:
# getent group | cut -d':' -f1,3-4 | grep -E 'media|ftp'
ftp:14
# pw useradd -n media -w none -u 8675309 -G ftp -c "Media User"
# getent group | cut -d':' -f1,3-4 | grep -E 'media|ftp'
ftp:14:media
media:8675309
# id media
uid=8675309(media) gid=8675309(media) groups=8675309(media),14(ftp)

We configure Plex.
Code:
# cd /usr/local && mkdir plexdata
# chown -R media:ftp plexdata
# sysrc plexmediaserver_enable=YES
plexmediaserver_enable:  -> YES
# sysrc plexmediaserver_user=media
plexmediaserver_user:  -> media
# sysrc plexmediaserver_group=ftp
plexmediaserver_group:  -> ftp
# service plexmediaserver start
Starting plexmediaserver.
# cd /usr/local/plexdata/Plex\ Media\ Server/Plug-ins
# wget https://github.com/ukdtom/WebTools.bundle/releases/download/3.0.0/WebTools.bundle.zip
...
2018-10-16 21:21:22 (401 KB/s) - 'WebTools.bundle.zip' saved [5899909/5899909]
# unzip WebTools.bundle.zip
...
   creating: WebTools.bundle/http/static/logs/Directive/logFileDisplay/
 extracting: WebTools.bundle/http/static/logs/Directive/logFileDisplay/logFileDisplay.js
# rm WebTools.bundle.zip
# chown -R media:ftp WebTools.bundle
# service plexmediaserver restart

...and Transmission.
Code:
# cd /usr/local/etc
# chown -R media:ftp transmission
# sysrc transmission_enable=YES
transmission_enable:  -> YES
# sysrc transmission_user=media
transmission_user:  -> media
# sysrc transmission_group=ftp
transmission_group:  -> ftp
# service transmission start
Starting transmission.

Edit Transmission settings & make default download dir permanent.
Code:
# service transmission stop
# nano transmission/home/settings.json
"rpc-whitelist-enabled": false,
"umask": 7,
Code:
# sysrc transmission_download_dir="/mnt/FTP/zDOWNLOADSz"
# service transmission start
# exit
logout

We stop both Old and New Jails and sync Plex Database.
Code:
# warden stop MediaJail
Stoppingthejail....192.168.1.52 (192.168.1.52) deleted
Unmounting user-supplied file-systems
Stopping jail with: /etc/rc.shutdown
# iocage stop Media
* Stopping Media
  + Running prestop OK
  + Stopping services OK
  + Tearing down VNET OK
  + Removing jail process OK
  + Running poststop OK
# cp -av /mnt/Vol1-Z2/jails/MediaJail/usr/local/plexdata/Plex\ Media\ Server/ /mnt/iocage/jails/Media/root/usr/local/plexdata/Plex\ Media\ Server/
# iocage start Media
 
Last edited:

anfieldroad

Junior Member
Joined
Dec 21, 2018
Messages
20
Doesn't work, just sits there saying "Looking for servers"

Like every guide I have found for installing Plex it is useless and doesn't work
 

Bibi40k

Member
Joined
Jan 26, 2018
Messages
120
When everyone else says it's working and you say that every guide is useless ... there must be a problem somewhere. Any way .. Happy New Year !
 

anfieldroad

Junior Member
Joined
Dec 21, 2018
Messages
20
Seems the issue is the allowedNetworks, I had to specify this in Preferences.xml and only a single network worked, anything else errored - multiple networks or wildcards.

How to specify multiple network ranges?
 

svtkobra7

Member
Joined
Jan 12, 2017
Messages
195
I can't help you, it's just another useless guide... sorry.
Well played ... still chuckling ... and that was after I picked myself up off the floor from laughing. Play Nice! :)

Image attached for your future use if needed. :cool:
index.png
 

mysticpete

Member
Joined
Nov 2, 2013
Messages
119
Thanks @Bibi40k for this write up, very concise and well written and assisted me completely in creating a Plex server on iocage and moving my old data from the warden jail.
 
Last edited:

yozart

Junior Member
Joined
Mar 5, 2016
Messages
15
Hello,

I followed your tutorial after several attempts with the Plex plugin. Unfortunately, I keep getting the same issue:

My media are not readable in Plex (only music is working). Moreover, there is no picture showing for any of my media including music.
If I try to read a movie, then I can wait for hours and nothing happens.

Do you have any idea of what can be the issue ?
I do not have any issue in my warden jail (plugin).
 

mysticpete

Member
Joined
Nov 2, 2013
Messages
119
Hello,

I followed your tutorial after several attempts with the Plex plugin. Unfortunately, I keep getting the same issue:

My media are not readable in Plex (only music is working). Moreover, there is no picture showing for any of my media including music.
If I try to read a movie, then I can wait for hours and nothing happens.

Do you have any idea of what can be the issue ?
I do not have any issue in my warden jail (plugin).
Check your permissions of the host files?
 

yozart

Junior Member
Joined
Mar 5, 2016
Messages
15
Well, I might be doing something bad with permissions then.
How do you check that a group has access to files? How to add a group to the permissions ? (in jail and/or in freenas ?)
Using ACL or something else?
 

Bibi40k

Member
Joined
Jan 26, 2018
Messages
120
Hi,
first paragraphs talks about groups and permissions. If you follow the tutorial step-by-step you'll be in the right place when you configure those settings.

in short... in both jail and freenas the groups that own the plex folder and shared folders must have the same ID. Please read and follow the tutorial. It cannot be more clear than this. At least i'm not able to do it more clear.
 

Bibi40k

Member
Joined
Jan 26, 2018
Messages
120
Hi,
there is no special sequence.
You just need to enter the iocage and run the 2 update comands time to time.

Code:
# sudo -i
# iocage console Media
# pkg update
# pkg upgrade -y
# service plexmediaserver restart
# exit
 

itskando

Member
Joined
Apr 30, 2018
Messages
145
We create the media user and add it to the ftp group.
Code:
# getent group | cut -d':' -f1,3-4 | grep -E 'media|ftp'
ftp:14
# pw useradd -n media -w none -u 8675309 -G ftp -c "Media User"
# getent group | cut -d':' -f1,3-4 | grep -E 'media|ftp'
ftp:14:media
media:8675309
# id media
uid=8675309(media) gid=8675309(media) groups=8675309(media),14(ftp)
Do we remain within the jail console here, or is this back on freeNAS OS itself?
Edit: The answer was yes - remain within the console.
 
Last edited:

itskando

Member
Joined
Apr 30, 2018
Messages
145
Sometimes, it is not possible to change the transmission default download-dir.
This was solved here; it might be worth adding the method to the guide to implement by default:

Set your transmission config file download-dir by going into the transmission jail and using the following command:
Code:
sysrc transmission_download_dir="/mnt/transmission/downloads"
service transmission restart

Also, if you want to make changes to the transmission config file,
you must stop the transmission service first, or the changes will revert.
Code:
service transmission stop
nano /usr/local/etc/transmission/home/settings.json
service transmission start


[Also, if you deviated at all regarding user names and have issues with download permissions, this was a helpful guide.]
 
Last edited:

itskando

Member
Joined
Apr 30, 2018
Messages
145
@Bibi40k : Your first guide mentions how to setup VPN and this guide mentions how to install a jail with plex and transmission. Is any further action necessary to make the media jail in this guide interface with the openVPN jail setup in your prior guide?

• Does IPFW need to change at all for transmission to appropriately work with it?
• Do you recommend a paid/3rd party VPN rather than a hosted openVPN server?
 
Last edited:

Bibi40k

Member
Joined
Jan 26, 2018
Messages
120
Hi itskando,
You don't need to change anything.
OpenVPN works ok but i plan to buy a router with hardware VPN on it just because my old one is dying, otherwise i'd keep OpenVPN.
 

itskando

Member
Joined
Apr 30, 2018
Messages
145
For those wondering about "umask":7,
I believe a decent explanation of umask exists here, and
if I understood correctly, the umask mode sets the permissions of downloaded files.
A umask code of "7" (in decimal) is "007" in hex, which stands for:

Code:
Bit 2 [Owner]: 0 - Grant read, write, and execute permissions
Bit 1 [Group]: 0 - Grant read, write, and execute permissions
Bit 0 [Other]: 7 - Grant no permissions

Thus, the "media" user and the "FTP" group which were associated with the jail
will have full permissions for any files downloaded through Transmission.
Other users and groups will not have access to these files.
 

FloridaDan

Junior Member
Joined
Apr 4, 2014
Messages
21
So first off, THANKS for this effort. It was a huge help.

That said, I have to confess that I cherry picked this. Part of that was motivated by the fact that I don't use Transmission. Part of it is that I got some odd results.

Below is the subset of things that I cherry picked out of the original.

A couple of observations:

  1. I made my jail manually through the UI. No particular reason for that, just what I did.
    1. Jail was named the same as it was under Warden.
    2. Based on the 11.2-RELEASE template
    3. VNET as selected as what the vnet0 interface
    4. I assigned an ipv4 address appropriate to my network and the correct subnet mask.
    5. I created mount points commensurate with what I had in Warden.
  2. To get the Plex database to sync to work at all, my Plex servers (and therefore the jail containing it) needed to have same "new" name as the old one. Because of this I started with the warden jail OFF.
  3. The Plex database sync is the place where I had the most oddities.
  4. There is a minor oddity associated with updating Plex. Even though I just performed a fresh install, followed by an immediate update/upgrade, Plex still thinks it's a couple of revs behind. I'm suspecting that this is just a lag in porting the most recent revisions, but I'm not positive of that.
All the same conversions used the original apply. I'm not repeating those parts. Please see the original post. The OP did an excellent job of marking the commands and data.

First, we become root
Code:
% sudo -i
Password:
Warning: settings changed through the CLI are not written to
the configuration database and will be reset on reboot.


Now that the Jail is up and running, we go inside, update everything and install what we need.
Code:
# iocage console Media
...
Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier
Edit /etc/motd to change this login announcement.
# env ASSUME_ALWAYS_YES=YES pkg bootstrap
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[Media] Installing pkg-1.10.5_3...
[Media] Extracting pkg-1.10.5_3: 100%
# pkg update
...
Processing entries: 100%
FreeBSD repository update completed. 32565 packages processed.
All repositories are up to date.
# pkg upgrade -y
...
Checking integrity... done (0 conflicting)
Your packages are up to date.
# pkg install -y nano wget plexmediaserver transmission
...
Once started, visit the following to configure:
http://localhost:32400/web
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
The careful observer will notice that I left several bits out of that first phase.

In the next phase I dropped all the bits associated with Transmission and the media user. I just worked with the Plex user and group.

As I noted above, I stuck with the plex user and group, so I changed the part about making the plexdata directory as follows:
Code:
# cd /usr/local && mkdir plexdata
# chown -R plex:plex plexdata


After enabling plexmedia server to auto start with the jail, I skipped the rest of this block.

I've used Plex for years and never used WebTools or had any idea that it existed. I honestly have little idea about what it does for me, but it's been a while since the repository on GitHub was updated. My initial attempts at trying to follow this kept running into trouble around WebTools, so I dropped it.

If anyone has any insight into what it is, what it's good for, or what the issues may be, I'm all ears.

Code:
# sysrc plexmediaserver_enable=YES
plexmediaserver_enable:  -> YES
Keep in mind that I started with the Warden jail OFF. So I didn't stop it again.

We stop both Old and New Jails and sync Plex Database.
Code:
# warden stop MediaJail
Stoppingthejail....192.168.1.52 (192.168.1.52) deleted
Unmounting user-supplied file-systems
Stopping jail with: /etc/rc.shutdown
# iocage stop Media
* Stopping Media
  + Running prestop OK
  + Stopping services OK
  + Tearing down VNET OK
  + Removing jail process OK
  + Running poststop OK
# cp -av /mnt/Vol1-Z2/jails/MediaJail/usr/local/plexdata/Plex\ Media\ Server/ /mnt/iocage/jails/Media/root/usr/local/plexdata/Plex\ Media\ Server/
# iocage start Media
The copy command did in fact copy a bunch of stuff from the warden jail to the iocage jail. Much of it looked like plex metadata as it was wizzing by on the screen. That said, once I started Plex up, all the data it seemed to know about was from 3 years ago, and it spent a great deal of time rebuilding the library.

I store the vast majority of my metadata on the media files themselves, so this wasn't a huge deal, and I'd almost resigned myself to having to rebuild the library anyways (I'd previously tried this several different ways, and never did get it even this far, so I considered this a win.)
 
Last edited:
Top