One of the most popular uses of NAS4Free is to host a Plex server that can serve media files to devices on your network. Plex is supported on a variety of platforms, but having support for FreeBSD is just icing on the cake. “The power to serve” is motto of the FreeBSD foundation, and with NAS4Free you get just that. NAS4Free is based off of FreeBSD, and therefore has the system’s stability, software and driver support, as well as the ability to run programs inside of jails. Jails are like virtual machines, where software can be run separately from the host system. Having Plex installed inside of a NAS4Free jail will have numerous and invaluable advantages: snapshots for reverting to an earlier state, jails so you can manage different software and services without risking system wide changes and conflicts, access to drivers and media transcoders to serve media, the ability to run your server 24/7 for months on end without having to reboot or worry about it crashing, and a rudimentary web UI to simplify setting up and using all these features.
I’m going to show how to setup Plex inside a jail because I believe it is the best way to go about it, regardless of skill level, because you can easily revert any unwanted changes. If the steps below just aren’t working out for you, there are a few simpler alternatives that will automate most of the process, though I should warn that they tend to involve the installation media being downloaded from an unofficial server. You can find these guides on the forums. However, if you are up for the challenge, please read on and do things the right way.
This guide only makes two assumptions:
- You are using the 64 bit installation of NAS4Free, version 10.2 or higher
- You have already set up a ZFS pool or RAID pool with datasets where your files and jail will be stored.
Installing the Jail Manager
NAS4Free has many plugins and extensions, we’ll be using “The Brig“, a jail manager with a web UI that makes your life easier. Enter these commands in through a shell or your web GUI (Advanced –> command):
fetch -o /tmp/thebrig_install.sh fetch https://raw.githubusercontent.com/fsbruva/thebrig/alcatraz/thebrig_install.sh
chmod a+x /tmp/thebrig_install.sh
/bin/sh /tmp/thebrig_install.sh /mnt/YOURPOOLHERE/YOURJAILNAME 2
The 2 at the end of the last command is a flag that tells it to install the working branch, so make sure you keep it in (the guide I was using before didn’t mention this and I lost a few hours because of that missing detail). “YOURPOOLHERE” should be replaced by the folder names you’ve created on your machine (N4F Wiki setup guide if you have not). If you get any errors, make sure you’ve pasted the commands correctly. You can just right click on the console if you’re using PuTTY and it will paste in. If this doesn’t work, try manually typing the commands in letter for letter. Once completed, refresh your NAS4Free webpage. You should see an extensions tab with “TheBrig” below it, open it up. A red box should appear saying it detected a first time install – do what it says and complete the rudimentary configuration (install path should be automatically entered). Then, go to tarball management. Click query, select base.tgz and lib32.tgz and click fetch.
That should do it, you can also backup your jails by exporting existing configuration (better to wait until you get things working how you want them, and then back up). So add a jail, name it Plex or something and make sure you check these boxes:
- Full jail
- Enable mount devfs
- Choose an IP address and add it (something like 192.168.1.x – make sure that address isn’t already being used)
- Tick both boxes at the bottom for “Installation Source”
Then and hit start (green button). Next we’ll install Plex from within the jail with a few commands.
We need to do some things first, like install ports. Open up a shell or enter these commands through your N4F web UI. Enter “jls” to see which jails you have running and their IP addresses. Login to the jail like this:
jexec (JID) csh
Then get ports.
portsnap fetch extract
And then install Plex
cd /usr/ports/multimedia/plexmediaserver/ && make install clean
Start Plex on boot, make sure you enter this correctly
echo plexmediaserver_enable="YES" >> /etc/rc.conf
Create a folder for your files
And we’re done here
Now, back in your NAS4Free web UI, we need to tell NAS4Free where to mount our media files inside the jail so Plex can use them. Go to The Brig tab, preferences, configure fstab. Add a line for the folder we just made like so, and be careful because these fields are a little buggy you might have issues with folder names that contain spaces.
/mnt/YOURPOOLHERE/MEDIA /mnt/YOURPOOLHERE/JAILNAME/plex/mnt/MEDIA nullfs ro 0 0
And now the files from the path on the left side are now available inside the jail as read only (keeping things secure). Remember typing “jls” previously and seeing your jails information? Get the IP address that way and type it into your browser:
Which should give you Plex’s own web UI where you can make changes to how Plex operates.
The dashboard is well done and has many improvements over the previous versions. Before, people often complained of Plex not beings able to see their files – I’ve never had that issue. All you need to do is add a library and refresh it any time you add new content. If you made it through all those steps, Plex should be accessible on your local network with little or no additional steps. How many devices can your Plex serve media to? See this post for information on CPU, passmark scores, and streaming. Roku has a Plex app, Android has a Plex app (though they make you pay)… The list goes on. There is even a Plex distro for the Raspberry Pi called RasPlex.