My Guide to using a RAM Drive for the Plex Log Directory

  • I found that Plex processes were accessing my drive every 30 minutes just to update the main log saying it was running but doing nothing. I decided to try to copy the method used by the Flash Memory Plugin which uses folder2ram. I initially tried adding the Plex log directory to its config file and then executing a folder2ram -generate.


    It did generate the file, however, Plex has an extremely long path and it also contains a lot of spaces in the path which caused folder2ram to not execute correctly. I ended up having to manually remove the mutant named files that were mangled because of the spaces. This was just as well because adding it to folder2ram's config file would have lasted only until the next time the plug-in was updated. At that time any changes I had made would have been blown away by the update.


    Besides the spaces in the path, the only other gotcha to doing this is the size of the log directory. Plex seems fairly bad at keeping the size of its log files reasonable. In 3 to 4 days I had been using Plex it had managed to generate 24 MB worth of logs. The DNLA log in particular seems to be able to grow without constraint. My earlier attempts failed because the initial 16 MB size of the tmpfs drive wasn't large enough. Eventually I increased the size to 128 MB and I added in a log cleanup routine to delete the older logs (ie "*.log.[3-9]"). Additionally I added a daily cron job to sync the data back to the disk.


    Overview of what you need to do to implement:

    Code
    Place file: /etc/init.d/plex_omv_tmpfs
    chmod a+x /etc/init.d/plex_omv_tmpfs
    insserv plex_omv_tmpfs
    Place file: /etc/cron.daily/plex_omv_tmpfs_sync
    chmod a+x /etc/cron.daily/plex_omv_tmpfs_sync


    plex_omv_tmpfs


    plex_omv_tmpfs_sync


    Acknowledge/Sources:
    - folder2ram (Good implementation on OMV)
    - https://www.debian-administrat…/661/A_transient_/var/log (I learned a lot from this explanation)

  • If you look at the details of what I'm doing, I actually followed folder2ram's implementation fairly in the closely in the items above.


    The reason I couldn't just use it directly was because of the directory name mangling that happens because of Plex's long path name and because they could at any time change their plugin and then my personal changes would be overwritten by their changes.


    I'm just about done writing a more evolved folder2ram alternative which adds on the following capabilities:


    - Allows you to specify services to shutdown before mounting the ram drive. These services are then restarted afterwords. (I created this because of the nightmare dealing with postfix in the current implementation. Their current implementation has hosed postfix half a dozen times necessitating removing the directory entirely and reinstalling postfix each time.)
    - Allows you to specify the size of the ram drive and checks the actual size to ensure you don't create a drive too small. (I ran into a problem with Plex because it was over a 100 MB and didn't fit in the default size.)
    - Removes old logs before syncing back to disk. Allows the amount of trimming to be controlled in the config file for each directory. (Also because of Plex, I needed to make sure I could reign in unruly programs' logs.)
    - Automatically generates and places a cron.daily script to synchronize the directories daily.
    - Checking to make sure the services specified exist, checking to ensure the directory specified exists, etc.

    • Offizieller Beitrag

    @ryecoaaron - maybe a good addition for folder2ram?


    @bobafetthotmail would be able to answer that better.

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

    • Offizieller Beitrag

    I was planning on sending babafetthotmail a message once I had it finished. I need some feedback on the features and perhaps some practical testing.


    You could also submit issues and/or pull requests on his github.

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

  • It's finished enough to start testing. I created a pull request on folder2ram. However, I used Perl to write it, it was just too complex to consider accomplishing all the desired todo items using shell script like folder2ram uses. So I'm not sure if it needs to go under its own area because it is so different.


    I'll discuss it with babafetthotmail and see what he thinks is the best course.


    Example Config file (added ramfs as well as tmpfs as options, along with log pruning and drive size limits):


    Nicely formatted summary of used space vs. size limit and bind mounts with directory location:

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!