macOS external drive tips for Plex Media Server

I’ve been migrating my Plex Media Server to a newer mac mini and I’d thought I’d share a few useful things that I learned. Because the mac mini now has an expensive soldered-on non-upgradeable SSD, it necessitates the use of external or network drives.

1. Make sure the drive is mounted before starting Plex Media Server.

External drives don’t mount before macOS runs your Login Items, so it’s likely that the media drive won’t be ready in time if you just put the Plex Media Server app as a Login Item.

What you’ll likely notice in this case is that PMS does start, and seems to find your media files, but it won’t be able to monitor the drive for changes. If you ensure it’s mounted first, it will be able to listen for changes automatically.

Solution: use Automator to create an Application that runs a shell script. Save that application, and add this to your Login Items list instead of Plex Media Server. This is my shell script, which simply checks once per second whether the external drive exists before launching PMS. If it never comes up, it just times out after 300 seconds (5 min).

for i in {1..300}
do
	if [ -d "/Volumes/MyExternalDrive" ]; then
		open "/Applications/Plex Media Server.app"
		break
	else
		sleep 1
	fi
done

2. You can move your Plex Media Server data to the external drive as well.

Normally your server data will be stored at /Users/myusername/Library/Application Support/Plex Media Server but this will probably be many gigabytes of frequently written data, which like the media data itself we might want to store externally. PMS doesn’t have its own option for this, but you can still make it happen.

Solution: Replace this folder with a symbolic link. First, make sure PMS is stopped before making these changes (you can open the Activity Monitor, look for Plex Media Server, click the X and Force Quit). Move the Plex Media Server folder to your external drive. Now open Terminal and use ln to replace it with a symbolic link:

ln -s "/Volumes/MyExternalDrive/Plex Media Server" "/Users/myusername/Library/Application Support/"

What this does, is create an alias for that external drive folder that redirects to that external drive whenever it’s accessed. It pretends to be a folder on your main drive, but it physically exists at the linked location.

Note that for this to work, you also need to ensure that the external drive is mounted before starting PMS. Instructions for that are above in tip #1.

3. You can configure macOS to mount external drives at boot instead of at login.

This isn’t essential, but it can speed up the mounting process a little. With this enabled, external drives will be mounted before logging in, and should persist if you log-out and log back in. This doesn’t really help with the startup issue, since the drives can still take several seconds or more to mount, but if you frequently need to log out and log back in, this can make that go faster.

Solution: Type the following in Terminal, which only needs to be done one time:

sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin -bool true

4. Placing files into a shared folder doesn’t make them shared, by default, but this can be enabled.

Not directly to do with Plex, but if you manage your files over the network, and you have a shared folder, you might find that when you add a new file or folder inside the shared one, it becomes owned by one person, and other users can’t access it or delete it, etc. I dunno if this only affects SMB sharing with Windows users or what, but it’s a problem I’ve encountered…

Solution: Enable ACL and set the shared folder to inherit permissions.

First we need to enable Access Control Lists (ACL), which we only need to do one time:

sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AclsEnable -bool YES

Second, for each shared folder, we need to set the ACL permissions to inherit themselves onto new files. In this example, it gives full permission to the everyone group, but you might want to create a more limted group. This command will affect the given folder, and recursively all folders it contains:

sudo chmod -R +a "group:everyone:allow readattr,writeattr,readextattr,writeextattr,readsecurity,list,search,add_file,add_subdirectory,delete_child,file_inherit,directory_inherit" /Path/To/Shared/Folder

Once this is done, all the files placed in the shared folder can be accessed and modified by everyone in the given group.

3 Likes

I moved this to the Tips section of forum. Thanks for the write-up :slight_smile: