Updated: September 9th, 2020: I had to redo all of this all over again and some steps have changed, so I’ve updated it.
I don’t often yack about this kind of stuff on my blog as it’s pretty much exclusively an art blog, but I recently bought a Raspberry Pi B+ that I thought I could use as a lower powered Plex Media Server rather than having my (dying) iMac run constantly. This is both in an attempt to prolong the life of my iMac and to help my incredibly high electric bill (whoops). While there are lots and lots of tutorials on how to set up Plex Media Server on a Raspberry Pi B+, I couldn’t find one that went through all of the steps I needed. So I’m going to compile them all here!
What you’ll need:
- Raspberry Pi B+ (Amazon.com has CanaKits for around $55)
- External USB Storage
- Wall-powered USB Hub (The Raspberry Pi does not have enough power to power USB storage devices on its own most of the time. If your Pi is running slowly or your server is having weird issues, if you’re not on a hub, this might fix your problem)
- Ethernet connection (You can connect via wi-fi, but your fastest connection will occur via ethernet)
- Class 10 SD Card (You can use a different class SD card, but class 10 is the fastest and you want to give your server a good running start)
- Mac or PC to pre-load the Raspbian operating system
- Wired keyboard and mouse for easiest access (The Pi comes with Bluetooth but it’s just easier with a wired keyboard and mouse)
Note: Raspberry Pi, even the B+ model, doesn’t have an incredible amount of a. RAM (1 GB) and b. processing power. Transcoding via Plex Media Server might be difficult or impossible (read: lots of buffering). If you want to share the server with a lot of people, I would suggest not using a Raspberry Pi.
Setting up your Pi out of the box
In this section I’m going to talk about how to set up your Raspberry Pi through Mac OS X. Since this is the only experience I have, I can’t tell you how to set it up via PC, but there are plenty of tutorials online that can show you how to do this. There are also instructions available on the official site.
What I used:
- 64 GB SanDisk Class 10 Micro SD Card
- SD Card Adapter
- Disk Utility
- Raspbian Stretch Package (Available for download here)
Go ahead and go to the Raspberry Pi website and download your choice of operating system. If you are totally new to using Terminal or otherwise, you might choose to go the NOOBS route, which is totally fine. I’ll tell you how to set up your Raspberry Pi by downloading the Raspbian Stretch with Desktop. The download is about 1.7 GB so think of this a little bit of pre-work.
While you’re waiting for that to download, now would be a good time to format your SD card. Put it in the adapter and insert it into your computer. Open Disk Utility, click on the SD card nested under External, and click “Erase”.
Note: Raspberry Pi does not support exFAT systems, nor Mac OS Extended (Journaled) aka HFS+… At least not in terms of an internal storage device. For that reason, you’re going to want to erase the system as FAT (MS-DOS). What you want is for it to format to FAT32. If you’re using an old SD card and you erase the SD card using disk utility, and it says it’s FAT16, chances are your SD card is too old to support FAT32.
Set it to erase as MS-DOS (FAT).
Here you might run into some issues like I did. I kept getting all kinds of errors trying to reformat the card. I can’t remember the exact errors, but it kept failing an erase. If this happens to you, unmount the SD card and pull out the adapter. Look at your adapter. Is there a little switch on the side? You may need to flip the switch. In my case, I had to flip the switch 75% of the way before it allowed me to reformat the card successfully. In other cases you may have to flip the switch and click erase twice… Disk Utility is finicky like that.
Before you’ve finished with Disk Utility, use it to find out where your SD card is located. It should be listed under “device” i.e. disk0s2, or disk1s2. It’s going to be “disk0” or “disk1”, minus the s2 part. Unmount your SD card, but don’t remove it physically from your machine.
Once you have your SD card formatted and your Raspbian Stretch with Desktop downloaded, go ahead and find your download… Probably in your downloads folder. Unpack the zip so you have a .img instead.
Crack open Terminal.
Figure out where you are by typing
Basically you’re going to need to figure out the path to the Raspbian img. In my case it’s in my downloads folder, so I’m going to type
From here I could type
ls and make sure that the Raspbian img is in there, but I know it is, so I’m going to go ahead and copy it now. In the terminal I am going to type:
sudo dd bs=1m if=raspbianfilename.img of=/dev/rdiskn conv=sync
Remember the device path I had you look for before? Make sure that you change the “n” after “rdisk” to the number you found before. Let’s say mine was disk1, so I’m going to change the path to “/dev/rdisk1”
Let that run! Once it’s complete, it’s going to bounce you back to your command line. Once that’s finished, congrats, you’ve just installed the Raspbian OS onto an SD card!
Now go ahead and take out your SD card and put it into your (assembled) Raspberry Pi. Get your Pi plugged into where it’s going to live (or you’re going to be using a monitor) and strap in ’cause we’re going to do some other cool things too.
Once you plug in the power cord your Pi will turn on, so connect that last. There’s no power button or switch on the Pi at this time unfortunately.
Switch your language settings
This may or may not affect you but the default language for the keyboard setup for your Pi is Great Britain. If you’re in the US using a US keyboard, you’re going to want to change that. Go ahead and open up the terminal on your Raspberry Pi and type:
Scroll down to
localisation options and set your language, keyboard layout, and time code preferences. You should be able to move around using the up and down arrow keys on your keyboard. Pressing the right arrow key will bring you to the select and finish buttons.
Let’s get cracking on that Plex Media Server!
There are options here, but I got stuck somewhere in the middle, so let me explain how I did it.
The first thing you’re going to want to do is to update your Pi and make sure it’s got all the packages it needs. Run:
sudo apt-get update
sudo apt-get upgrade
This might take a bit. Go get a snack! Once that’s done, we’re going to want to check some things. Run:
sudo apt-get install apt-transport-https
If you already have this installed, it’ll tell you, but you need it so run it anyway just in case.
Next up is grabbing the repository that contains Plex:
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -
(That’s a capital O, not a zero or a lowercase o) Now add it to the package list:
echo "deb https://dev2day.de/pms/ jessie main" | sudo tee /etc/apt/sources.list.d/pms.list
July 2019 update:
Plex Media Server is now officially available, so you will no longer need the dev2day repository. This code is what you can use to patch yourself over if you’re using an old version with the dev2day repository, but you should register the key to the package manager and add the official Plex repository to the source list as outlined below in the September 2020 update.
September 2020 update:
Use this next step to add the key to the package manager:
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
Then add the official Plex repository to our source list:
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
And update it, of course:
sudo apt-get update
Time to download Plex Media Server! Run:
sudo apt install plexmediaserver
Set a static IP
Next you’re going to want to set a static IP address for your Pi Plex server. Run this:
It will give you your current IP address. Copy it down (or remember it).
sudo nano /boot/cmdline.txt
Go to the end and add
ip= then your IP. Control X to save, y, and then enter to overwrite. Great! Let’s restart your Pi to make sure everything is in effect.
*Sometimes I have difficulty getting the static IP to work in cmdline.txt, so there is an alternate way to do it. You’ll want to know your router’s IP, as well as domain name servers (find this by running ip route | grep default ). Here’s how:
sudo nano /etc/dhcpcd.conf
There should be a bunch of things commented out. You can delete the # in front of the stuff you want. interface eth0 static ip_address=192.168.0.4/24 can be changed to the internal IP you want your Pi to have at startup; add your router IP and domain name servers as well. eth0 is for ethernet, or wired internet. If you also want to change the wireless IP, look for wlan0 and modify that.
Making sure Raspbian can read your USB drive(s)
Now I know you’re excited to get in and start customizing your Plex Media Server, but there’s a few things that can hinder that. First, you have to make sure that your Pi can at the very least read your hard drive(s). The first thing you’ll want to do is make sure that you have support for your drive format.
For HFS+ run:
sudo apt-get install hfsplus hfsutils hfsprogs
For exFAT run:
sudo apt-get install exfat-fuse exfat-utils
For NTFS run:
sudo apt-get install ntfs-3g
Personally, since all of my drives were formatted by Mac OS X, they were all HFS+, so I really only needed the HFS+ extensions.
Now, this is important. You’re going to want to make sure that your Raspberry Pi, now that it can recognize your disk file system, can actually read the contents in your disk. This is called permissions. Go ahead and run:
sudo chmod -R 777 /media/pi/
And possibly even further down with:
sudo chmod -R 777 /media/pi/drivename/
Great! Now let’s access your Plex Media Server and start adding some stuff.
Remember your IP address from before? Open up Chromium and type that in, followed by
:32400/web and hit enter. Now you should be able to start setting up and customizing your Raspberry Pi Plex Media Server!
Other Mac OS X Goodies
Another part of my set up I wanted was to be able to drop files into my Raspberry Pi over the network. In order to do this, I needed to install:
sudo apt-get install netatalk
Once this is done installing, you should be able to access your Raspberry Pi using your username and password (defaults are username
raspberry, definitely change that) using the Finder on the left sidebar under Shared… Click on All.
You might want to share other directories too other than just the Pi’s home directory, just edit this file:
sudo nano /etc/netatalk/apf.conf
Edit this file appropriately. The [Homes] should be where the home folders are (i.e. Mine is just at /home), but you can add additional paths. Here’s an example of some paths I added:
[TV Shows] path = /home/pi/TV Shows [External TV Shows] path = /media/pi/External Drive Name/TV Shows
Last thing I wanted was to be able to check up on the Pi without a dedicated monitor. How can I do that? Screen sharing of course! For that, you’ll just need to follow this easy-to-follow tutorial.
A restart here and there…
In the two years I’ve been having my Raspberry Pi act as my Plex server, I noticed that sometimes if running for extended periods of time it just… stops. I’ve decided that in order to help this, I am going to install a cronjob that restarts my Pi every month at 1 AM. Here’s how:
sudo crontab -e
I then add this line (a breakdown of what this means is available here):
0 1 1 * * /sbin/shutdown -r now
To check and make sure that your cronjob is running properly, set it to a time in the forseeable future and then run:
last reboot | head -1
To see if it restarted when it was supposed to.
Might I also suggest keeping backups? After dealing with what I just did, worthwhile to cronjob a backup!
0 0 * * * /media/pi/External Drive/backup.sh
Congrats! Have fun playing with your new Raspberry Pi Plex Server!