Install Plex Media Server on Banana Pi with Bananian

banana-pi-plex-media-serverPlex Media Server, the beloved DLNA software for home media servers is finally on the Banana Pi without a chroot. There was a guide referenced which showed you how to install the Plex Media Server package from the Drobo NAS Server in a chroot jail on the Banana Pi. This was great except it caused various issues because of mapping folders between the host system and the jail. There were also problems with metadata not showing up.

I can confirm that metadata is indeed working now when using this guide and streams mp4, divx and xvid content locally just fine when you use a DLNA client like Plex Home Theater. Transcoding is another story and will require some testing for your media collection. I used the latest fresh Bananian image and also tested Igor's image with good results. Many thanks go to uglymagoo on the Plex forum for identifying the right PMS package to work with our Banana Pi. This package will also work on the Banana Pi Pro and CubieBoard Cubietruck series. I have supplied an image at the bottom of this post.

Update March 31, 2016 with Armbian Plex Image with transcoding enabled

You can now install Plex and have the port multiplier module working with my Banana Pi Media Server Image

Here is a quick rundown of the specs of the Banana Pi vs the Raspberry Pi models, see benchmarks as well, the SATA is really a great addition to your low powered home media server.

Pi Unit
Processor
RAM
RAM Bus
Network
WiFi
USB
SATA
Cost
Raspberry Pi 3
1.2 GHz ARMv8
Quad Core
1 GB DDR2
450 MHz
100 Mbit
Yes
4
No
$35
Raspberry Pi 2
900 MHz ARMv7
Quad Core
1 GB DDR2
450 MHz
100 Mbit
No
4
No
$35.00
Raspberry Pi
700 MHz ARMv6
Single Core
512 MB SDRAM
400 MHz
100 Mbit
No
4
No
$25
Banana Pi
1 GHz ARMv7
Dual Core
1 GB DDR3
432 MHz
Gigabit
No
2
Yes
$36.99
Banana Pi Pro
1 GHz ARMv7
Dual Core
1 GB DDR3
432 MHz
Gigabit
Yes
2
Yes
$45.00

Install Plex Media Server on Banana Pi

banana pi plex media server

Make sure you have the en_US locale installed

This command lists current locales

locale -a

My output looks like this

C
C.UTF-8
en_US.utf8
POSIX

If you don't have en_US.utf8 you can generate it

To generate the locale edit the locale generator configuration file first to enable the locale

sudo nano /etc/locale.gen

Uncomment this line by deleting the #

# en_US.UTF-8 UTF-8

Ctrl+X, Y and Enter to save

Now generate the locales

sudo locale-gen

Install Plex Media Server on Banana Pi using Repository

Install libexpat1 for playing subtitles on Android devices

sudo apt-get install libexpat1 -y

Enable https transport or you will get this error: E: The method driver /usr/lib/apt/methods/https could not be found.

sudo apt-get update && sudo apt-get install apt-transport-https -y --force-yes

Grab uglymaoo's gpg key for his repository

wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -

Check which version of the glibc you have by typing this command

ldd --version

If the output says 2.13 use wheezy, if it says 2.19 use jessie instead of wheezy below for uglymagoo's repo.

Add uglymagoo's Plex repository

echo "deb https://dev2day.de/pms/ wheezy main" | sudo tee /etc/apt/sources.list.d/pms.list

Update your package lists

sudo apt-get update

Install Plex Media Server

sudo apt-get install plexmediaserver-installer -y

When you know there is a new version of Plex Media Server you can upgrade with this command now

sudo apt-get update && sudo apt-get upgrade -y

Access Plex on your Banana Pi at this URL, replace ip.address with your actual IP http://ip.address:32400/web

If Plex says it has started but you cannot reach the web interface you can narrow down the issue by starting Plex manually like this

sudo bash /usr/lib/plexmediaserver/start.sh &

There is a guide to install the Plex UnSupported AppStore and fixing video transcoding if it's not working in the Plex Web Client.

Please use free Dynamic DNS to access Plex remotely.

Alternative Method 1 – Easy Install Method

In this method you grab the latest precompiled Plex package from uglymagoo and install it, it is super fast and easy.

Enter your temp folder, this will ensure the package is emptied after you reboot

cd /tmp

Remove previous Plex packages in case you are just upgrading

rm plexmediaserver*.deb

Download the latest Plex Media Server Package

wget --trust-server-names http://dev2day.de/plex-latest

Install the latest Plex Media Server Package

sudo dpkg -i plex*

You will see the Plex server has started and can now access it at http://ip.address:32400/web

Plex will autostart on boot and you can now configure Plex.

Alternative Method 2 – Build the Plex Package

With this method you are going to grab the latest Plex ARMv7 Synology package and turn into a deb package you can install on your Banana Pi or Banana Pi Pro. This method will upgrade previous installations used for installation methods 1 and 2 in this post.

Enter your home directory

cd ~

Grab the latest Plex skeleton package

wget http://dev2day.de/skeleton.tgz

Unpack the Plex skeleton

tar -xzf skeleton.tgz

Grab the latest Plex Media Server package link for ARMv7 which can be found at https://plex.tv/downloads click NAS.
plex media server arm7 choose nas

Click the Synology tab and right click on the ARMV7 button and copy the link to the clipboard.

plex media server arm7 choose synology

Back in SSH type wget and paste the link you have copied to the clipboard, trim the s from https as well if you have issues

wget http://downloads.plex.tv/plex-media-server/0.9.11.16.958-80f1748/PlexMediaServer-0.9.11.16.958-80f1748-arm7.spk

Rename the Synology Plex package, replace the filename here with the filename of the newest package you just downloaded.

mv PlexMediaServer-0.9.11.16.958-80f1748-arm7.spk PlexMediaServer-0.9.11.16.958-80f1748-arm7.tgz

Unpack the Plex package, again replace the package name

tar -xvf PlexMediaServer-0.9.11.16.958-80f1748-arm7.tgz

Unpack the package to the skeleton directory

tar -xvf package.tgz -C skeleton/usr/lib/plexmediaserver

Delete unnecessary stuff

rm -r skeleton/usr/lib/plexmediaserver/dsm_config

Enter the plexmediaserver folder

cd skeleton/usr/lib/plexmediaserver

Create some symbolic links

find . -iname "*.so" -exec chmod 644 {} \;
find . -iname "*.so.*" -exec chmod 644 {} \;

Go back to the home directory

cd ~

This is optional, you can edit the package details

nano skeleton/DEBIAN/control

Change Maintainer if you want and adjust the version

Package: plexmediaserver
Version: 0.9.11.7.803-87d0708-3
Architecture: armhf
Maintainer: Jan Friedrich (uglymagoo) <jft@dev2day.de>
Section: video
Priority: extra
Homepage: http://www.plexapp.com
Description: Plex Media Server for Linux
  Stream media everywhere(tm)

Install fakeroot

sudo apt-get install fakeroot -y

Build the deb package for installation

fakeroot dpkg-deb --build skeleton ./

You can now install the plexmediaserver package you just created

sudo dpkg -i plexmediaserver*

If all went well you can remove the files and folders you used to build the package

rm skeleton.tgz
rm -R ~/skeleton
rm plex*.deb

Install the transcoding tools at the bottom of this post if you plan to transcode.

Access your Banana Pi Plex Media Server at http://ip.address:32400/web

Alternative Method 3 – Manual Install of Plex Media Server

The following section is only necessary if the above methods does not work.
Run all of this as root in an SSH session, if you are logged in as a sudo user execute this command to gain super user rights for the session

sudo su

Enter your home directory

cd ~

Create a plex directory to work with

mkdir plex

Enter the plex working directory

cd plex

Grab the Synology arm7 package

wget https://downloads.plex.tv/plex-media-server/0.9.11.7.803-87d0708/PlexMediaServer-0.9.11.7.803-87d0708-arm7.spk

Rename the Synology arm7 package to tar so it can be unpacked and used on the Banana Pi

mv PlexMediaServer-0.9.11.7.803-87d0708-arm7.spk PlexMediaServer-0.9.11.7.803-87d0708-arm7.tar

Unpack the Plex Media Server tar package

tar -xvf PlexMediaServer-0.9.11.7.803-87d0708-arm7.tar

Create a directory for plex

mkdir -p /opt/plex/Application

Unpack the Plex package to the plex folder you just created

tar -xvf package.tgz -C /opt/plex/Application

Create a symlink for this file

ln -s /lib/arm-linux-gnueabihf/ld-linux.so.3 /lib/ld-linux.so.3

Make sure you have the en_US.utf locale or you will get this error
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid

This command lists current locales and fixes the locale error above

locale -a

My output looks like this

C
C.UTF-8
en_US.utf8
POSIX

If you don't have en_US.utf8 you can generate it or modify the plexmediaserver file further below to use your locale

To generate the locale edit the locale generator configuration file first to enable the locale

nano /etc/locale.gen

Uncomment this line by deleting the #

# en_US.UTF-8 UTF-8

Ctrl+X, Y and Enter to save

Now generate the locales

locale-gen

Now run Plex for the first time!

Enter your plex directory

cd /opt/plex/Application

Start Plex Media Server to see if it's working

bash start.sh &

Browse to http://ip.address:32400/web and Plex should pop up!

Configure Plex Media Server to Autostart on Boot

To get Plex to start on boot, create this file

nano /usr/local/bin/plexmediaserver

Paste this inside

#!/bin/sh
SCRIPTPATH=/opt/plex/Application
export LD_LIBRARY_PATH="${SCRIPTPATH}"
export PLEX_MEDIA_SERVER_HOME="${SCRIPTPATH}"
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/opt/plex/Application/Library/Application Support"
ulimit -s 3000
/opt/plex/Application/Plex\ Media\ Server

Ctrl+X, Y and Enter to save

Make the plexmediaserver file executable

chmod +x /usr/local/bin/plexmediaserver

Create the init.d script to start and stop plexmediaserver on the Banana Pi

nano /etc/init.d/plexmediaserver

Paste this slightly modified PMS script

#!/bin/sh
### BEGIN INIT INFO
# Provides:          plexmediaserver
# Required-Start:    $remote_fs $syslog $networking
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Plex Media Server
# Description:       Plex Media Server for Linux,
#                    More information at http://www.plexapp.com
#                    Many thanks to the great PlexApp team for their wonderfull job !
# Author:            Cedric Quillevere / origin@killy.net
# Rewamped           Christian Svedin / christian.svedin@gmail.com
# Adapted (cubox-i)  Francis Belnger / francis.belanger@gmail.com
# Version:           1.2
### END INIT INFO

# Read configuration variable file if it is present
[ -r /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver

test -f "/usr/local/bin/plexmediaserver" || exit 0

plex_running=`ps ax | grep "/opt/plex/Application/Plex Media Server" | awk '{ print $1 }' | wc -l`


case "$1" in
    start)
        if [ "$plex_running" -gt 1 ]; then
                echo "Plex already running..."
                exit 0
        fi
        echo -n "Starting Plex Media Server: "
        su -l $PLEX_MEDIA_SERVER_USER -c "/usr/local/bin/plexmediaserver &" >/dev/null 2>&1
        sleep 1
        echo "done"
        ;;
    stop)
        if [ "$plex_running" -eq 1 ]; then
                echo "Plex Media Server is not running (no process found)..."
                exit 0
        fi
        echo -n "Killing Plex Media Server: "
        # Trying to kill the Plex Media Server itself but also the Plug-ins
        ps ax | grep "Plex Media Server" | awk '{ print $1 }' | xargs kill -9 >/dev/null 2>&1
        ps ax | grep "Plex DLNA Server" | awk '{ print $1 }' | xargs kill -9 >/dev/null 2>&1
        sleep 1
        echo "done"
        ;;
    restart)
        sh $0 stop
        sh $0 start
        ;;
    status)
        if [ "$plex_running" -gt 1 ]; then
                echo "Plex Media Server process running."
        else
                echo "It seems that Plex Media Server isn't running (no process found)."
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
        ;;
esac

exit 0

Ctrl+X, Y and Enter to save the Plex Media Server script

Make it executable

chmod +x /etc/init.d/plexmediaserver

Update rc to enable your new Plex Media Server script

update-rc.d plexmediaserver defaults

Reboot and you are all ready to start adding media to Plex and stream it around your home!

reboot

Transcoding Tools

Plex Media Server requires a new libc6 module that you can pull from the jessie repo (thanks again to uglymagoo).
It will enable XviD, DivX and MKV playback in the Plex web interface and in the Plex app.

Install libexpat1 for help playing in the Android app

sudo apt-get install libexpat1 -y

Stop your Plex server first

sudo service plexmediaserver stop

Now grab the package, extract the libc6 file and place it in the PMS folder.

If you used method 1 or 2 the path is /usr/lib/plexmediaserver and not /opt/plex/Application

cd /tmp/
mkdir libc6
cd libc6
wget http://ftp.us.debian.org/debian/pool/main/g/glibc/libc-bin_2.19-18+deb8u2_armhf.deb
dpkg-deb -x libc6_2.19-18_armhf.deb ./
cp -a lib/arm-linux-gnueabihf/libm-2.19.so /opt/plex/Application
cd /opt/plex/Application
chmod ugo+x libm-2.19.so
unlink libm.so.6
ln -s libm-2.19.so libm.so.6

Restart your server

sudo service plexmediaserver start

You should set Plex to use your external hard drive for temporary transcoding data after you have mounted your drives properly.

Click the settings icon in the top right, Click Server and then Transcoder in the left pane.

Make sure SHOW ADVANCED is enabled underneath Server.

Scroll down to Transcoder temporary directory and set your USB external drive's mount path (e.g. /mnt/usbstorage not /dev/sda1)

Scroll down further and hit Save Changes

raspberry pi 2 change transcoder path

Fix Plex Permission Issues on Banana Pi

If Plex isn't reading your drives you can do one of two things, change the permissions of your external storage (less secure) or change the user Plex is running as (which could mean you need to rescan for metadata).

Add the plex user to your pi group

sudo usermod -aG pi plex

Then change the permissions where /mnt/usbstorage is your mount path for your hard drive so your regular group has execute permissions (second 7) which will include the Plex user.

sudo chmod -R 775 /mnt/usbstorage

To change which user Plex runs as, open this file

sudo nano /etc/default/plexmediaserver

Change this line, replace plex with your username you use to log on or the owner of the mounted drive

PLEX_MEDIA_SERVER_USER=plex

Ctrl+X, Y and Enter to save

Then restart your Plex server

sudo service plexmediaserver restart

I may create a Banana Pi cluster to see if it is a viable solution for heavy transcoding outside your home network.

Now that you have completed the Install Plex Media Server on the Banana Pi guide you can configure Plex Media Server

Here is the Banana Pi Media Server Image, share to reveal the link, it includes the Media Server Installer as well.