How to install Plex in a FreeNAS jail

How To Install Plex in a 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 fill in the network settings to match your environment.

 

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.

Select the following:

Jail Name: plex

Type: pluginjail or standard (your choice)

IPv4 Address: 192.168.x.x (Anything that isn't taken and isn't in your DHCP scope)

Autostart: Checked (default)

VIMAGE: Checked (default)

vanilla: Checked (default)

 

Then click "Ok".

For more information on creating jails in FreeNAS, visit:http://doc.freenas.org/index.php/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:

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/

 

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.

 

 

The original tutorial I wrote is at:

http://forums.freenas.org/index.php?threads/tutorial-how-to-install-plex-in-a-jail.19412/

how about plexpass versions?

Check on page 2

Hello,

I guess I made a mistake. I followed the How To and than did the following:

.............

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

....

root@plexmediaserver_1:/usr/ports/multimedia/plexmediaserver-plexpass # echo plexmediaserver-plexpass_enable="YES" >> /etc/rc.conf
root@plexmediaserver_1:/usr/ports/multimedia/plexmediaserver-plexpass # service plexmediaserver-plexpass start
/etc/rc.conf: plexmediaserver-plexpass_enable=YES: not found
plexmediaserver-plexpass does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d)

As I thought this would start the Plex Server when I use the PlexPass Version....well it looks like I was mistaken ! :-(

How can I correct this?

Thank you soo much!!

Cheers

Hossa

How about just clicking on plugins and selecting plex media server???

This automatically creates the jail, does the download and installs without you having to do anything else...

After install is complete, jexec into the jail and "echo plexmediaserver_enable="YES" >> /etc/rc.conf" and that is it...

I did this like 6 months ago and haven't had one issue...

Hello,

I guess I made a mistake. I followed the How To and than did the following:

.............

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

....

root@plexmediaserver_1:/usr/ports/multimedia/plexmediaserver-plexpass # echo plexmediaserver-plexpass_enable="YES" >> /etc/rc.conf
root@plexmediaserver_1:/usr/ports/multimedia/plexmediaserver-plexpass # service plexmediaserver-plexpass start
/etc/rc.conf: plexmediaserver-plexpass_enable=YES: not found
plexmediaserver-plexpass does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d)

As I thought this would start the Plex Server when I use the PlexPass Version....well it looks like I was mistaken ! :-(

How can I correct this?

Thank you soo much!!

Cheers

Hossa

Hi Hossa,

I had the same issue as well, you need to edit your /etc/rc.conf file and replace the - with a _  as such...

plexmediaserver_plexpass_enable="YES" 

Save the edit, then start Plex with service plexmediaserver_plexpass start

Hello Balky,

I tried the "Plugin" way quite a few times. It installed Plex....created the Jail. I could also start Plex.

Than added storage to the jail.

BUT sadly never got past the point to give the jail access to my media collection !?

So I thought I would try the "manual" way....maybe working better.

Could someone please just clerify:

-> Plex Plugin install creates jail with user and group (how ever to find out the names without console)

-> If you know the user and group add those to the FreeNAS Users and groups manually. What about a password !?

-> Give this user permission to access the folder, share, mount or whatever you have your media in.

This is the way to go correct?

Thanks a lot for the tip with the _ Mr...loose !!

Will try that! :-)

Cheers

Hossa

I believe the user and group are created for the program Plex Media Server to run under. The password is not necessary nor is it even set. The way to allow a jail to access your media is all that you need.

Hello again,

after following the hint of Mrloose, I got Plex up and running! :-)

Thank you again!

But now I am stuck at "Mount / Permission" ! :-(

I added storage to the jail using the GUI. Afterwards I rebootet the NAS.

When I than tried the "ls -l /mnt" command at the prompt inside the jail, it shows me 0 ! Why?

Hope someone can help!

Thanks!

Hossa

How about just clicking on plugins and selecting plex media server???

This automatically creates the jail, does the download and installs without you having to do anything else...

After install is complete, jexec into the jail and "echo plexmediaserver_enable="YES" >> /etc/rc.conf" and that is it...

I did this like 6 months ago and haven't had one issue...

I prefer a manual installation because I can then upgrade it as soon as the ports are released. I also hear that when updating the plugins, it does some type of migration which takes a long time and can corrupt your Plex installation.

Hello again,

I followed your guide now. Every point was possible. I mounted my "added storage" to the folder "media" in the jail.

It worked. It showed me the user and group.

I added the new group "Media" to the jail, which also consists of "plex".

When I than do the ls -l command it shows me also "Media" as group of the "media" folder......before it was 1002.

So it worked.

But when I than try to access the folder via Plex it shows me nothing, and it also doesn't find any media! :-(

I don't know whats wrong.

When I am in the console inside the jail I can navigate trough the whole content of the mount.....even down to each single file.

But When I try to access it via Plex it shows nothing at all!

Update:

Some more details:

I mounted my FreeNAS mediafolder: "RaidZ1-Volume/Media" to "RaidZ1-Volume/jails/PlexMediaServer/mnt/Media" inside the jail.

When I do ls -l :root@PlexMediaServer:/ # ls -l

I get all folders with permissions and this one says:

drwxr-xr-x 3 root wheel 3 May 11 19:51 mnt

When I than go inside mnt and do it again I get:

drwxr----- 5 1001 Media 6 Apr 26 18:12 Media

"Media" is the group I created which has as a member "plex"!

When I than go inside Media and do ls -l again I get:

-rwxr----- 1 1001 Media 56 Feb 4 23:17 Dateiliste erstellen.bat
drwxr----- 4 1001 Media 4 Apr 26 16:46 Musik
drwxr----- 5 1001 Media 5 Apr 26 18:11 Serien
drwxr----- 9 1001 Media 9 Apr 26 18:12 Spielfilme

This is now the content of my "Media" Folder on the FreeNAS. So the Storage got mounted and I actually can access it.

When I now navigate down until a single Media file all the rights and permissions are the same; for example:

root@PlexMediaServer:/mnt/Media/Spielfilme/Dokus # ls -l
total 9065902
-rwxr----- 1 1001 Media 8856649168 Aug 16 2012 Michael Jackson The Life of An Icon (2011) - 1080i.ts
-rwxr----- 1 1001 Media 156160 Oct 27 2013 Thumbs.db
-rwxr----- 1 1001 Media 1009163132 Feb 21 2012 iGenius - Wie Steve Jobs dieWelt veränderte (2011) - 576i.ts

But when I try to access the folders and media via Plex I can only get to /mnt/Media .....than there is nothing.

I see the mount is working. I see the media is there. I guess the permissions are still incomplete.... :-(

So What is wrong?

Hope someone can help! :-) Please!

Cheers

Hossa

Hello again,

I followed your guide now. Every point was possible. I mounted my "added storage" to the folder "media" in the jail.

It worked. It showed me the user and group.

I added the new group "Media" to the jail, which also consists of "plex".

When I than do the ls -l command it shows me also "Media" as group of the "media" folder......before it was 1002.

So it worked.

But when I than try to access the folder via Plex it shows me nothing, and it also doesn't find any media! :-(

I don't know whats wrong.

When I am in the console inside the jail I can navigate trough the whole content of the mount.....even down to each single file.

But When I try to access it via Plex it shows nothing at all!

Update:

Some more details:

I mounted my FreeNAS mediafolder: "RaidZ1-Volume/Media" to "RaidZ1-Volume/jails/PlexMediaServer/mnt/Media" inside the jail.

When I do ls -l :root@PlexMediaServer:/ # ls -l

I get all folders with permissions and this one says:

drwxr-xr-x 3 root wheel 3 May 11 19:51 mnt

When I than go inside mnt and do it again I get:

drwxr----- 5 1001 Media 6 Apr 26 18:12 Media

"Media" is the group I created which has as a member "plex"!

When I than go inside Media and do ls -l again I get:

-rwxr----- 1 1001 Media 56 Feb 4 23:17 Dateiliste erstellen.bat
drwxr----- 4 1001 Media 4 Apr 26 16:46 Musik
drwxr----- 5 1001 Media 5 Apr 26 18:11 Serien
drwxr----- 9 1001 Media 9 Apr 26 18:12 Spielfilme

This is now the content of my "Media" Folder on the FreeNAS. So the Storage got mounted and I actually can access it.

When I now navigate down until a single Media file all the rights and permissions are the same; for example:

root@PlexMediaServer:/mnt/Media/Spielfilme/Dokus # ls -l
total 9065902
-rwxr----- 1 1001 Media 8856649168 Aug 16 2012 Michael Jackson The Life of An Icon (2011) - 1080i.ts
-rwxr----- 1 1001 Media 156160 Oct 27 2013 Thumbs.db
-rwxr----- 1 1001 Media 1009163132 Feb 21 2012 iGenius - Wie Steve Jobs dieWelt veränderte (2011) - 576i.ts

But when I try to access the folders and media via Plex I can only get to /mnt/Media .....than there is nothing.

I see the mount is working. I see the media is there. I guess the permissions are still incomplete.... :-(

So What is wrong?

Hope someone can help! :-) Please!

Cheers

Hossa

I believe the issue is because the Media group doesn't have execute on the folders. To be able to traverse directories, Unix (also Linux) requires the execute bit.

Edit: Try something like this in your jail:

find /mnt -type d -exec chmod 0750 {} \;

The above command finds all the directories in the /mnt directory and applies a chmod of 750 (rwx on owner, rx on group, nothing to world).

Hello prahlm93,

thanks a lot for your quick reply !!

I did not know that! Will try it as soon as possible, and let you know if it was the problem!

Maybe you should update your "How to" with this detail. I guess I will not be the only one with this problem in the future....

Thanks again!

Have a nice day

Hossa

Hello again,

I tried your suggestion. First I could not chmod any folders, because I mounted the storage as "read only".

After deleting the mount and mounting it again with no checkmark at "read only" I was able to execute your command in the jail:

find /mnt -type d -exec chmod 0750 {} \;

But sadly, after the command finished and after a restart of Plex I now don't even see the folder inside the mnt folder !?

Before I had:

drwxr-xr-x 3 root wheel 3 May 11 19:51 mnt

Now I have:

drwxr-x--- 3 root wheel 3 May 11 19:51 mnt

The folders inside "mnt" all have the same permissions as "mnt".

I guess something in your command was wrong !?

Help again please!

Cheers

Hossa

Update:

I simply tried all different variants:

find /mnt -type d -exec chmod 0750 {} \;
find /mnt/ -type d -exec chmod 750 {} +       <- No folder in "mnt"
find /mnt/ -type d -exec chmod 700 {} +       <- No folder in "mnt"
find /mnt/ -type d -exec chmod 705 {} +       <- "Media" folder in "mnt", but no subfolder structure, no media files found
find /mnt/ -type d -exec chmod 755 {} +       <- "Media" folder and all subfolders in "mnt", media files also found ! :-)

How come I need rx on "group" AND "others"  ???

Or am I missing a clue?

Thanks

Hossa

Update2:

I found out, what the problem was!

It has to be like this to work:

drwxr-xr-x 3 root wheel 3 May 11 19:51 mnt

And all folders inside "mnt" only have to be like this:

drwxr-x--- 5 1001 Media 6 Apr 26 18:12 Media

Maybe you could explain it; just to understand what I am doing! ;-)

Cheers

Hossa

Hello again,

I tried your suggestion. First I could not chmod any folders, because I mounted the storage as "read only".

After deleting the mount and mounting it again with no checkmark at "read only" I was able to execute your command in the jail:

find /mnt -type d -exec chmod 0750 {} \;

But sadly, after the command finished and after a restart of Plex I now don't even see the folder inside the mnt folder !?

Before I had:

drwxr-xr-x 3 root wheel 3 May 11 19:51 mnt

Now I have:

drwxr-x--- 3 root wheel 3 May 11 19:51 mnt

The folders inside "mnt" all have the same permissions as "mnt".

I guess something in your command was wrong !?

Help again please!

Cheers

Hossa

Update:

I simply tried all different variants:

find /mnt -type d -exec chmod 0750 {} \;
find /mnt/ -type d -exec chmod 750 {} +       <- No folder in "mnt"
find /mnt/ -type d -exec chmod 700 {} +       <- No folder in "mnt"
find /mnt/ -type d -exec chmod 705 {} +       <- "Media" folder in "mnt", but no subfolder structure, no media files found
find /mnt/ -type d -exec chmod 755 {} +       <- "Media" folder and all subfolders in "mnt", media files also found ! :-)

How come I need rx on "group" AND "others"  ???

Or am I missing a clue?

Thanks

Hossa

Update2:

I found out, what the problem was!

It has to be like this to work:

drwxr-xr-x 3 root wheel 3 May 11 19:51 mnt

And all folders inside "mnt" only have to be like this:

drwxr-x--- 5 1001 Media 6 Apr 26 18:12 Media

Maybe you could explain it; just to understand what I am doing! ;-)

Cheers

Hossa

Yes, sorry about that. Since the /mnt folder is owned by Root:Wheel, giving it 750 permissions would not allow Plex to go into the directory since Plex is not running as Root or a user that is in the Wheel group. By giving it 755, it allows any user to traverse the directory.

Hello


I followed these instruktions and it worked perfect! Untill i 3 month later reboted my freenas, Now i can’t connect to the plexmediaserver. When i check the jail i can see that the plexmediaserver is running!? Any idea what have happend?


Best regards

Plex@gudo

Hello. I was just trying to install the plexpass version (0.9.9.16.555) of Plex onto my freenas server. When i attempted to install it using this command cd /usr/ports/multimedia/plexmediaserver-plexpass/ && make install clean the shell then says the package is fake. I've used the manual way to install plex before with no problems, but it isn't working now. This could be a problem on my end, but i'm not sure. Does anyone possibly have any ideas?

 

install  -s -o root -g wheel -m 444 /usr/ports/multimedia/plexmediaserver-plexpa

ss/work/PlexMediaServer-0.9.9.16.555-50cd0c3/lib* /usr/ports/multimedia/plexmedi
aserver-plexpass/work/stage//usr/local/share/plexmediaserver-plexpass           
# Fix permissions to programs and db                                            
# Python fix                                                                    
====> Compressing man pages (compress-man)                                      
===> Staging rc.d startup script(s)                                             
===>  Installing for plexmediaserver-plexpass-0.9.9.16.555                      
===>  Checking if plexmediaserver-plexpass already installed                    
===>   Registering installation for plexmediaserver-plexpass-0.9.9.16.555       
*** [fake-pkg] Error code 74                                                    
                                                                                
Stop in /usr/ports/multimedia/plexmediaserver-plexpass.                         
root@plexmediaserverplexpass:/usr/ports/multimedia/plexmediaserver-plexpass

I'm also getting this error on FreeNAS. I tested with the plexpass and normal PMS ports and they both report fake.

I found this message on a mailing list:

http://lists.freebsd.org/pipermail/freebsd-questions/2013-September/253439.html

So I tried to upgrade ports-mgmt with the following:

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

However, it also has the following errors:

====> Compressing man pages (compress-man)
===>  Installing for indexinfo-0.2
===>  Checking if indexinfo already installed
===>   Registering installation for indexinfo-0.2 as automatic
*** [fake-pkg] Error code 74
 
Stop in /usr/ports/print/indexinfo.
*** [run-depends] Error code 1
 
Stop in /usr/ports/devel/libffi.
*** [install] Error code 1
 
Stop in /usr/ports/devel/libffi.
*** [build-depends] Error code 1
 
Stop in /usr/ports/lang/ruby19.
*** [install] Error code 1
 
Stop in /usr/ports/lang/ruby19.
*** [extract-depends] Error code 1
 
Stop in /usr/ports/ports-mgmt/portupgrade.
*** [install] Error code 1
 
Stop in /usr/ports/ports-mgmt/portupgrade.
 
 
I just upgraded to FreeNAS 9.2.1.7 yesterday. Maybe that is the issue?

I tried adding NO_STAGE=yes to /etc/make.conf and installing:

root@plex:/usr/ports/multimedia/plexmediaserver-plexpass # make install clean
===>  plexmediaserver-plexpass-0.9.10.1.585 is marked as broken: Not staged..
*** [install] Error code 1
 
Stop in /usr/ports/multimedia/plexmediaserver-plexpass.
 
This is because of a recent change in ports:
http://blogs.freebsdish.org/portmgr/2014/09/01/the-ports-tree-is-now-stage-only/
 
Argh!!