You NEED to have a Plex server

Growing up in Sri Lanka, the best way to watch western movies or TV series was to download and burn them to DVDs (or rent or get from friends). Until recently (6–7 years), Netflix was not a household name in Sri Lanka due to many reasons mainly being the bandwidth limitations.

But when SLT introduced the off-peak GBs and Dialog had the “50rs-1hour-unlimited browsing” package, everyone who was into the whole collecting movies/tv-show started downloading shows in bulk; and I did the same. Because of this, back in the Uni, we literally had a community called “Movie + Tv Series downloaders and sharer’s community” 😅. The whole purpose was to download and share movies and tv-shows among friends, so everyone will have access to almost all the shows and no one has to download the same thing again.

To collect these shows, I had to buy external hard drives. Because what I did earlier was to burn everything onto DVDs and keep them saved in my cupboard. Investing in an external HDD made more sense even it was just for this silly purpose so I started with just 500GB and when I finished Uni, I had a total of 8TB external HDDs.

That was good and fun back then, but when Netflix came to the picture, spending 9USD was easier than taking an external HDD everywhere, I kinda forgot about the stuff I collected over time. When I first moved to Canada, I only brought 1 external HDD, because I didn’t see the use of it as Netflix had almost all the shows I like (that’s what I thought) and external HDDs are heavy. But due to content provider restrictions, many of the movies and tv-shows are not allowed on Netflix-Canada, and to watch them, I had to subscribe to other services. (ex: Friends is not available on Netflix-CA, only on Crave.ca). When I returned to Sri Lanka last year, one of my main goals was to bring back all my external HDDs, so at least I can plug and watch them.

After bringing all the HDDs, the next problem was plugging and watching was a real pain. If I want to watch it on TV, then plug the ex-HDD into the TV, if I want to watch it on my laptop, use the adapter and plug the ex-HDD into the laptop, etc. and there was no way to watch stuff on the phone or the tablet.

I started looking into investing in NAS (Network Attached Storage) after watching a few Linus Tech Tips videos. But soon I realized, what’s in the market is way over my budget for simple use and they are overkill. So I started looking into smaller and cheaper options. Then I found out about this video.

This was like a gem for me because it covers everything I wanted. So I started gathering stuff to build my Raspberry Pi — NAS.

Note: I’m not going to list down all the instructions, because it’s already covered in this video. But I’ll be listing down all the commands, as it’s missing on the video.

These are the stuff I bought:

For all this, I spent around CA$ 320+tax. But note that the price of the RPi had skyrocketed maybe due to the supply chain issues.

Alright, now these are the steps:

Step 1: Bake the Pi 🥧

  • Insert your SD card into a card reader and plug it into your laptop.
  • Download the RPi installer and install it on your laptop
  • Run the program and fill the boxes with the required details.
  • When selecting the OS make sure to select the Lite version if you are planning to proceed with the headless (SSH) approach.
  • Then select your SD card for the storage and enter “cmd + shift + x” or on windows “cmd + shift + x” to open advanced options. From here just enable SSH and set the password for the user and click Save. You can change other options if you need to.
  • Lastly; hit “Write” and your Pi is now baking.

Note: As I mentioned, if you are going with the SSH route, select the lite OS. If you select the full version, it will give you an error when installing the Open Media Vault via ssh.

Step 2: Connecting to the RPi via SSH 🔗

  • Insert the SD card with the fresh OS install to your RPi.
  • Next, follow up with plugging in the network cable (comes from your switch/router) and then the power cable.

As soon as your RPi boots up, log into your router and get the IP address of the device. If your router is capable of setting up static IP addresses for devices, I recommend you do that for the RPi for easy access.

Once you have the IP address (ex: 10.x.xx.xx) of your RPi, now let's connect to it via SSH. Before that, first, ping the IP and check whether it’s online.

ping 10.x.xx.xx

if the ping is a success, then press control+c to exit, and now lets ssh. the text pi you have before the @ is the username you added when baking the RPi.

ssh pi@10.x.xx.xx

Note: if you have only one RPi connected to your network, you can use the following to connect to your pi as well;

ssh pi@raspberrypi.local

it’s going to ask you to enter the password (if you haven’t set one up, the default is raspberry), and then voila; you are in.

Note: If you are having issues with connecting to the Pi after several times, or getting the “WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!” error; just enter the following command to reset.

ssh-keygen -R 10.x.xx.xx

Step 3: Updating the Pi and Installing Open Media Vault 🖥

I’m gonna list the next few commands in order, so it won’t be a lengthy explanation and if you want one, please watch the video above.

  • Update the Raspberry Pi
sudo apt update && sudo apt upgrade
  • Install OpenMediaVault: OpenMediaVault is a free Linux distribution designed for network-attached storage. The community support and the versions are solid as of now and it’s very easy for even a noob to get the hang of it.
sudo wget -O — https://raw.githubusercontent.com/OpenMediaVault-Plugin-Developers/installScript/master/install | sudo bash

or

wget -O - https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash

This is going to take some time and once you are done with it, enter your RPi’s IP address in your web browser and it’s going to take you to the following webpage.

username: adminpassword: openmediavault

As soon as you log in using the default username and password, click on the top-right gear icon ⚙️ and change the password.

Step 4: Setting up the HDDs 💾

The first step is to plug in your external HDD. Before that, there’s something that you should be aware of. When you are setting up the shared drive and the services, if your HDD has already has data you won’t be able to proceed with setting up NFS. It will return an error and the way to proceed is to format the HDD and re-mount the HDD. That being said, you can proceed with no problem at all and you can access the NAS on Windows, Mac & Linux. That being said, you might have an issue with writing to the drive over the network. So if possible go with a new HDD (I know that defeats the whole purpose, but it’s entirely up to you).

Mount the HDD

  • Go to Storage → Disks and check whether you can see your ex-HDD there.
  • Then go to Storage → File Systems , click on the + button and mount your ex-HDD.
  • Then you will be able to see something like this

Whenever you make any change on OMV, you will get a yellow banner on top of the page to apply the changes. Unless you click on apply, all your changes will not have an effect. As a practice, apply your changes while working on things.

Create a Shared Folder

  • Go to Storage → Shared Foldersand click on the + sign to add a shared folder.

From here, you can give a name to your shared folder, select the file system, add basic permissions, and save the shared folder.

But note that when you are clicking save, you might get a permission error. If you get that, click cancel, go back to the list view, click on the unsaved shared folder list item and click on Privilages. It’ll take you to the following page and change the permissions to Read / Write for the user and click Save. If you go back to the shared folder save view, now you’ll be able to save that folder.

Setting up Access (NFS, SMB, etc.)

This process is straight forward but this is where you will face the issue I mentioned earlier.

To add service, click on Services → SMB/CIFS → Settingsor Services → NFS → Settingsand click enable. It’s simple as that. After enabling, click on the Shared option and add the shared folder to these services. When you try to apply the changes, you will get an error (500), and to resolve that, you will have to format and remount your HDD. It’s because of a compatibility issue with NFS, but if you are just going to use SMB, there’s no problem at all. You can access the NAS from both Windows and Mac.

Accessing your NAS

If you did everything as mentioned above, your NAS should be up and running. Now, let's access it. On Mac, open the Finder app and click on Go → Connect to Serverfrom the options or just press cmd + k. This will open the connect to server window and here add the following and click on Connect 🤞.

smb://10.x.xx.xx/SharedFolderName/

If the connection is successful, now you can see your NAS under your locations on your mac. But wait, you don’t see any of your content there 🤔. Now let's fix that, shall we? The reason for you to now see the content, is because you created a shared folder in the ex-HDD, so now it’s a child folder of the HDD. You need to unplug the HDD from the RPi, connect it to the laptop, and move all the content that’s outside of the Shared folder into the folder. Reconnect the HDD to the RPi, and voila; you have all your content in a NAS.

After going on a huge tangent, let’s come back to the actual topic. What’s Plex and how to install it onto your Raspberry Pi NAS. The easiest way to explain what Plex is that’s it’s your own Netflix. You can consume media on your storage devices from any client device using their modern and user-friendly apps.

You can sign up for a free Plex account and use that to access your library. They have the paid options and well with more features, but it’s not needed for our day-to-day use.

But why did I set up a NAS before setting up the Plex server? You can of course go ahead without the NAS and just set up the Plex server. But the problem you will face is that, if you want to add more content, you will have to unplug from the RPi, connect it to the laptop and copy content (or if you install the full OS, you can use it as a regular computer with a monitor and an IO tools). But with a NAS, you can easily access the HDD and manage content there and the Plex server will be automatically updated.

Step 5: Install Plex Media Server 📺

  • SSH back to your RPi
ssh pi@10.x.xx.xx
  • Install the apt-transport-https package. This package allows the apt package manager to retrieve packages over the https protocol that the Plex repository uses.
sudo apt-get install apt-transport-https
  • Now add the Plex repositories to the “apt” keyrings directory
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
  • Update the package list and install the latest version of the Plex Media Server. Around 40% of the installation, you will get a prompt to enter Y or N. Go with N (no) for the easy installation.
sudo apt update
sudo apt install plexmediaserver

If you didn’t get any errors, that’s it! You’ve successfully installed Plex on your NAS. Now type the following on your browser to set up Plex Media Server.

http://10.x.xx.xx:32400/web

Note: if the setup page takes a long time to load, just refresh the page and it’ll take you back to where you should be.

After the setup is done, you can start adding your media to a Plex library. Select the type and when adding the folder, you can add them from your NAS. It’s easy as that.

This is a very inexpensive and interesting project for me to try on because, with all the data I manage, this was a no-brainer. I’m planning to continue on this build by adding other features to the Raspberry Pi and if you are interested, consider subscribing to the newsletter.

Alright, folks! That’s it for now. If you have any questions or any suggestions, feel free to comment below.

Signing off:
Kavindu Narathota
(www.narathota.com)

Update — March 27, 2022

How to Update the Plex Server to the latest version

From time to time, you might get an alert on your Plex server to update it to the latest version. You can check the version or if there are any updates on the General Settings page as well. While there are so many ways to update the server, the easiest way I’ve figured out is to update it via openmediaserver update settings. Just go to http://10.x.xx.xx/#/system/updatemgmt/updates and refresh the page and update the required package. It’s easy as that!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kavindu Narathota

Kavindu Narathota

After working in the tech industry for a while, I learned a thing or two about Software & Product Engineering. www.narathota.com