Openmediavault + Plex Media Server as Home Media Server

Server Introduction

OpenMediaVault (OMV)

OpenMediaVault (OMV) is a Debian based headless Operating System (OS). I have been using this for a while now. More I use this OS more I fall in love with. Reason for this is mainly because of its beautiful web based management system, plugin system (DLNA,CUPS, Tranmission) and  its based OS.

OpenmediavaultImage 1.1 – OpenMediaVault (OVM) Web Interface

Openmediavault is very lite weight operating system (download here).  It has straight forward installation method. I think the only problem with installation is that it takes whole hard drive (HD) for OS installation which mean you cannot use that HD for file storage purpose. Similarly, you cannot customise the space that you would like to give to OS unlike other operating system.( So Be Carefully before you install this OS make a backup!)

There is work around for this problem either you can (1) install OS in fast pendrive or (2) you can shrink you partition after you install the OS. I prefer second option and its much safer than pendrive as anyone can unplug pendrive and whole system will stop working. I am not going to explain how to install the OS in detail.

1. For installing OS in pendrive, insert your pendrive then run the installation. It will give you option later on to install in it.

2. For installing OS in hardrive  - follow in screen setup and install everything then you need a live OS to shrink partition. I prefer Partedmagic (download). Just boot in to live OS and use Partition Editor (its a Gparted application) to shrink to the size partition to size that you want to give to os (I would prefer 20GB so that you can play around with os later). (maybe I will explain this in detail near future?)

After installation of OS you will get a ip for you server (it will show your ip on your monitor). Just go to other computer at home and type that ip in your chosen browser (I prefer chrome but its up to you). It will now show you the login box. For the first time your login detail will be

User Name: admin
Password: openmediavault

To change the password, after you login you can do this

System -> General Settings ->Web Administrator password

Next thing we need to do is to enable ssh service. We need this to run different terminal command in server. Not everything can be done from web management system.

Go to Services -> SSH -> Enable (tick) ->OK

Again you need to download SSH client, if you are using Linux or Mac OS its build in system but for Windows system you need to download SSH client. My favorite SSH client for windows is putty (download). Putty is very user friend application. One does not need to spend more than 10 min to connect to SSH server.

puttyImage 1.2 – Putty

We will be using SSH to run different command remotely in server.

End of Server Pre-Setup
Plex Media Server Introduction

Plex Media Server (PMS)

After this, we will install Plex Media Server (PMS) in server. Plex Media Server (PMS) is a server application which auto manage the media content and serves it to different platform. You can find its client apps in Windows & Mac OS as well as in mobile platform (iOS, Android) plus it can also be install in Apple TV, its build in Google TV, LG Connected Devices, Roku.

myplexImage 2.1 – Plex Media Server (PMS) Web Manager

Installing PMS in OpenMediaVault (OMV)

1. First thing we should know is that OMV is not ground up build system. It is based on Debian System. So anything that runs in debian will run in OMV. Plex Media Server (PMS) does run in debian system but not in direct way. PMS has .deb installation file which are base on Ubuntu OS (which like OMV is base on debian too). Lets start the installation, first you need to add repo (its a web link where file are kept) in source.list file in OMV.

Connect to SSH and run following command in order.

apt-get install aptitude
aptitude update
aptitude install curl

Add this line deb http://shell.ninthgate.se/packages/debian squeeze main in /etc/apt/source.list.d/plexmediaserver.list

nano /etc/apt/sources.list.d/plexmediaserver.list
aptitude update
aptitude install plexmediaserver

These command will add repo “deb http://shell.ninthgate.se/packages/debian squeeze main” to /etc/apt/source.list and keys to login to web. If everything went well without the error then plexmediaserver should be install.

Now check if plexmediaserver is running or not

/etc/init.d/plexmediaserver status

if it says “Plex Media Server process running” then PMS is running. If it gave error like file not found or “Plex Media Server process not running” then it might be due to two possible reason. Either the installation didn’t add user plex or there is no file called plexmediaserver in /etc/init.d/

Either way the solution I found will work. We need to run PMS as root user. Follow the steps below

export LD_LIBRARY_PATH=/usr/lib/plexmediaserver

Now we need to check if there is plexmediaserver file in /etc/init.d/ or not

nano /etc/init.d/plexmediaserver

If this gives you empty editor then copy following code.

### BEGIN INIT INFO
# Provides: plexmediaserver
# Required-Start: $remote_fs $syslog $all
# 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 his wonderfull job !
# Author: Cedric Quillevere / origin@killy.net
# Version: 1.0
### END INIT INFO

#test -f “/usr/lib/plexmediaserver/Plex Media Server” || exit 0
test -f “/usr/lib/plexmediaserver/start.sh” || exit 0

export PMS_RUN_USER=”root

plex_running=`ps ax | grep “\./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 $PMS_RUN_USER -c “/usr/sbin/start_pms &” >/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

Otherwise if it looks like this, just change plex to root at line 17.

Now, we need to change plex to root in /etc/default/plexmediaserver files

nano /etc/default/plexmediaserver

At line 19 change plex to root again.

Now run

chmod 777 /etc/init.d/plexmediaserver
/etc/init.d/plexmediaserver restart

Check if plex is running or not

/etc/init.d/plexmediaserver status

If it says “Plex Media Server process running.”

Now goto your client computer (i.e laptop / tab) and goto browser and type

[your server ip]:32400/web

It will show you the Plex’s web management system where you can add/remove contain.

NoticeNote: Using root user to run any application is not recommended, specially if you are concern about security. And If you use root to run PMS, every time you update PMS you need to go back to /etc/init.d/plexmediaserver, delete it and rename plexmediaserve.dpkg to plexmediaserver and restart demon.
End of Plex Media Server Installation
Optional for OMV- Moving PMS Library

If you are like me who have small partition for you OS then you might need to think of moving Plex Media Server Application Library to different partition.

The easiest solution that I found is to make symbolic link of your Library folder.

First copy all the files from your library to other partition. (I am running PMS as root if you are using any other user then you need to change root to that user name)

cp -avr /root/Library /media/[partition name]/Library

Just in Case make a backup

mv /root/Library  /root/Library.bak

Now Symbolic link your Library folder

ln -s /media/[partition name]/Library /root/Library
End of Optional for OMV- Moving PMS Library
About these ads

31 thoughts on “Openmediavault + Plex Media Server as Home Media Server

  1. Pingback: Plex Media Server Management | Linux+

  2. I like what you guys are up also. Such intelligent work and reporting! Carry on the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my website :)

  3. Pingback: Openmediavault + Remote Access | Linux+

  4. I visited a lot of website but I think this one has got something special in it. “Let your life lightly dance on the edges of Time like dew on the tip of a leaf.” by Rabindranath Tagore.

  5. Pingback: Openmediavault + Deluge 1.3.6 | Linux+

  6. Hi FACTRO.

    I simply cannot get this to work. I get this message when running the apt-get update command:

    root@NAS:~# apt-get update
    E: Type ‘“deb’ is not known on line 1 in source list /etc/apt/sources.list.d/plexmediaserver.list
    E: The list of sources could not be read.

    I need your help

    Regards,
    Daniel

  7. Oh my god it worked! After so many headaches and tries! Thanks a bunch! One more question for you. If i reboot/shutdown my OMV machine – will the plex media server automatically start when my OMV machine boots back up again or will I have to manually start it up each time?

    Regards,
    Daniel

  8. yes it will.. the only problem you will have later is…when you update plex, script for plex in /etc/init.d/ folder will not work..
    .
    work around for this : when plex updates it will backup /etc/init.d/plexmediaserver ->/etc/init.d/plexmediaserver.dpkg and creates a new plexmediaserver file in there..which won’t work (its for ubuntu not for debian), what you need to do is delete the new plexmediaserver file and rename plexmediaserver.dpkg > plexmediaserver …
    and /etc/init.d/plexmediaserver start
    unfortunately , you have to do this every time it update…:(

    • Okay thanks for the info. Is there any way of disabling update. That way I can update manually when I’m ready to mess with the scripts again

      Regards,
      Daniel

      • I don’t think OMV updates automatically!.. what you need to do is, use omv web interface to update.. you can deselect plex when you update..

  9. Greetings,
    Awesome tutorial but I’m having an issue. when I try to execute /etc/init.d/plexmediaserver restart
    I get bash: /etc/init.d/plexmediaserver: Permission denied
    I’m running as root. Any clue why this would happen?

      • I was able to run your code but the restart did nothing. Then, I ended up copying your code your provided in your tutorial to the /etc/default/plexmediaserver. Where could I get the original code? Or should I just reinstall PMS?

  10. after you copy that code, save it and chmod 777 /etc/init.d/plexmediaserver
    /etc/init.d/plexmediaserver restart. If it didn’t work please check my reference.. :)

    Link to my plexmediaserver file..
    http://db.tt/bbsves7b

    after download change plexmediaserver.txt to plexmediaserver

  11. and can you check this /etc/init.d/plexmediaserver status after you restart, if its says its still not running download my plex files and replace it with yours and restart. It should work!..

    • I thought that code only went into the /etc/init.d/plexmediaserver? I seem to remember something different in the /etc/default/plexmediaserver file?

  12. yes code only goes to /etc/init.d/plexmediaserver file.. that should have root as user in it..

    I think its best you delete the old plexmediaserver file in /etc/init.d.. and download / upload the files I have in dropbox and change the permission and start. This should work.

    PS. while uploading plexmediaserver file dont forget to remove txt extension.

    • Just to clarify, you only had one file in your dropbox. As you suggested, I deleted my plexmediaserver file in /etc/init.d. I removed the .txt extension, moved the file, ran the chmod and I’m closer but still coming up short:
      root@Ultra:~# chmod 777 /etc/init.d/plexmediaserver
      root@Ultra:~# /etc/init.d/plexmediaserver restart
      Plex Media Server is not running (no process found)…
      Starting Plex Media Server: done
      root@Ultra:~# /etc/init.d/plexmediaserver status
      It seems that Plex Media Server isn’t running (no process found).

  13. Yes its just one files, have you run this command
    export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
    as root?
    and try restarting the plexmediaserver again.

    PS. which os are you trying to running this in? OMV, Debian, Ubuntu..

    • I have. I followed those steps when I saw the message. the /etc/default/plexmediaserver still contains the same code as the /etc/init.d/plexmediaserver. I could have sworn this was different from the /etc/default/plexmediaserver file.

  14. /etc/default should be different..

    it should be like this

    ==copy from below===

    # default script for Plex Media Server

    # the number of plugins that can run at the same time
    PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6

    # ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
    PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000

    # where the mediaserver should store the transcodes
    PLEX_MEDIA_SERVER_TMPDIR= /media/to/you/temp folder/

    # uncomment to set it to something else
    # PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=”${HOME}/Library/Application\ Support”

    # the user that PMS should run as, defaults to ‘plex’
    # note that if you change this you might need to move
    # the Application Support directory to not lose your
    # media library
    PLEX_MEDIA_SERVER_USER=root

    ==Don’t copy from here====

    PLEX_MEDIA_SERVER_TMPDIR, you should change this to any local folder you want to use as tmp folder..

    • And now I’m in business! Thanks mate! I just saw the link you provided in PlexApp’s forums. Sorry to hijack your post but hopefully it’ll help others like me

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s