Plex Media Server for OpenWrt

I think that these are due to the init script (during the initial install) trying to shut down a plex media server instance that doesnt exist and trying to read uci config items before /etc/config/plexmediaserver exists. If these configs are non-existant the script will generate them (hense why things still work even with these errors), but it doesnt do any checks to ensure the config exists before initially reading it.

When I have time I'll implement a check. there are also a few bashisms in the code I probably should fix as well.

Too bad. The main hurdle here is that Ive never used extroot before and only have a broad general idea of how it is setup. Its hard to write working code for a setup that you dont understand in detail and that you cant test...

1 Like

Hi, I have a Cudy WR3000 router that has no USB ports, can I configure plex via RCLONE using my onedrive space? Alternatively, my Cudy is connected to a LAN port of my internet provider's router (Vodafone station 6) which has 2 USB ports, is it possible to use the USB ports via cudy where will I install plex? Thank you

That is a better approach than onedrive via rclone (too much cpu overhead) but your Vodafone box must expose tla usb drive as a network share (samba)

1 Like

THANKS, so is it possible to do it both ways? I can use the router directly (if the CPU can do it) or use the Vodafone station, as a source via USB, which is already in SAMBA mode

Where can I find instructions for doing these things?

Option 1 (Map onedrive with RCLONE, and use plex, both on the Cudy WR3000 router, therefore without any USB port to use

Option 2 (Use the Vodafone router, where an HDD in SAMBA mode is connected, to use the cudy WR3000 router as a plex media server which catalogs the films on the disk connected to the Vodafone router.

A thousand thanks

It is probably possible in terms of "can plex media server do it" so long as you can mount it so that it shows up at some directory in your local filesystem.

My plexmediaserver init.d script just passes plex media server the directory to look for the ".plex media database" (via an environment variable). So, as long as you mount it so that at some directory on the local filesystem plex media server can find its database it shouldnt really matter if it is actually on network-attached storage or on a usb-attached drive.

That said, my openwrt init.d script may need to be tweaked so that it wont error out before launching plex (I didnt realy consider this use case when I wrote it...). When I get a free minute Ill modify the init.d script so that if the plex_drive_mnt uci variable is defined and exists on the local filesystem and the plex_drive_dev uci variable isnt defined and cant be determined (or is set to /dev/null) it wont complain about not being able to find the block device and error out. In this case itll skip all the built-in logic for auto-mounting the block device and set plex_drive_dev to /dev/null and just look under whatever folder you list in plex_drive_mnt for the .plex database.

Also, while this is (I think) technically doable, I really dont know how much performance will degrade doing it like this (with network-attached storage instead of direct usb attached storage)...it may work ok, it may be so laggy it is unusable...Im really not sure.

2 Likes

Thanks so much, I'll be happy to try when you release the change. Isn't it possible to find a solution to make everything work in the cloud? So both the files (the films) and the catalog that plex creates, all on onedrive, Google, etc?! Would be great!

I mean, as long as you can access it by going to a directory on your local filesystem then plex should (i think) be OK with it. i.e., anything like a mounted drive or a mounted samba share that you can access at some local path (e.g., /mnt/cloud/media) will work, but a http[s] / ftp / ssh address wont. You could even in theory do this with the squashfs image containing the binaries+llbraries that run plexmediaserver (instead of copying the squashfs to /tmp first and then mounting it), which would make plex use much less RAM.

The problem is that these things reduce the performance of plexmediaserver and tend to make video playback have more studdering, and "being able to run" doesnt mean much if the video plex is playing studders so much you dont even want to watch it. And I really dont know if performance will be good enough to be usable doing things this way. You never know until you try though.


To give some insight on why I set things up like I did:

I no longer use it, but previously I had a netgear R9000 with a fairly beefy quad core cortex-a15 CPU. The stock netgear firmware supported plexmediaserver (which is what inspired me to start this project to bring it to openwrt). Their implementation had the plex binaries/libraries on the hard drive with the plex database, and also allowed the hard drive with the media to be network-attached instead of usb-attached.

  • with media on a USB-attached harddrive: things worked, but performance was pretty awful. It was sort of watchable for SD content, but HD content was so studdery you really didnt want to watch it
  • with media on a network-attached drive: performance was so bad that plex would typically crash trying to just load the library. Actually playing something was almost impossible, and if the stars aligned just right and you managed to get something to actually play you spent 20x as much time waiting for it to buffer as you spent actually watching.

In comparison, with the method I currently use performance is roughly equivalent to running plexmediaserver on a x86_64 PC in every aspect except for video transcoding.

That said, the stock R9000 firmware was absolutely terrible and had bugs everywhere, so that may have been part of the problem. But not having the plex binaries/libraries on ram and not having the media on a local usb-attached drive both for sure made performance considerably worse.

1 Like

Thank you very much, it will be interesting to try once you have made the change, if it doesn't work well, I will use kodi, from Android TV, taking the Film catalogue, from onedrive via RCLONE which I will put on the Cudy WR3000. This way kodi can handle it like a local disk.

Ps. Excuse my terrible English :rofl: but I'm Italian, and I get help from Google translator :stuck_out_tongue_winking_eye:

What do you think of this router of mine https://www.cudy.com/products/wr3000-1-0 Bought a few days ago on offer for €29 on Amazon, the hardware seems really excellent for its cost, what do you think?? Its job should be,

  1. Rclone to see my onedrive spaces as if they were network disks

  2. surfshark VPN account

  3. plex server, without any coding, just pass the files, in case of bad results, I would use Kodi with library on onedrive via RCLONE The cudy WR3000 router.

in my opinion, could be adequate, since it will have to manage everything on a single user, never two together, and the hardware doesn't seem bad to me, it's also very recent.

1 Like

Ive uploaded a new version of the script to github. Place that file at /etc/init.d/plexmediaserver. Then at /etc/config/plexmediaserver put a file containing

config main
        option plex_drive_dev '/dev/null'
        option plex_browser_root '/path/to/plex/mountpoint'  #replace this with real path

And then run service plexmediaserver start and it should set up everything under the path you defined in plex_browser_root


The cudy wr3000 looks to be a pretty good router for the price. The biggest potential; issue is going to be RAM space. Between the squashfs with the plex binaries and the runtime memory usage, plex media server will use up ~128 mb of ram or so. The cudy wr-3000 has 256 mb. So, if you arent running anything else memory-hungry it might just work.

1 Like

Thank you very much, yes the router does not have to do anything in particular, the devices are almost all connected to the Vodafone station 6 router, so this cudy router only has to manage the streaming services (Netflix, Disney+, etc.) or plex for my contents, and manage vpn (surfshark) and my onedrive space, to be able to manage it like a local network disk. So the router has to do little and above all never everything together, and with just one device. So I believe that to manage ONEDRIVE with RCLONE and PLEX SERVER, it could go perfectly with my needs.

Hi, I currently also have a GL.iNet GL-MT300N-V2 micro router, which also has a usb port, in your opinion, could this handle RCLONE with its hardware? It has 128gb so absurdly it could also run plex server?! The router supports the latest version of Openwrt. It would be interesting to see if there is a way to use a USB memory that the router can use as RAM, exactly like the Android smartphone does, which uses internal memory to extend the RAM.

Nope, mt300nv2 is totally underpowered for this task.
You need either an x86 box (ideally latest or previous gen) or rpi5 or equivalent (rk3588 soc)

Keep in mind that I only need it to let Kodi read video files on OneDrive. In any case, the router supports the latest version of Openwrt, so in fact I can install everything I need, then it will all be seen in the presentations, but since on a technical level, it is possible to do it, I might as well try and see the results :sweat_smile:

@Daniele78 @maurer

To give an idea of cpu requirements: running on my dynalink dl-wrx36 (quad core a53 @ 2.2 GHz + 1 gb of ram), streaming (without transcoding) a 1080p movie (which it does reasonably well) uses up ~1/3 of the total available CPU power, split pretty evenly between the CPU cores. So if I have 8.8 ghz in combined CPU ticks between the 4 cores, ~3 ghz is being used up by plex. It also uses up ~128 MB of RAM.

  • Of the CPU usage, ~3/4 is from running plex and ~1/4 is from readinng data off of my usb-attached HDD.
  • Of the RAM usage, ~60% is from keeping the plex binaries + libraries in ram (on a squashfs), and ~40% is from runtime memory use.

So, a router with a 1.5 ghz dual core cortex-a53 and 128 mb RAM would basically use up 100% of its resources running plex. Being that routers that actually handle internet traffic requires some resources to do so, the realistic min specs are a bit above this (though if it is being run on a "dumb ap" then not so much above this), assuming the goal is "streaming (without transcoding) 1080p video fairly well.

Its also worth noting that only ARMv7/ARMv8 CPU's are supported. I dont think plex puts out a version for other architectures (not counting x86_64 of course).


I mean, this can for sure be done on openwrt, as it is a general linux feature to do this (it is called "swap" on linux). I dont know if the default openwrt kernel has this feature enabled or not, but if you compile your own firmware and tweak the kernel config it is for sure possible.

That said, you dont want to do this. Accessing data (particuarly with the type of access that things stored in RAM often require) is orders on magnitude slower from a HDD than from RAM. You're talking <1 MB/s for a HDD versus >10000 MB/s for RAM. When a system uses up itgs RAM and is forced to use disk space like RAM 95% of the time it immediately slows to a hault and goes into deadlock, requiring a reboot to recover. Even if you set up, say, cgroup protection to ensure this didnt happen and only plex stuff was on the disk, plex performance would be unusably bad.

1 Like

Yeah as @jkool702 correctly points out you can't install plex on platforms like mt300nv2 (mipsel architecture)

1 Like

Thanks, I don't understand one thing, that I can install the latest version of Openwrt, and that this can install plex, how can it not work? I'm not referring to the performance which can make it unusable, but the fact that the processor is not compatible, given that the openwrt operating system m (model GL.iNet GL-MT300N-V)anages the system!#

Plex is not distributed by openwrt but by a 3rd party plex inc. and openwrt does not come with plex preinstalled - you need to follow @jkool702 s tutorial to install it from this 3rd party and they don't package (compile) plex for your processor.

2 Likes

Thanks, at this point since we don't have to use the coding part, there's no point in doing all these steps, since it's better to use Kodi. Plex only works if there is a server, it makes sense to use it only when you need to encode files, otherwise it is practically a useless job.