Moving Plex’s metadata (Library) directory on systemd
based systems
This information is intended for those systems where cat /proc/1/comm
returns systemd
. If your system returns init
, please see the next post in this thread.
While you may change /lib/systemd/system/plexmediaserver.service
, it is under the control of the package manager and subject to replacement without warning at any time during an update. To provide stability, systemd allows creation of an override.conf
file to customize and create enduring local adjustments to a distributed default package.
You can change a number of parameters about how PMS runs on your Linux system including where the metadata (Library) resides.
One of the more common needs is to relocate /var/lib/plexmediaserver
from it’s default location to a SSD or where there is more space.
On systems which use Systemd (Ubuntu 16+, Fedora, Centos 7, Debian 8,) you create a customization file which SystemD reads prior to launching PMS. This file is independent of the default configuration and service control mechanisms in /lib/systemd/system/plexmediaserver.service
. The Plex-supplied service definition should not be modified as any changes are subject to overwriting at every update.
The steps are:
- Stop Plex Media Server
- Create the ‘override’ file
- Move the files to their new location
- Change ownership if needed
- Inform systemd of the changes
- Start PMS
In the example below, the following will be shown. Tailor to your environment as needed
a) Run as user “chuck” in the “strange” group.
b) Move the metadata (Library) to /home/plex for the extra space
c) Relax the default file-creation permissions (for plug-ins, etc)
The following steps must be done as root, elevate first and get a full shell to work in
sudo sh
Begin here:
A. Create /etc/systemd/system/plexmediaserver.service.d
You can create the path directly in your favorite text editor or with systemctl edit plexmediaserver
Once in the editor, create the customization override containing the following**
#
# Customize Plex's config
[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/home/plexdata/Library/Application Support"
#
# These values are only needed if you wish to change user & group
User=chuck
Group=strange
#
# This is needed to change the default umask
UMask=0002 # this must be 4 digits of octal
INFO: It appears some systems want Umask while others want UMask. Please be cautious of this until fully resolved and noted here.
Warning: Do not use /media
as it is a reserved directory with Gnome. Select a target directory not used by any system applications.
B. Now copy the existing library. (Resolve errors before deleting the original copy of your library)
mkdir /home/plexdata
cd /var/lib/plexmediaserver
tar cf - ./Library | (cd /home/plexdata ; tar xf -) # this will take some time
cd /home/plexdata
# now change ownership
cd /home/plexdata
chown -R chuck:strange
C. Inform SystemD of the changes and test the related & reconfigured PMS
systemctl daemon-reload
systemctl start plexmediaserver
D. Test your system. Verify everything is exactly as it was. If not, resolve before proceeding
http://127.0.0.1:32400/web
E. Delete the old library in /var
rm -rf /var/lib/plexmediaserver/Library & # this can safely go into the background
Once you have created the override file, you can later edit it and add additional customizations with
sudo systemctl edit plexmediaserver
F. Verify “EXEC” status on target partition.
If moving PMS Library to a disk which was added after the system was originally installed, it is common to need adding exec
in the mount options for the partition.
An example of the /etc/fstab
entry for this is:
/dev/sde2 /home/plexdata ext4 defaults,auto,exec 0 0
Remember to remount the partition if you changed this mount entry.
(if using the automounter, remounting is required to ensure proper mount options)