Skip to content

Instantly share code, notes, and snippets.

@mattpatterson94
Last active November 19, 2023 20:39
Show Gist options
  • Save mattpatterson94/771ca9f4a770ccb4eca468a9bf69484a to your computer and use it in GitHub Desktop.
Save mattpatterson94/771ca9f4a770ccb4eca468a9bf69484a to your computer and use it in GitHub Desktop.
Setting up Plex Media Server on Raspberry Pi (with NTFS automounting)
  1. Get the latest version of Raspbian LITE
  2. Download Etcher and install.
  3. Run etcher to burn raspbian onto your SD Card
  4. Place a file named ssh on the boot directory (you can mount the boot directory in disk utility)
  5. Place the SD card into the pi and boot.
  6. Run sudo raspi-config to set up basic initial config.
  7. Upgrade Raspbian
sudo apt-get update
sudo apt-get upgrade
  1. Check you have HTTPS transport package installed
sudo apt-get install apt-transport-https
  1. Install Plex Media Server package
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -
echo "deb https://dev2day.de/pms/ jessie main" | sudo tee /etc/apt/sources.list.d/pms.list
sudo apt-get update
sudo apt-get install -t jessie plexmediaserver
  1. Change plex user to pi
sudo nano /etc/default/plexmediaserver.prev

Change PLEX_MEDIA_SERVER_USER=plex to PLEX_MEDIA_SERVER_USER=pi

  1. Restart plex sudo service plexmediaserver restart
  2. Set your IP address as static
hostname -I

Copy the output from this command into the cmdline.txt file

sudo nano /boot/cmdline.txt

add ip=127.0.0.1 (replace the ip with your ip) to the end of the text in the file

  1. Install NTFS-3G. This will allow you to use NTFS drives easily
sudo apt-get install ntfs-3g
  1. Retrieve the UUID of the devices you wish to mount
sudo blkid

Output should look like this

lrwxrwxrwx 1 root root 10 Jan 1 1970 0AC4D607C4D5F543 -> ../../sda1 Note down the value of the UUID --> 0AC4D607C4D5F543
  1. Create a location for mount point:
sudo mkdir /mnt/volume

Give proper permission:

sudo chmod 770 /mnt/volume
  1. Mount the USB Drive and then check if it is accessible at /mnt/volume
sudo mount -t ntfs-3g -o uid=1000,gid=1000,nofail,umask=007 /dev/sda1 /mnt/volume
  1. Now, we will configure RasPi to do this after every reboot: Take a backup of current fstab and then edit
sudo cp /etc/fstab /etc/fstab.backup
sudo nano /etc/fstab

Add the mount information in the fstab file (replace UUID with your own):

UUID=0AC4D607C4D5F543 /mnt/volume ntfs-3g auto,users,uid=1000,gid=1000,dmask=000,fmask=111,utf8,nofail    0       0
  1. Reboot
sudo reboot

Voila! You should be able to access your plex setup via 192.168.x.x:32400/web

References

How to set up a raspberry pi plex server

How to setup mount / auto-mount USB Hard Drive on Raspberry Pi

Random Fixes

modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.14.50-v7+/modules.dep.bin'

https://askubuntu.com/questions/459296/could-not-open-moddep-file-lib-modules-3-xx-generic-modules-dep-bin-when-mo

Extras

Setting up Transmission
  1. Install
sudo apt-get update && sudo apt-get install transmission-daemon
  1. Stop Transmission
sudo systemctl stop transmission-daemon
  1. Edit the config file
sudo nano /etc/transmission-daemon/settings.json

Modify the following lines

"download-dir": "/media/the-hub/Movies",
"rpc-password": "raspberry",
"rpc-username": "pi",
"rpc-whitelist-enabled": false,
  1. Start transmission
sudo systemctl start transmission-daemon

Voila! You should now be able to log in via http://192.168.x.x:9091/transmission/web. using username pi, password: raspberry

REF: Set up transmission daemon on a raspberry pi

Set up HDD auto timeout

This guide is for if you wish to auto switch off your hard drives when they are not being used.

We will be using a package called hdparm

  1. Get the locator for your hard drives
sudo blkid

Copy the /dev/sdx. Don't include the additional 1/2/3 on the end.

  1. Install hdparm
sudo apt-get update
sudo apt-get install hdparm
  1. Modify the hdparm config
sudo nano /etc/hdparm.conf
  1. Add a configuration to the bottom of the file for drive
/dev/sda {
     spindown_time = 1
}
  1. Save and reboot

Set up port forwarding

Quick way to access plex and transmission via the internet is to set up port forwarding on your modem. Set ports 32400 and 9091 to forward to the IP of the raspberry pi, and then use the external IP to access plex and transmission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment