Operating a Plex media server is actually quite simple. The real crux of the matter is to access your own media collection from the jail.
NEW: For the very impatient I have a console only section. There are only commands, no explanations.
Last updated:
iocage
installedGenerally, such service should be set up in its own environment. This makes not only security, but also maintenance much easier. Jails can be backed up relatively easily and only the packages that are absolutely necessary are installed.
The local setup looks like this:
┌────────────────────────────────────────────┐
│ TrueNAS │
│ ┌────────────────────┐ │
│ │ jails/plex │ │
LAN: 0.0.0.0:32400 ─┼─┼─► plexmediaserver ─┼─► /mnt/daten/medien │
│ └────────────────────┘ │
└────────────────────────────────────────────┘
A separate jail is required. Here we use plex
as the jail name.
Login to the jail via SSH: ssh USERNAME@IP
or ssh USERNAME@HOSTNAME
to gain root rights with su
.
Package sources should be customised, see separate article.
As a rule, your movies will be stored in the TrueNAS pool or in the FreeBSD host system. They are therefore also subject to its authorizations. If Plex is now installed in a jail, a separate Plex user has also been created.
With TrueNAS, the easiest way to do this is to use the ACL Manager (Edit permissions) of the data set with the media files, to which a reading (and possibly writing) user with the id 972 is simply added. A warning message from TrueNAS "No user name could be found for this ID" can be ignored. Do not forget to apply authorizations recursively!
In FreeBSD without ACL in a classic UNIX authorization structure, it is usually sufficient to adjust the group of the media folder and the files with:
chown -R :972 /mnt/data/media
recursively changes the group membership to 972 andchmod -R 750 /mnt/data/media
allows user and group read access to folders and files orchmod -R 770 /mnt/data/media
allows both read AND write access to folders and files.All others are not allowed anything in this example.
Just an example! It just has to fit your user & rights concept.
Well, the permissions should now be correct, but the directories outside the jails are not yet visible. This includes our example with /mnt/data/media
. So how does the /mnt/data/media
directory get into the jail? Via NullFS.
The easiest way to do this with TrueNAS is in the "Mount Points" section of the jail administration. Here you can specify any number of folders that should appear in the jail. In our example, enter /mnt/data/media
as the source and then a path within the jail as the target, e.g. /mnt/jail/plex/root/mnt/media
. If the media
folder does not yet exist: Never mind, simply enter it manually in the path, it will then be created automatically. If the jail is then started later, the directories are automatically included.
In FreeBSD this is actually done with one command: mount_nullfs /mnt/data/media /mnt/jail/plex/root/mnt/media
.
However, the target path must already exist (if necessary, create it beforehand with mkdir -p /mnt/jail/plex/root/mnt/media
).
The difficulty now is to ensure that the assignments survive a reboot.
The easiest way to do this is to store them in /etc/fstab
:
# Device Mountpoint FStype Options Dump Pass
/mnt/daten/medien /mnt/jail/plex/root/mnt/medien nullfs rw 0 0
/mnt/daten/musik /mnt/jail/plex/root/mnt/musik nullfs rw 0 0
This is best managed with BastilleBSD or iocage.
Update the package source with pkg update
and then install the required packages: pkg install plexmediaserver
.
Enable services and start them automatically when starting the jail: service plexmediaserver enable
.
As no configuration files are adapted, the service can be started directly: service plexmediaserver start
.
OR
Update the package source with pkg update
and then install the required packages: pkg install plexmediaserver-plexpass
.
Activate services and start automatically when starting the jail: sysrc plexmediaserver-plexpass=YES
Since no configuration files are adapted, the service can be started directly: service plexmediaserver-plexpass start
.
Plex can then be accessed at http://IP:32400 or http://HOSTNAME:32400
Attention: Plex is based on multicast. In order for the local Plex website to find the Plex server behind it at the first start, both MUST be in the same subnet.
When you start the assistant for the first time, it will ask for a folder with movies, series, music or pictures. You can now refer to the folders provided above. At least adjust the content type and language to finish the wizard and Plex will then automatically start indexing these folders. If not: Check permissions. :)
Data protection: In the standard configuration, Plex also wants to make it easy and ensure that the local media can be accessed from anywhere, even if the firewall etc. have not yet been set up. Plex uses a relay server for this purpose. If you want to prevent external (albeit not perfect) use in the local setup, you must explicitly deactivate this with the "Activate Relay" option. This can be found in the "Settings" under the "Network" menu item.
tbd
Voilá