With our ever increasing media libraries containing movies, TV shows, music and pictures we need something that can serve this content to any of our devices.
If you fancy opera in the kitchen, jazz in the bathroom and the latest Hollywood blockbuster in your pocket, then you need a media server and the Raspberry Pi 2 is the ideal low cost candidate.
To replicate this project you will need:
- A laptop running Windows/Mac or Linux
- A minimum of 8GB SD card
- A 2A power supply
- An Ethernet cable connected to a router.
- An external USB hard drive
We start the project by installing the latest version of Raspbian on to an 8GB or greater SD card. The best tutorial on how to do this is provided by the Raspberry Pi Foundation and can be found on their blog
With Raspbian installed we now need to boot our Raspberry Pi. Insert the microSD into the Raspberry Pi, then attach any peripherals such as keyboard, mouse, HDMI, Ethernet to the Pi. Lastly attach the power cable to boot the Pi.
When your Pi has booted to the desktop, click on the menu to the top left of the screen and go to the Preferences menu. From there select the Raspberry Pi Configuration application.
In this application we need to change the boot behaviour so that the Pi boots to the terminal and is logged in. We’ll also change the memory for the GPU to only use 16MB of RAM, and overclock the Pi 2 to 1GHz.
With these changes made, save and exit the application. You will be asked to reboot, do so before progressing.
With our Pi rebooted we now find ourselves at the terminal. It may seem a little scary at first but the terminal is the best way to work with a Linux computer.
Our next goal is to install the software necessary for our Pi.
First we update our list of available software. In the terminal type.
sudo apt-get update
The update will take a few moments to complete. When the terminal is returned to you enter the next command to install the HTTPS transport package to enable access to HTTPS content over the Internet.
sudo apt-get install apt-transport-https -y --force-yes
Next we shall download a key that will authenticate our downloads to ensure they are safe
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -
With the key downloaded we now add a new repository to our list, this repository is provided by dev2day.de who has worked on the packages that will power our Plex install.
In the terminal type
echo "deb https://dev2day.de/pms/ jessie main" | sudo tee /etc/apt/sources.list.d/pms.list
We now update our list again, to ensure that we now have the latest updates for the Plex Media Server.
sudo apt-get update
Lastly we install the Plex Media Server software.
sudo apt-get install -t jessie plexmediaserver -y
The install will only take a few minutes and once completed the Plex Media Server will automatically start as a background service on your Pi.
Fix IP address of the Pi
To ensure that we can discover our Pi on a network we will now fix the IP address of the Pi.
First we need to find out the IP address, in the terminal type.
Write down your IP address!
Now let's fix the IP address, in the terminal type
sudo nano /boot/cmdline.txt
At the very end of the line we will add the IP address that we earlier wrote down. So type
ip=THE IP ADDRESS YOU WROTE DOWN
With the IP entered press CTRL + O, then Enter to save your changes.
Now press CTRL + X to close the file.
Now reboot your Pi to make the changes permanent.
With your Pi rebooted we shall now test that we can access the Plex server. On your laptop or desktop PC open a web browser and type your IP address followed by :32400/web so for example I typed.
This will now open the Plex Media Server software and we will need to read and accept the Terms and Conditions before progressing.
Once Plex has loaded take a few moments to get familiar with the interface. Specifically the libraries, which will house your media collection.
The SD card of our Raspberry Pi is rather small, so let's add an external hard drive and store our media there.
Plug in your USB drive. Nothing will happen in Plex until we mount the drive. In Linux, mounting a drive means that it is ready to be used. On your Raspberry Pi, in the terminal type
You will see a lot of text whizz up the screen but keep a look out for your hard drive.
So now lets create somewhere to link our hard drive to the Raspberry Pi this will be a directory called “library”. In the terminal type
sudo mkdir /mnt/library
Now we shall open a text editor and add a line of code to mount the drive on boot. For our drive we used a FAT32 formatted drive. As this is the only USB drive it will be given the assignment “sda” and if the drive has one partition, where our data is stored, then it will be “1”. This gives us the location of our media which is “sda1”.
sudo nano /etc/fstab
So now we shall mount our drive, got to the last line which starts with a “/” and make a new line under it. Enter the following and try and keep your spacing similar to those above.
/dev/sda1 /mnt/library vfat defaults 0 0
To save your work press CTRL + O followed by Enter. Then to exit press CTRL + X.
Reboot your Raspberry Pi.
Once the Pi has booted back up navigate to your content by typing.
Now we need to see where our content is, so to find it type
You should see lots of directories and files, just as you arranged them on your main computer.
Our next step involves enabling access to the files for any user. As our server will be in our home we shall enable access to all of the content for all of the users. Typically this is not the done thing for big servers in production but for our server this is fine. So to enable access we need to type
sudo chmod 777 -R /mnt/library
Now this might take some time so be patient.
So now that we our drive ready to serve our media, let's start using it!
Back to our laptop/PC and open your web browser to your Plex Media Server.
You will be prompted to add a library, so go ahead and do so. Now which library you add depends on what you have. I chose to add a couple of TV series. When ready click on “Add Library” to import the media.
Depending on the amount of media that you have to import this process may take minutes or hours, so please be patient and wait for the process to finish.
When the media is imported, Plex will try its best to grab the metadata, the information about the content such as genre, IMDB data, actor details etc.
Multi User Access
The huge benefit of Plex is that any user on the home network can access any of the media in the library. So children can watch their favourite films on the mobile device, parents can listen to music or podcasts or share their family photos on their laptops.
Plex can also be streamed to a chromecast device, enabling high definition movies to be enjoyed on the big screen.
Listen to all of your music across your entire home and all you need is a Raspberry Pi and a little Linux know how.