Home / Exciting tips / Linux / How to install Plex server on Raspberry Pi 4

How to install Plex server on Raspberry Pi 4

Installing Plex on Raspberry Pi 4 is possible, though it does take some work as the developers of Plex do not offer up an easy to download package for Raspberry Pi users. Instead, Plex is installed on Raspberry Pi 4 through a third-party software repository.

Please note that Plex on Raspberry Pi requires Rasbian Lite, the version of Raspbian, without a desktop environment. For information on how to set up Rasbian on your Raspberry Pi 4, head over to the official Raspberry Pi documentation. It will walk you through the setup process in detail.

In addition to Raspbian, Plex also requires a high-speed SD card to operate correctly. If you have a slower SD card and plan to use Plex on it, please consider getting one of the cards below instead. It will drastically improve media playback performance.

Using a Raspberry Pi 3? We have a guide for that too.

Updating Raspbian

The first step in installing Plex on Raspberry Pi 4 is updating the underlying operating system. Why? An out of date operating system means that your Pi isn’t running with the latest firmware upgrades, kernel patches, and software fixes. Without patches, performance and stability are impacted. To update Raspbian, follow the step-by-step instructions below.

Step 1: Plug in an HDMI cord into a monitor to view the Raspbian text console on your Raspberry Pi 4. Be sure also to connect a keyboard so you can type commands.

Step 2: Connect an Ethernet cable to your Raspberry Pi 4, so it has internet access. A WiFi connection is not recommended for hosting Plex as they tend to be unreliable.

Step 3: Turn on the Raspberry Pi 4 and let it power up. When you get to the login screen, type in pi for user and raspberry for the password.

Step 4: Run the apt update command to refresh Raspbian’s software sources and to check for pending updates or software patches.

sudo apt update

Step 5: Run the apt upgrade command to install any pending software updates or patches. Keep in mind that as the Raspberry Pi 4 is much slower than a conventional laptop or desktop computer, this upgrade process may take a few minutes.

Step 6: Run the reboot command to restart your Raspberry Pi 4, as some updates may need the system to restart.

Step 7: Log back in with username pi and password raspberry and move on to the next section of the guide.

Set up the Plex repository

To access the Plex repository on Raspbian, “apt-transport-https” must be installed, as the Plex software repository runs in HTTPS mode, and the Raspbian package manager cannot handle HTTPS by default.

To install the “apt-transport-https” package, use the following terminal command.

sudo apt install apt-transport-https

After installing the “apt-transport-https” package, it is time to add the Plex repository’s encrypted key to the system. Using the wget command, download the key.

wget https://downloads.plex.tv/plex-keys/PlexSign.key

Add the key to the system with:

sudo apt-key add PlexSign.key

With the Plex key added, it’s time to add the Plex third-party software repository to  Raspbian. Using the echo command below, add the repo.

echo 'deb https://downloads.plex.tv/repo/deb public main' | sudo tee /etc/apt/sources.list.d/plexmediaserver.list

Now that the Plex software repository is set up on your Raspberry Pi 4 run the two commands below to install the server software.

sudo apt update
sudo apt install plexmediaserver

Setting up Plex

Now that the Plex app is installed on your Raspberry Pi, it is time to get everything set up. To start, go to a laptop or desktop computer and open up a browser window (this will also work on a smartphone or tablet). In the browser window, go to the following URL.

Please note that you will need to know the IP address of your Raspberry Pi 4. To find out this information, write ip addr show | grep 192.168 in the terminal console. Alternatively, check your router for the IP information.

raspberrypi-ip-address:32400/web/index.html#

After accessing the web UI, go back to the Raspberry Pi 4 and plug in an external USB hard drive (or flash drive) with media files on it into the USB 3.0 port. Then, run the lsblk command to show a printout of all attached storage devices.

In the lsblk output, your USB hard drive or flash drive will be /dev/sda, unless you have more than one USB device connected. If your device is not /dev/sda, please follow this guide for more information.

When you’ve figured out that the USB hard drive is /dev/sda, you’ll need to find out how many partitions are available for use. To find partitions, look under /dev/sda in the lsblk readout. On most USB hard drives and USB flash drives, there is one partition. On the Raspberry Pi, this partition should show up as /dev/sda1.

Note: for best results, ensure your USB hard drive or USB flash drive is formatted in the Ext4 file format.

Are you having issues locating partition information on your Raspberry Pi? Please follow this guide on the subject. It goes over how to read lsblk properly.

Once you’ve found the drive information, use the mkdir command to create a folder in /srv/. This folder will be where your media is mounted.

sudo mkdir -p /srv/usb-media/

Next, you must add the USB drive in the /srv/usb-media/ directory. Using the mount command, mount the drive.

sudo mount /dev/sda1 /srv/usb-media/

With the drive mounted to /srv/usb-media/, it is time to add your USB drive’s entry to /etc/fstab so that it is always available, even after a reboot. In the Raspberry Pi terminal console, write the following commands.

Note: in the command example below, we specify Ext4 as the file system. If your USB hard drive or USB flash drive uses a different file system, please run lsblk -f and find your file system type in the FSTYPE column by your device.

sudo -s echo ' ' >> /etc/fstab echo '# USB Media drive ' >> /etc/fstab
echo '/dev/sda1 /srv/dev-disk-by-label-Data ext4 defaults,nofail 0 2 ' >> /etc/fstab

Once your drive is set up on /etc/fstab, return to the web browser, and follow the step-by-step instructions below to add media to your library.

Step 1: Log into the Plex UI with your Plex account. You may also log in with other accounts, such as Google or Facebook.

Step 2: After logging in, you’ll be prompted to add media. Browse for the TV shows and Movies in /srv/usb-media/ and click “Next.”

Step 3: Once the “Next” button is clicked, Plex will slowly process and add media to your library. Sit back and be patient.

When Plex is done processing media, click “Play” to enjoy media from your Raspberry Pi 4!

About excitingtips

Check Also

4 ways to compress files in the terminal on Linux

Are you new to Linux? Want to learn how to compress files from the Linux …

Leave a Reply

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