Storing Metadata on SMB Network Share

Folks,

Rather than try to put a square peg (SMB) into a round hole (where NFS is needed),
I’ve decided to write this out.

You need NFS because most Linux hosts & NAS systems do not offer the needed SMB services PLUS you’re on a Linux host where SMB support is marginal and non-native.

This post is the combination of two existing server-linux-tips which I’ve authored for tasks such as this.

  1. Your mileage will vary . This is not supported because we cannot guarantee the integrity of the NFS server.
  2. It will work beautifully , albeit it a bit slower -or-
  3. It will crash horribly and corrupt your data on the NFS server

So, it’s time to ride the wild software :wink:

This is not for the faint of heart.

  1. Server must support NFS v4 - prefferably NFS v4.2
  2. A share must be exported with R/W for the IP address of the PMS host where this runs from with no-squash
  3. Use of SMB on a Linux host, which uses POSIX file locking for database operations, will fail every time.

Here’s how it works. This is a working example. You are free to use it as-is.

A. Stop Plex

sudo systemctl stop plexmediaserver

B. Make a directory anywhere which isn’t a pre-existing directory (this means no use of /media regardless the state of Gnome)

sudo mkdir /PlexMetadata

C. Set the ownership to plex and set permissions

sudo chown plex:plex /PlexMetadata
sudo chmod 755 /PlexMetadata

D. Create the /etc/systemd/system/plexmediaserver.service.d/override.conf

sudo sytemctl edit plexmediaserver

  • In this file place:
#  Move Plex's metadata storage to the NAS
[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/PlexMetadata/LibraryApplication Support"
  • Save and exit the text editor

E. Create and test the NFS mount entries for /etc/fstab

  • In /etc/fstab, editing as appropriate:

ip.addr.of.server:/metdata-share-name /PlexMetadata nfs defaults,vers=4,rw,auto,sec=sys,nofail,bg 0 0

(( The above is ONE line))

F. Test the mount

sudo mount /PlexMetadata
mount | grep PlexMetadata

(if errors, or if vers=4 is not shown, iterate here until working and can write to the NFS share (suggest ‘touch’ command) )

G. Transfer existing Plex metadata to network share

cd /var/lib/plexmediaserver
sudo bash
tar cf - ./Library | (cd /PlexMetadata ; tar xf - )

(If errors, correct the Network share export and/or the mount. Repeat process until tar completes without errors)

H. Verify final path exists as it should:

ls -la “/PlexMetadata/Library/Application Support/Plex Media Server/Preferences.xml”

( If the above lists as owned by plex:plex then you are ready. )

I. Update systemctl

sudo systemctl daemon-reload

J. Restart Plex

sudo systemctl start plexmediaserver

K. At some stable point – Restart the host and verify full restart.

Keep the existing contents of /var/lib/plexmediaserver until 100% positive this is working for you.