Home Media Server using Raspberry Pi & Plex
A comprehensive step by step guide, covering everything you need to know to install, run and maintain Plex Media Server running on a Raspberry Pi shared across your network.
Plex is a powerful media server which make your videos, music and photos accessible on all your favourite devices; Web, Android, iOS, Windows, Xbox, Chromecast, Smart TVs and more.
Plex indexes all you Movies, TV shows and Music, gathers beautiful posters and artwork, cast and crew info, Rotten Tomatoes ratings, and provides a nice clean interface where all your media can live and come alive.
Plex needs a running server instance on a machine locally on your network. Raspberry Pi can be a perfect in-expensive solution for an always on, low energy media server. Raspberry Pi is a tiny and inexpensive (~50$) computer.
An external Hard Drive with external power is needed as well to hold all your files. Raspberry Pi is not powerful enough to power the external hard drive, thus external power source is needed. In the following steps I’ll go through setting up a Plex Media Server on a Raspberry Pi (RPi 3 is the latest and fastest model with a 1.2Ghz cpu and 1Gb ram) with a 1TB 3.5 HDD in an enclosure and USB interface on a micro SD card.
b. Preparing your Raspberry Pi
c. Static IP for the Raspberry Pi
d. SSH-ing the Pi
e. Installing Plex Media Server
f. Preparing the disk storage
g. Setting up Plex
h. Keeping the server up & running autonomously
i. Monitoring your Pi
j. Updating Plex Media Server
k. Raspberry Pi as a client
- Raspberry Pi 3
- Raspberry Pi power adapter
- 8GB (or greater) micro SD Card class 10 (or faster) (and a card reader, duh)
- Router with internet & ethernet port
- Network cable
- Monitor with an HDMI connection, USB Keyboard and USB mouse (temporarily for the initial setup)
- External USB Hard Drive (the bigger the better) with an external power source
- Cable tie
- Can-do attitude!
Preparing your Raspberry Pi
To start we need to prepare the OS for install on the SD Card, setup the hardware and connect everything for initial setup.
IMPORTANT NOTE: from now on any terminal commands in block with ‘ < … > ’ as value, means that you must replace ‘ < … > ’ and the value inside with the variable value depending on your setup or information gathered in a previous step. Ex: ‘ssh pi@<18.104.22.168>’ becomes ‘ssh firstname.lastname@example.org’ where the new IP address comes from a previous step.
- Let’s start with downloading Raspbian first, an OS based on Debian Stretch (4.9) optimized for RPi hardware. Download the image from: https://www.raspberrypi.org/downloads/noobs/ (use full not lite). Download on your PC or MAC which has a card reader connected.
2. Use the Card Reader to format the microSD Card (use FAT32 as file format system)
3. Install Raspbian image on the SD Card using NOOBS installer. Follow the official guide: https://www.raspberrypi.org/documentation/installation/noobs.md
4. After completion, safely remove SD Card and Insert the SD card into the RPi. Attach the keyboard, mouse, monitor and network cables to the RPi (other end of network cable goes into your router). Finally attach the power cable and turn on the power to start your RPi.
5. Once the RPi starts, go to Menu (top left) > Preferences > Raspberry Pi Configuration
6. In the following setting screen change the following settings:
From System Tab:
- Boot is set to CLI (Terminal)
- Change password (create a new one, default is ‘raspberry’)
- Change your hostname to your likings, like: ‘plex-media-server’
From the Interfaces Tab
- Enable SSH Server
From Performance Tab
- GPU Memory is set to 16 (lowest possible)
From Localisation Tab
- Set Locale as en(English) — US(United States) — UTF-8
- Set your Timezone to your local timezone
Finally click OK and you will be prompted to reboot your Raspberry Pi. Important, CHOOSE NO for now and close the configuration window.
Static IP for the Raspberry Pi
Home routers are commonly DHCP meaning that they will assign an IP randomly from an available set to each connected device. This can make things difficult if we need to login remotely (ssh) on our RPi. Thus, we need to set a static/fixed ip for the Pi.
There are two ways to go about this, either setup the router to reserve an IP by the device MAC address or edit the network interface in the RPi to have a fixed IP. We’ll do the latter.
From the top menu, go to Preferences > Add/Remove Software
In the search box found in the top left corner, search for ‘wicd’. Once the results appear, tick the one which is titled ‘wired and wireless network manager — metapackage’. Now click Apply button followed by the OK button. This might take a couple of minutes. Once done, it will look like the screen below. You can close this window.
Once the WICD Network Manager is installed, open it from top menu > Internet > Wicd Network Manager
WICD will show you the current connected network:
Now also open a terminal window side by side (4th icon on the top bar). Also, click on Properties button of the connected wires network.
In the terminal run the following commands:
NB: from now on any terminal commands will look like the one above. Any command with sudo might ask you for the password you just created in the previous step
The current RPi IP Address = 192.168.0.106
Now we need to get more information about our router:
We need to take note of the Gateway IP (IP of the router)
Gateway IP (Router) = 192.168.0.10
Now map the IP, Netmask and Gateway (router IP) like below:
As for the DNS, you can use the following:
DNS server 1: 22.214.171.124
DNS server 2: 126.96.36.199
Once saved, we can test that the changes took effect by disconnecting and re connecting the network. Either at the bottom of WICD or from terminal ‘ifconfig’ command, you can check the ip.
Pro tip: Apart from the IP which the router assigned, you can change the last 3 digits if the IP to your liking as long as they are in the network range and set that as the static IP.
This video goes into detail of setting up static IP with WICD from command line to if you want to delve a bit deeper: https://www.youtube.com/watch?v=3vQumH1iAB0
After you’re happy with your static IP it’s time to restart the Pi. The Pi now will restart in Command Line Mode since that’s how we changed it previously. Next, we’re gonna make sure everything is up to date before we store the Pi away and continue working from our PC/Mac.
The rest of the step by step guide is in the PDF below.
Not convinced yet? See the result below!
After 1 year running now, the RPi never failed and worked flawlessly providing many devices (Rasplex on another RPi attached to TV, Xbox One, Fire Stick, mobile phones & laptops) with movies and tv shows.
Some things to note: If you are copying files on the external drive via network or Plex is busy indexing and getting metadata for the new media added, I highly recommend letting the process finish first before streaming/watching anything. Failure to do so might result in the RPi freezing.
Regarding streaming to multiple devices at the same time, I tested for 10 minutes playing two different videos to two different devices. Quality was set at 3Mbps 720p. Video quality was good & remained constant and never stopped waiting for any buffer. CPU usage varied, sometimes using 20% sometimes 100%. Memory was used in full. Results below:
I’m getting ‘Permission denied’ when I run commands.
You need more rights to run this command. Add ‘sudo’ infornt of your command, if this doesn’t work you can switch to root user with:
I’m getting a ‘cannot set LC_TYPE to default locale’ message when installing packages.
edit the bashrc:
sudo nano ~./bashrc
at the end of the file add
save the file (CTRL + X , press Y and Enter), than run
test if works