If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Moving PMS 'Library'

ChuckPAChuckPA Posts: 20,315Members, Plex Pass, Plex Ninja, Plex Team Member Plex Team Member
edited January 28 in Linux Tips

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 task, with PMS stopped, is:
1. Create the 'override' file
2. Move the files to their new location
3. Change ownership if needed
4. Inform systemd of the changes
5. Start PMS

In the example below, the following will be shown. Tailor to your environment as needed

a) Run as user chuck:spacecadet
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. In it, create override.conf 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=chuck
#
# 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:chuck. 

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 with systemctl edit plexmediaserver

Please DISABLE Verbose logging until requested

Please search before posting

Primary support forums: Linux, Synology, and QNAP

Please remember to report back. This benefits others.

Useful links

 Installation and Basic Setup |  Media Preparation (How to name your media files)  |  Linux Permissions 

 Handling TV Specials | Handling Movie extras  |  Nas Compatibility List

 Reporting Plex Server issues | Plex Media Server FAQ | Linux Tips

 

Other useful guides: Local Subtitles | The Plex "dance" | Synology FAQ | PMS Release Announcements

Hosts: Fedora, QNAP, Synology, most Linux distros in VM

No technical support via PM unless offered

Please remember to mark the appropriate answer(s) which solved your issue.

 
Tagged:

Comments

  • ChuckPAChuckPA Posts: 20,315Members, Plex Pass, Plex Ninja, Plex Team Member Plex Team Member
    edited June 2017

    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. Continue normal operation from this point forward with metadata now stored in /home/plexdata

    Please DISABLE Verbose logging until requested

    Please search before posting

    Primary support forums: Linux, Synology, and QNAP

    Please remember to report back. This benefits others.

    Useful links

     Installation and Basic Setup |  Media Preparation (How to name your media files)  |  Linux Permissions 

     Handling TV Specials | Handling Movie extras  |  Nas Compatibility List

     Reporting Plex Server issues | Plex Media Server FAQ | Linux Tips

     

    Other useful guides: Local Subtitles | The Plex "dance" | Synology FAQ | PMS Release Announcements

    Hosts: Fedora, QNAP, Synology, most Linux distros in VM

    No technical support via PM unless offered

    Please remember to mark the appropriate answer(s) which solved your issue.

     
This discussion has been closed.