If you are not familiar with Plex then you should take a look at their website.
Plex organizes your video, music, and photo collections and streams them to all of your screens.
What this explanation leaves out is that Plex will handle all of the details for you fairly seamlessly. Whatever format your collection is in, Plex will automatically ensure that it is compatible with whatever device you are using to view the collection. First I will explain how to install it on FreeNAS and then I will talk more about the software itself.
First, we must create a jail. Go to Jails and click Add Jail. Give your jail a name and click OK. By default Plex will use this as the name it displays in the client, but you can easily change that in the settings.
Once the jail is created, click on the Shell icon to log in. Verify your IP address via ifconfig. FreeNAS 9.3 introduced the option to use DHCP addresses for your Jails. I changed my configuration to use DHCP as I assign static IPs via my router which gives me the added benefit of registering the machine name in DNS.
Now that we are logged into the jail we run the following command to install Plex. If you do not have a Plex Pass or do not wish to use the Plex Pass version, then replace plexmediaserver-plexpass
with just plexmediaserver
.
pkg install plexmediaserver-plexpass
This will want to upgrade pkg. Select y to allow this. Once that is done, select y again to install Plex server. The install will automatically create a plex user and group with id’s of 972.
Enable Plex autostart by the following, as in the instructions.
sysrc plexmediaserver_plexpass_enable=YES
Then start the server by running the following.
service plexmediaserver_plexpass start
Plex will now be running on the IP you verified via ifconfig.
Now you need to add some media to Plex. Go to the Storage tab and select the Volume you wish to store your Plex media in. Pick the Dataset with the same name as the Volume. Then select Create Dataset.
Name your Dataset as you wish. I tend to use plexmedia but it does not particularly matter. I would however avoid naming it just media. Click on Advanced Mode and change the Record Size to 1024K. This is not required but is useful as we will be storing large video files in this Dataset. I leave Share type as UNIX because I do not share my Plex media Dataset. I use SCP to directly copy the data or log in and move it over from another Dataset which has been shared.
To simplify permissions I create a Plex user and group in FreeNAS, both with id’s of 972 as that is what Plex defaults to. I disable password login as this user is primarily for easy Dataset permissions and does not need to log in. Then I change the permissions of the Plex media Dataset to be owned by the Plex user and group. Make sure your SCP user is part of the Plex group if you wish to use SCP to copy your data as I do.
Now we go back to the Jails tab and add the Plex media Dataset to the jail as storage. I tend to mount it as /plexmedia but that is an individual choice. I find it easiest to create the directory in the jail shell before adding storage. This helps prevent typos. If you want to ensure that Plex does not accidentally delete your data you can mount the Dataset read only. You will still be able to modify it from FreeNAS but it will no longer be able to be changed from inside the jail. Note that doing this will make the “Allow media deletion” checkbox in Plex irrelevant.
Once the storage is added, I create a movies directory and a tv directory. They default to the Plex group with read permissions. I change the ownership to the plex user as well. This is not a required step. Make sure to change the group permissions to allow writing or the user you added to the plex group will not be able to add files. If you wish to use Plex for music, pictures or home videos you will want to add directories for those as well.
Once the jail storage is configured I log into Plex and add the directories I created as libraries. You will want to ensure that each directory type is it’s own library as the metadata scanners can get confused if they do not find the expected type of media. Note that Plex in a jail will not automatically detect folder changes. You will have to set the server to update your library periodically. I originally set it to daily but since Plex does not always update every library during the update cycle I have changed it to hourly. If I need something to show up quicker then I just manually update the appropriate library.
Keep in mind that the update interval is based off of the server start time and not the clock. So an hourly update will update in 60 minute increments from the time the server started, not exactly on the hour. Secondly, the update interval does not take affect until the previous update interval has passed. In my case of changing the interval from daily to hourly I had to wait until the next day before the server started checking hourly.
That is all there is to it. Once you add files into the appropriate directories you will start to see them populated in the Plex library.
Plex will not automatically update in a FreeNAS jail. Once a new update is released you will need to log into the shell of the jail and run the following command.
pkg upgrade
Since FreeBSD and therefore FreeNAS are not the primary target for Plex it will take a few days for the release to become available. I do not mind as this usually gives enough time for any major bugs to reveal themselves.