Plex Media Server on Raspberry Pi 4

I have quite a few old DVDs but now don’t own a DVD player! I also stream buy any TV series or films from Google Play as can watch on the smart TVs in my house. Because of this I wanted the same flexibility with my old DVD collection so decided to use a spare Raspberry Pi 4 with an external SSD and stick Plex on it.


Raspberry Pi Initial Setup

I am not a fan of setting up Raspberry Pi’s via a TV screen and working through a GUI so I run them in ‘headless’ mode – no GUI access just SSH. This is very simple to setup and get the Pi immediately onto your home WiFi with SSH enabled.

  • Download the latest version of Raspbian (at time of writing this was Raspbian Buster Lite Feb-20)
  • Download the latest version of Rufus and copy the Raspbian image file onto the SD card
  • Once the copy is completed you need to create a file called ‘ssh’ WITHOUT a file extension on the root of the SD card. This will automatically enable SSH on the Pi at first boot
  • Create a file on the root of the SD card called ‘wpa_supplicant.conf’, open it up in a text editor and add the following, replacing where appropriate:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=«your_ISO-3166-1_two-letter_country_code»

network={
    ssid="«your_SSID»"
    psk="«your_PSK»"
    key_mgmt=WPA-PSK
}

You can now eject the SD card, insert it into you Pi and power up. You can then check the DHCP server on your router to find the IP address of the Pi and connect it.

From here there are just a few more standard things you need to complete on your Pi before getting onto Plex…

  • Update the Pi
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo dpkg-reconfigure tzdata
sudo apt-get auto-remove
  • Use raspi-config to change both the hostname and default password (yes, this can be completed via command line but is easier via the config)
sudo raspi-config
  • Reboot for changes to take affect
sudo reboot

Mount External SSD (USB)

Now that the Pi is all setup, we need to mount the external SSD which will be used to store the DVD rips.

  • Format the external drive as exFAT. Other formats can be used but for this, I am using exFAT
  • Plug into the Pi and issue the following command to see some details about the drive including the format type and name. In my case the name is sda1.
sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
  • As we are using an exFAT, we need to install the exFAT driver by issuing the following command:
sudo apt-get install exfat-fuse
  • Create a mount point for the drive
sudo mkdir /mnt/plexdrive
  • Mount the drive to the mount point
sudo mount /dev/sda1 /mnt/plexdrive
  • Verify the mount has worked by looking at the contents of your drive
ls -l /mnt/plexdrive

Automatic Mounting of SSD

Now that we have the disk mounted, we need to make it automatically mount at boot.

  • Get the UUID of the disk partition. In my example, my UUID is “1A9D-5867”
sudo blkid
  • Edit fstab file
sudo nano /etc/fstab
  • Add the following to fstab remembering to replace the UUID, mount point and format type if required
UUID=1A9D-5867 /mnt/plexdrive exfat defaults,auto,users,rw,nofail 0 0
  • Save and exit the fstab file
  • Test that everything has worked and the drive has mounted by rebooting the Pi
sudo reboot
<<when rebooted>>
ls -l /mnt/plexdrive

Plex Media Server Install

Now the whole reason for configuring the Raspberry Pi; installation of Plex Media Server!

  • Add the required packages
sudo apt-get install apt-transport-https
  • Before adding the official Plex repository, we need to add the correct key and then run an update
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
sudo apt-get update
  • We can then go ahead and install Plex Media Server from the repo
sudo apt-get install plexmediaserver
  • Once this is completed we then need to change the user the service runs under from Plex to Pi to avoid any permission issues now or in the future
sudo service plexmediaserver stop
sudo nano /lib/systemd/system/plexmediaserver.service
<<change plex user and group to pi>>
sudo chown -R pi:pi /var/lib/plexmediaserver
sudo systemctl --system daemon-reload
sudo service plexmediaserver start
sudo reboot
  • Once the Pi has rebooted you’ll need to open a browser and visit http://plexserver:32400/web/ to complete the configuration.

References

Leave a Reply

Your email address will not be published. Required fields are marked *