Moving PMS 'Library'

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:

  1. Stop Plex Media Server
  2. Create the ‘override’ file
  3. Move the files to their new location
  4. Change ownership if needed
  5. Inform systemd of the changes
  6. 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)

34 Likes
Cannot play media after metadata library move
Application Support symlink not working
Error in PMS when trying to move plexdata
Linux/Ubuntu local disk shows enormous space usage by PMS
Can Someone Please Point Me To The Tutorial On Moving The Data Folder To Another Location?
Unable to start plex after moving library
Help moving library metadata
Store Plex library database & settings on external drive?
Plex Server on a NUC
DVR not recording after moving plex media library
Plex players fail to play (anything,everything)
Docker container keeps loosing connection/access - DB constantly busy
[SOLVED] Thumbnails not showing after moving Plex Media Library
Need to move METADATA folder to make space
LG TV: Conversion failed. The transcoder exited due to an error
Can I move /usr/lib/plexmediaserver?
PMS Migration Install Fail
How to change location of Plex Media Server data files on CentOS
PMS Migration Install Fail
Ubuntu 19.04 move metadata to SSD
Ubuntu 19.04 move metadata to SSD
Update has cleared my library
DVR not working after moving Library on Ubuntu
Plex server not being found after completing troubleshooting steps
PMS Library won't work on mergerfs with direct_io
500 Internal Server Error when getting logs
Moving PMS ‘Library’ Issue
Suggestion: Move Plex media files out of var
Server or account issue?
How to add PMS back after reinstall
Move plex DB off my ssd
Moving PMS Library: Recommendation
Move/Clear Plex metadata
Need help moving /var/lib/plexmediaserver on KVM guest to host Samba share
Change Metadata Location on Ubuntu 14.04
Problems with PMS and Plex App after rebuild/recovery of media source drive
"plexmediaserver.service.d" issue in Centos 8
New music scanner metadata size
Plex Music scanner downloads many 1-10MB posters into metadata, and I would like fewer, smaller images
Server settings are not available
DVR not recording after moving plex media library
Changing Metadata Directory
Metadata Scanning stops working after sometime (only reboot) resolves
Bug: Preferences.xml is reset when there is no space left on disk
PMS on Ubuntu Server setup as an appliance
Move cache folder or simply library
Move cache folder or simply library
Moving library on new plex install broke library access
Move cache folder or simply library
Problems upgrading and updating my PI due to low space, possibly from metadata from the Plex Server
Problems upgrading and updating my PI due to low space, possibly from metadata from the Plex Server
Moving posters and art to other hard drive
Suggested Edit to "Moving 'PMS' Library" Guide
Moving library on new plex install broke library access
PMS not honoring env var
Ubuntu 20.04 LTS Plex crashes when playing to any non-computer device
Transcoded stuff didn't work anymore, direct play works
Server Will Not Start
Plex won't start Dev/mapper/Plex--vg-root at 100%
Move PLEX library location
Moving plex metadata to external drive (debian linux)
Moving plex metadata to external drive (debian linux)
Using Clonezilla to clone /root & /var (including PMS ) to new drive - issues?
Destination For Metadata Move - Quick Question
Libraries not showing after PMS migration to new CentOS server
Ubuntu Server Plex Install broken
Failed to start — Read/write access Plex Media Server dir
Moved PMS Library, now can't get live TV or recordings
PMS Stopped working on Ubuntu Server upgrade from 18.0 to 20.04 LTS Upgrade
Cannot move metadata/library
New Server Setup, Restore Connection to External HD Library and Database
Ubutnu Root Directory filling up and /var/lib/plexmediaserver doesn't exist
Can't access server after moving metadata
Reinstall OS Ubuntu 18 to 20.04 and had to set it all up again (Solved)
Fix pms metadata storage locations already!
Help moving library metadata
One last attempt to make this work before removing it forever SOLVED!
One last attempt to make this work before removing it forever SOLVED!
Why does this manual doesn't work on my Ubuntu Server 20.04 & PMS?
Upgrade PMS on Linux
PMS migration from Synology to Intel NUC onto secondary SSD
Server move to new disk drive failed
Linux PMS Symlink Issues (moving plex data to a new folder)
Storing Metadata on SMB Network Share
Home screen is blank AGAIN -- Getting sick of this
Move PMS Library
Moving Database to another location
Plex doesn't start after having moved the library
Storing Metadata on SMB Network Share
Storing Metadata on SMB Network Share
Moved Database to USB lost all Artwork
New media not pulling in metadata from agents
Moving folders to SSD, question
PMS Filling up HDD
Plex Movie Posters not downloading
Scanner Error after Relocating Plex Media Server Data Directory
Debian VM unreliable playback
Plexmediaserver has filled my root partition
Copying files to migrate plex to new server
Move Metadata Library to different folder on Ubuntu 18.04 fails
Moving Metadata repository from

Moving Plex’s metadata (Library) directory on init based systems

This procedure is intended for those whose systems are init based (cat /proc/1/comm returns init).

Perform the following sequence in a root shell and with PMS stopped

sudo sh

A. Create the new location to hold the Plex Library

In this example, I show you how to use /home/plexdata. It can be any valid filesystem on your computer. The only restriction is it may not be a network file system (remote mount). This is because the database requires file locking. File locking is not supported by most network share protocols.

mkdir  /home/plexdata

B. Now copy the existing library. (Resolve errors before deleting the original copy of your library)

cd /var/lib/plexmediaserver
tar cf - ./Library | (cd /home/plexdata ; tar xf -)   # this will take some time
cd /home/plexdata

C. Change ownership to plex

chown plex:plex /home/plexdata

D. Add the following entry to /etc/fstab which will ‘bind’ (overlay) the new location on top of /var/lib/plexmediaserver/Library

/home/plexdata/Library    /var/lib/plexmediaserver/Library         none  bind 0 0

E. Test the mount

mount /var/lib/plexmediaserver/Library
touch /var/lib/plexmediaserver/Library/dummy
umount /home/plexdata

F. Verify the dummy file only exists in the new location (/home/plexdata/Library)

ls /home/plexdata/Library
ls /var/lib/plexmediaserver/Library

G. Verify normal PMS operation with the mount active

mount /var/lib/plexmediaserver/Library

Start PMS

H. With Verification complete

  1. Stop PMS
  2. umount /home/plexdata
  3. rm -rf /var/lib/plexmediaserver/Library/* (Library must remain but remove all below it)
  4. mount /home/plexdata
  5. Start PMS

I. All metadata will now be stored in /home/plexdata

5 Likes