Skip to content

Instantly share code, notes, and snippets.

@pgee70
Last active March 9, 2026 08:12
Show Gist options
  • Select an option

  • Save pgee70/1728bebb71fcf5341358ae9f2b846919 to your computer and use it in GitHub Desktop.

Select an option

Save pgee70/1728bebb71fcf5341358ae9f2b846919 to your computer and use it in GitHub Desktop.
ubuntu plex move server instructions

ubuntu plex move media folder location instructions

yeah, so you want to move the location of the plex media server files? perhaps you got some new shiny hard drives to store your media?

steps

  1. don't do it.
  2. see step 1

but really, how do you do it? my drives are so shiny!

so if you have plex media server installed via apt-get, you have sudo access to your linux box, and the location of the server is in the path /var/lib/plexmediaserver/Library/Application Support/Plex Media Server then these instructions may help, or they may not. either way you are on your own.

lets assume you have the files copied onto your new directory.

plex has two spots is appears to store the file paths: in the sql lite database tables: media_parts and section_locations

in my case, i updated the from the path /zfs-raid/media to the path /mnt/media/

# stop the plex server
sudo systemctl stop plexmediaserver.service
# make a backup of the file.
sudo cp '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db' ~/only-l0sers-make-backups.db
sudo '/usr/lib/plexmediaserver/Plex SQLite' '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db'

# now you are in the sqlite language, enter:
update media_parts set file=replace(file,'/zfs-raid/','/mnt/') where file is not null;
update section_locations set root_path=replace(root_path,'/zfs-raid/','/mnt/') where root_path is not null;
.quit

# make sure you have read/write permissions for the database file.
ls -Al '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases'
# look for line like: rw-r--r-- 1 plex plex  396904448 Mar  9 18:45 com.plexapp.plugins.library.db 

# now, the plex server needs to start, so lets get that done.
sudo systemctl start plexmediaserver.service

# if it breaks, the logs are stored here, and are useful to view.
ls -Al '/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs'

# if plex is working remove your backup - but you didn't do that right?
rm ~/only-l0sers-make-backups.db 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment