How to move Plex's data on 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:
- 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.
- The location should not be something dynamically mounted (external USB, etc).
- 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.
- 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)
- 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