Best mount settings for streaming ( Plex )

@jpat0000 care sharing how to install node-drive-fuse

I haven’t been able to make it work lately keep getting errors and it used to work fine

Hold me over till we can cache in rclone

google will show you files during ban but will error if you try and play

@MartinBowling

You’ll have to share what errors you’re getting. A couple problematic bugs with node-gdrive-fuse:

mod time is invalid for files, leads to Plex database corruption/dashboard breaking.

Writing the mount results in the same file appearing many times in the mount, doesn't play well with applications like Sonarr

No cache data cleanup of any kind...

https://github.com/thejinx0r/node-gdrive-fuse/pull/79/commits/3d755b9bfb704de4c5aebb97703a8d5ad964fa4b

Simply make the changes to the two files manually to fix the mod time problem.

For writing I use unionfs-fuse. This is a little tricky actually, because even though you can specify the local disk as the read/write priority, it won’t write to the local disk unless the folder it’s writing to exists already, or the less prioritized mount doesn’t have write enabled. I use automatic download handling software like Sonarr and I want it to be able to delete upgraded copies of my media.

Make local folder for temporary write:

/home/user/tmpwrite

Clone node-gdrive-folder structure:

cp -R --attributes-only /home/user/nodegdrivemount/MYMEDIA/Shows /home/user/tmpwrite/MYMEDIA/

cd /home/user/tmpwrite/MYMEDIA/Shows
find . -type f -size -1M -exec rm {} +
(Do this every once in a while)

Merge em together:

unionfs-fuse -o cow,allow_other /home/user/tmpwrite=RW:/home/user/nodegdrivemount=RW /home/user/unionfsmount

Move your temporarily written files to Google Drive at your leisure:

rclone --no-check-certificate --no-traverse --drive-chunk-size=64M --transfers=6 move /home/user/tmpwrite google:MYMEDIA/Shows --exclude .@**

Finally, the cache problem. I recommend setting the cacheLocation to /dev/shm/nodegdrivecache (your RAM).

Create bash script: cleanup.sh
find /dev/shm/gdrivecache/download -maxdepth 1 -mmin +1 -exec rm -f {} \;

Create a screen to run the script:

screen -S cleanup

Execute every 60 seconds:

watch -n 60 bash cleanup.sh

Adding new stuff to Google Drive is fine with node-gdrive-fuse but moving files around will result in you needing to rebuild the database, simply delete it from /dev/shm (or wherever) and start your mount again if needed.

1 Like

@jpat0000 thanks for the tips! I should have been more specific.

I was getting harmony errors when running it so I
Hadn’t even gotten to my plex setup.

I’ll work through it and use some of your tips
Try some different Node versions

@Ajki Been using your mount script for a few days now, have you noticed it sometimes takes things ages to start playing? But after they start it’s all good?

@toomuchio define ages ?

All i can tell you is that connection to amazon is a bit spastic in general.

For example every now and then I run tree -D -s -h trough all my library, the server in both cases had 0 people streaming and Plex Library was not updating eg same CPU usage.

14.12.2016/17:51
3304 directories, 28933 files 32TB
tree -D -s -h completed in 317 seconds

15.12.2016/14:09
3304 directories, 29000 files 32TB
tree -D -s -h completed in 552 seconds

As you can see the difference is massive hence you cant really claim hmm something is wrong with rclone version and/or mount parameter before you do some proper test just to see how amazon drive is behaving.

At home I was running tons of copy file tests to measure the speed and its spastic as well … not 10% difference but 200% difference within one hour. Sometimes I could copy file within 2 minutes and 20 minutes later it would take 5 minutes while nothing was changed.

Yes it works on all remotes.

I’ve seen it take up to 30 seconds to start playing something but then it’s fine. I think it’s just crappy ACD performance. Otherwise these mount settings have been great for me.

This is my mount script if anybody was wondering @Ajki have you made any further changes? This seems to be working really well.

killall rclone
fusermount -uz …
rclone mount --allow-other --read-only --max-read-ahead=2G --acd-templink-threshold=0 --dir-cache-time=60m --checkers=32 --timeout=30s --contimeout=15s --retries=3 --low-level-retries=1 --stats=0 --quiet acdge:/ … &

killall unionfs-fuse
fusermount -uz …
unionfs-fuse -o allow_other,cow,max_readahead=2000000000 …=RW:…=RO …

The issue with slow starts is due to rclone and not ACD.

I’ll post my setup tomorrow that uses rclone crypt and acd_cli together to make start ups happen in about 3-4 seconds.

Why killall ? this will kill current upload progress as well.
@Stokkes so far the only slow start i noticed is from Plex not rclone eg when I run some movie that is 24GB or more it may take up to 8 to 10 seconds to start if I run the same movie with media play directly a home it will take 3 seconds.

I make sure I never run my mount script while copying, the unmount doesn’t always kill the rclone processes in the background

@Ajki

That is really odd. When I was on Hetzner or even now on SYS, mounting the encrypted drive and pointing Plex to it would cause start times to be 10+ seconds, almost always higher. I’m always using the latest betas too.

What my new setup does is mount the ACD drive using acd_cli and then use rclone to mount the encrypted folder for my media on the local ACD path. This way rclone isn’t talking to ACD directly, acd_cli does and it has been significantly faster, even on a mobile connection its 4-5 seconds to start a video when on LTE.

I have no idea why this is but I can easily recreate it by just remounting directly with rclone and modifying my UnionFS mount options.

I’m definitely up for ideas as adding acd_cli does add an extra layer where things could go wrong.

@toomuchio
Never had problem with unmount, did you ever check with findmnt how many times you mouted as i saw people with multiple rclone mounts-

What you could do is put in script to keep unmounting while mount exist
(not tested but should work )

while [   mountpoint -q -- "/storage/acd" ]; do
             fusermount -uz /storage/acd
done 

@Stokkes Maybe there is difference in performance crypto vs encfs ( iam using the latter )

My mounts:

Whatever video I start is between 3 to 5 seconds and those 24GB between 5 and 10.
The only way to get it between 10 to 15 seconds is if I do burn in subtitles and video is 24GB but thats not rclone but transcoder that needs some time

@Ajki I’m using your mount setting and everything is working great but how do you update your plex library? On a timer?

@chris243
In my rclone-cron.sh I run
tree --prune -i -h -D /storage/media-local/ > /home/plex/rcloneque.log
rclone move …
pmslibupdate.sh

The pmslib file checks
if grep -q “series” /home/plex/rcloneque.log; then
curl “http://xxxx:32400/library/sections/2/refresh?force=0&X-Plex-Token=xxxx
fi

Basically scripts just update the library i uploaded in.

Interesting… I would love to take a look of all the different scripts you made and canabilize them for my own setup =)… Any chance you can upload them somewhere? That would be awesome.

Also - are you still using the net settings you posted somewhere in the beginning of this thread?

Another option, which has the potential to allow you a fine-tuned approach, is to use the Plex Media Scanner command directly.

#!/bin/sh
su - plex -c /bin/sh << eof
        export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
        find "$2" -type f -mmin -$((60*24)) -print0 | xargs -0 dirname -z | sort -uz | xargs -0 -I {} /usr/lib/plexmediaserver/Plex\ Media\ Scanner -r -p -s -c $1 -d "{}" --no-thumbs 2>&1
eof

Save this as a bash script and then feed it two arguments when called, the place to look for new files and the library number to look in. This, in theory, would have the effect of scanning only the folders you tell it to instead of rescanning the entire library. In practice, there is one oddity that Plex has not addressed and that is it also tries to match unmatched files from the specified library [1]. This does result in a slightly longer scan time than it should be, but nowhere as long as rescanning the entire library.

The exact definition of a “new file” is defined by the 60*24 part, as is the time calculates to 24hrs, but you can make that longer or shorter as desired by changing the numbers.

2 Likes

I have actually done some tests. I’m just a beginner but it just worked so far.

VPS Server with Plex Media Server installed
rclone mount --allow-non-empty --allow-other --read-only [secret:path/to/mount] [/mnt/TEST]

So far so good with rclone v.1.35, anyone else has tested it?
Plex sees correctly the files and i have tested with a 100 movies section without any issues. No ban, good speed/performance scanning and streaming.

Now i need to go for the next step which is going to production, but for that i would need to write the scripts for mounting, and plex, and plexpy and so on.

any other suggestions or issues detected?

Are you using GDrive or ACD?

I’m using Gdrive, but have tested also with Amazon.