Rclone autoscript on OSMC / Vero 4K +

What is the problem you are having with rclone?

Trying to create an autostart/automount script, and when I manually mount via SSH it locks/freezes when I browse the folders. It takes a very long time to access/browse media content.

What is your rclone version (output from rclone version)

rclone v1.45

  • os/arch: linux/arm

  • go version: go1.11.6

(Installed via sudo apt-get rclone install)

Which OS you are using and how many bits (eg Windows 7, 64 bit)

OSMC on a Vero 4k +

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount crypt:media /home/osmc/gsuite --allow-non-empty --size-only --dir-cache-time=2m --fast-list --vfs-read-chunk-size=96M --vfs-cache-max-age 675h --vfs-read-chunk-size-limit=1G --buffer-size=48M

The rclone config contents with secrets removed.

[gsuite]

type = drive

client_id = x

client_secret = x

scope = drive

token = {"access_token":x

[crypt]

type = crypt

remote = gsuite:media

filename_encryption = standard

directory_name_encryption = true

password = x

A log from the command with the -vv flag

[https://pastebin.com/ghj6sjTJ](https://pastebin.com/ghj6sjTJ)

I tried to follow these instructions:

cd /home/osmc
mkdir scripts
cd scripts
nano mountscript.sh
chmod +x mountscript.sh

mountscript.sh looks like this

$!/bin/bash

rclone mount crypt:media /home/osmc/gsuite --allow-non-empty size-only --dir-cache-time=2m --fast-list --vfs-read-chunk-size=96M --vfs-cache-max-age 675h --vfs-read-chunk-size-limit=1G --buffer-size=48M

Then I did:

*sudo nano /lib/systemd/system/test.service

and typed in:

[Unit]
Description=rclone_mount
After=network.target

[Service]
ExecStart=/home/osmc/scripts/mountscript.sh

[Install]
WantedBy=multi-user.target

and at last:

*sudo systemctl daemon-reload
*sudo systemctl enable test.service
*sudo systemctl start test.service

But it does not mount when I restart. (This is my first time trying such a script as this)

Output from this command:

*sudo systemctl start test.service

Failed to start test.service: Unit test.service has a bad unit file setting.

See system logs and ‘systemctl status test.service’ for details.

I haven’t found out how to see the system logs yet.

Your service file does not look quite right as it points to a script?

What version of rclone are you running?

Thank you for the reply.

I see now that I didn't copy paste it correctly.

I tried to follow this guide, if you scroll to the bottom there is some sort of step-by-step.

That version is ancient and should be updated.

Here is my service file as an example:

felix@gemini:/etc/systemd/system$ cat rclone.service
[Unit]
Description=RClone Service
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/opt/rclone/rclone.conf
KillMode=none
RestartSec=5
ExecStart=/usr/bin/rclone mount gcrypt: /GD \
# This is for allowing users other than the user running rclone access to the mount
--allow-other \
# Google Drive is a polling remote so this value can be set very high and any changes are detected via polling.
--dir-cache-time 1000h \
# To log to syslog as well
--syslog \
# I reduce the poll internval down to 15 seconds as this makes changes appear fast the API quotas per day are huge
--poll-interval 15s \
# This is setting the file permission on the mount to user and group have the same access and other can read
--umask 002 \
# Please set this to your own value below
--user-agent randomappname102 \
# This sets up the remote control daemon so you can issue rc commands locally
--rc \
# This is the default port it runs on
--rc-addr :5572 \
# no-auth is used as no one else uses my server and it is not a shared seedbox
--rc-no-auth \
# The local disk used for caching
--cache-dir=/cache \
# This is used for caching files to local disk for streaming
--vfs-cache-mode full \
# This limits the cache size to the value below
--vfs-cache-max-size 750G \
# This adds a little buffer for read ahead
--vfs-read-ahead 256M \
# This limits the age in the cache if the size is reached and it removes the oldest files first
--vfs-cache-max-age 1000h \
# This sets a per file bandwidth control and I limit this to a little bigger than my largest bitrate I'd want to play
--bwlimit-file 16M
ExecStop=/bin/fusermount -uz /GD
ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --rc-addr 127.0.0.1:5572 _async=true
Restart=on-failure
User=felix
Group=felix

[Install]
WantedBy=multi-user.target

Thank you very much!!

Any guidance on how to best update it now that it is already installed ?

Rclone should always be installed via this:

https://rclone.org/downloads/#script-download-and-install

Thank you, I tried that one, and this happened:

osmc@osmc:~$ curl https://rclone.org/install.sh | sudo bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4491 100 4491 0 0 11604 0 --:--:-- --:--:-- --:--:-- 11574
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15 100 15 0 0 56 0 --:--:-- --:--:-- --:--:-- 56
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12.6M 100 12.6M 0 0 14.1M 0 --:--:-- --:--:-- --:--:-- 14.1M
unzip: invalid option -- 'a'
BusyBox v1.30.1 (Debian 1:1.30.1-4) multi-call binary.

Usage: unzip [-lnojpq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]

Extract FILEs from ZIP archive

-l List contents (with -q for short form)
-n Never overwrite files (default: ask)
-o Overwrite
-j Do not restore paths
-p Print to stdout
-q Quiet
-x FILE Exclude FILEs
-d DIR Extract into DIR
osmc@osmc:~$ rclone version
rclone v1.45

  • os/arch: linux/arm
  • go version: go1.11.6

You may want to check on the OSMC forums on how to properly install it.

1 Like

I guess you can get around this specific problem by installing unzip:
sudo apt-get install unzip

The theory is: The https://rclone.org/install.sh script looks for commands: unzip, 7z and busybox, and uses whichever it finds first. In your case it finds unzip and executes it as unzip -a "$rclone_zip" -d "$unzip_dir". But in reality unzip is just a symbolic link to busybox, which does not understand the -a argument. The install script should have executed it as it would if only busybox was found:
mkdir -p "$unzip_dir" && unzip "$rclone_zip" -d "$unzip_dir". By installing a "real" unzip utility you work around this (until the install.sh script is fixed, if the theory is correct).

1 Like

Thank you, this worked with regards to installing rclone with the install script!

I managed to install the latest rclone and tried your script (with some changes);

>     [Unit]
> Description=RClone Service
> Wants=network-online.target
> After=network-online.target
> 
> [Service]
> Type=notify
> Environment=RCLONE_CONFIG=/home/osmc/.config/rclone/rclone.conf
> KillMode=none
> RestartSec=5
> ExecStart=/usr/bin/rclone mount crypt:media /home/osmc/gsuite \
> # This is for allowing users other than the user running rclone access to the mount
> --allow-other \
> # Google Drive is a polling remote so this value can be set very high and any changes are detected via polling.
> --dir-cache-time 1000h \
> # To log to syslog as well
> --syslog \
> # I reduce the poll internval down to 15 seconds as this makes changes appear fast the API quotas per day are huge
> --poll-interval 15s \
> # This is setting the file permission on the mount to user and group have the same access and other can read
> --umask 002 \
> # Please set this to your own value below
> --user-agent randomappname102 \
> # This sets up the remote control daemon so you can issue rc commands locally
> --rc \
> # This is the default port it runs on
> --rc-addr :5572 \
> # no-auth is used as no one else uses my server and it is not a shared seedbox
> --rc-no-auth \
> # The local disk used for caching
> --cache-dir=/cache \
> # This is used for caching files to local disk for streaming
> --vfs-cache-mode full \
> # This limits the cache size to the value below
> --vfs-cache-max-size 750G \
> # This adds a little buffer for read ahead
> --vfs-read-ahead 256M \
> # This limits the age in the cache if the size is reached and it removes the oldest files first
> --vfs-cache-max-age 1000h \
> # This sets a per file bandwidth control and I limit this to a little bigger than my largest bitrate I'd want to play
> --bwlimit-file 16M
> ExecStop=/bin/fusermount -uz /home/osmc/gsuite
> ExecStartPost=/usr/bin/rclone rc vfs/refresh recursive=true --rc-addr 127.0.0.1:5572 _async=true
> Restart=on-failure
> User=osmc
> Group=osmc
> 
> [Install]
> WantedBy=multi-user.target

This gives me an error:

osmc@osmc:~$ sudo systemctl start rclone.service

Job for rclone.service failed because the control process exited with error code.

See "systemctl status rclone.service" and "journalctl -xe" for details.

osmc@osmc:~$ systemctl status rclone.service

  • rclone.service - RClone Service
    Loaded: loaded (/lib/systemd/system/rclone.service; enabled; vendor preset: enabled)
    Active: activating (auto-restart) (Result: exit-code) since Sat 2021-05-01 11:12:01 CEST; 899ms ago
    Process: 5040 ExecStart=/usr/bin/rclone mount crypt:media /home/osmc/gsuite --allow-other --dir-cache-time 1000h --syslog --poll-interval 15s --umask 002 --user-agent randomappname102 --rc --rc-addr :5572 -
    Main PID: 5040 (code=exited, status=1/FAILURE)

May 01 11:12:01 osmc systemd[1]: Failed to start RClone Service.
lines 1-7/7 (END)

After some mucking about it seems I got this working.

/lib/systemd/system/rclone.service file looks like this:

[Unit]
Description=rclone_mount
After=network-online.target
Wants=network-online.target

[Service]
Environment=RCLONE_CONFIG=/home/osmc/.config/rclone/rclone.conf
ExecStart=/home/osmc/scripts/mountscript.sh

[Install]
WantedBy=multi-user.target

/home/osmc/scripts/mountscript.sh file looks like this:

#!/bin/bash

/usr/bin/rclone mount crypt:media /home/osmc/gsuite --allow-non-empty --allow-other --size-only --dir-cache-time=2m --fast-list --vfs-read-chunk-size=96M --vfs-cache-max-age 675h --vfs-read-chunk-size-limit=1G --buffer-size=48M


These are the settings/variables I use on a coreelec-box and I got them from another rclone-user.

Are there any improvements to me made? I have a rather large library.

1 Like

--fast-list does nothing on a mount.

You are making thing slow by using a low dir-cache-time.

--allow-non-empty is not a good flag and really shouldn't be used unless you have a very specific use case for it.

Why did you set buffer-size and chunk-limit?

Instead of pointing to a script, you should move that rclone mount line to your ExecStart line.

Thank you for the reply.

I must confess I have sort of "inherited" these settings/variables when I found out rclone could be used on my coreelec-box, and they have worked, so I have not done any more research to improve it, but now that I have had some problems with my OSMC-box I would like to make it as good as possible.

--fast-list will be removed

dir-cache-time= what is the better choice here ?

--allow-non-empty will be removed if possible.

buffer-size and chunk-limit were one of my "inherited" settings. Should they just be removed ?

Thank you, I will try to move the rclone mount line!