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!

How to move Plex's data on Linux

ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,102 Plex Team Member
edited June 2016 in Linux

The purpose of this 'How To' is to show you how to move your existing PMS data directory ( /var/lib/plexmediaserver) transparently to another location, either locally or on your NAS.

In this example, 'systemctl' (systemd) is used. Use the command appropriate for your system

Points to consider:

  1. First, pick a location which has enough space (now and the foreseeable future). "/home" usually makes a great location for this since it survives OS installations and upgrades. /home/plexdir is used in this example.
  2. The location should not be something dynamically mounted (external USB, etc).
  3. The new location must be mounted automatically when the machine boots (before Plex is started). This means an entry exists in /etc/fstab for it.
  4. It is strongly advised to keep the new location at the 'top level' of the new file system location (root dir of a hard drive or top of a NAS share)
  5. If you do place your Plex data on your NAS / local lan, be advised to take care in making certain user 'plex' has all the appropriate permissions on the other machine

Performing the actual move

# Get a root shell for the following commands
sudo sh

# Stop Plex (use whatever command / method you normally use to stop Plex)
systemctl stop plexmediaserver 

# Create the new destination directory ( I will use /home/plexdir in this example )
mkdir /home/plexdir

# Set ownership permissions
chown plex:plex /home/plexdir

# Copy the existing library to the new location 
cd /var/lib/plexmediaserver
tar cf - . | (cd /home/plexdir ; tar xf - )

# Move the current library out of the way  (to be deleted later)
mv Library Library.orig

# Create the redirection symbolic link
ln -s /home/plexdir/Library ./Library


# Start Plex and verify everything is ok.   
# If no errors were printed during the transfer, and you didn't skip any permissions steps, the move will be invisible.
systemctl start plexmediaserver

# Delete the original library
rm -rf /var/lib/plexplexmediaserver/Library.orig

# exit the root shell
exit

Comments

  • ChuckPAChuckPA Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 13,102 Plex Team Member
    edited August 2016

    Update

    As of PMS 1.0.2, you may now override some of PMS's default values as it starts on systems which use the systemd daemon.
    Tested systems include: Ubuntu 16, Centos 7, and all Fedora systems 18+.

    The values of interest you may override are:

    PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
    PLEX_MEDIA_SERVER_HOME_DIR
    PLEX_MEDIA_SERVER_TMPDIR
    PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS

    Additionally, you may directly override the User and Group PMS runs as.

    User=
    Group=

    For details, see the man pages for your system on how, and where, to put the override file. Of importance, you want a '[Service]' override. If this makes sense to you, you already know what to do

    Referring to the move procedure above:

    If you edit (override) the default values, you will not need to create the symbolic link back to the default location.
    You may skip the step:

    # Create the redirection symbolic link
    ln -s /home/plexdir/Library ./Library
    

    After you have tested your changes, you are free to delete the old 'copy' of the library.

This discussion has been closed.