Best practices for service file to speed up video loading w/ gdrive?

I should call this thread "roast my garbage service file" because I've cobbled it together from other people. Here's my usecase:

  • google drive connected to Jellyfin holding media.
  • server has 30gb of free space, low powered vps
  • connection is 480Mbsp up and down

My service file, if anyone has thoughts on what to add / remove to help videos load more quickly play reliably, I'm all ears. Bonus points if you could educate me as to what I am changing and why. TIA.

[Unit]
Description=RClone Media Mount Service
After=network-online.target

[Service]
Environment=RCLONE_CONFIG=/home/xxxxxxx/.config/rclone/rclone.conf
RestartSec=5
ExecStart=/usr/bin/rclone mount gdrive:xxx /home/xxxxxxx/media \
  --allow-other \
  --umask=002 \
  --vfs-cache-mode full \
  --vfs-cache-max-size 20G \
  --vfs-cache-max-age 15m \
  --vfs-read-ahead 2G

ExecStop=/usr/bin/fusermount -uz /home/xxxxxxx/media

Restart=on-failure
RestartSec=10

User=ubuntu
Group=ubuntu

[Install]
WantedBy=multi-user.target

It looks ok but I would increase --vfs-cache-max-age. 15m is definitely wrong. If you use cache keep data there as long as possible so set it to e.g. 9999h

Gdrive is polling remote so you can also add --dir-cache-time 9999h

In addition add cache warming using rc interface.

All together:

[Unit]
Description=RClone Media Mount Service
Wants=network-online.target
After=network-online.target

[Service]
Environment=RCLONE_CONFIG=/home/xxxxxxx/.config/rclone/rclone.conf
RestartSec=5
ExecStart=/usr/bin/rclone mount gdrive:xxx /home/xxxxxxx/media \
  --allow-other \
  --umask=002 \
  --vfs-cache-mode full \
  --vfs-cache-max-size 20G \
  --vfs-cache-max-age 9999h \
  --dir-cache-time 9999h \
  --rc \
  --rc-addr 127.0.0.1:5575 \
  --rc-no-auth \
  --vfs-read-ahead 2G

ExecStop=/usr/bin/fusermount -uz /home/xxxxxxx/media
ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --url 127.0.0.1:5575 _async=true

Restart=on-failure
User=ubuntu
Group=ubuntu

[Install]
WantedBy=multi-user.target

I tried the updated file you suggested, it's now throwing an error:

Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ An ExecStart= process belonging to unit rclone.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Sep 14 11:58:56 jellyfin-gdrive-optimized rclone[21769]: Failed to rc: connection failed: Post "http://127.0.0.1:5575/vfs/refresh": dial tcp 127.0.0.1:5575: connect: connection refused
Sep 14 11:58:56 jellyfin-gdrive-optimized systemd[1]: rclone.service: Control process exited, code=exited, status=5/NOTINSTALLED
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ An ExecStartPost= process belonging to unit rclone.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 5.
Sep 14 11:58:56 jellyfin-gdrive-optimized systemd[1]: rclone.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit rclone.service has entered the 'failed' state with result 'exit-code'.
Sep 14 11:58:56 jellyfin-gdrive-optimized systemd[1]: Failed to start RClone Media Mount Service.
░░ Subject: A start job for unit rclone.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit rclone.service has finished with a failure.
░░
░░ The job identifier is 3702 and the job result is failed.

Run mount command from command line with -vv and post output here.

Or add :

--log-file /path/to/rclone.log --log-level DEBUG

try to start it again and post rclone.log here

Sorry, I'm slow. How would I run the mount command with all those flags from the command line?

/usr/bin/rclone mount gdrive:xxx /home/xxxxxxx/media --allow-other --umask=002 [...all other flags...] -vv

1 Like

Thank you, sorry it took a few days but I was able to get this working and it feels crisp and speedy!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.