Rclone mount as service

Hello,
I have spent litrally a whole day trying to get my rclone to mount but as a service at startup and even though I have partialy failed i have learned a hell of a lot doing so.

I have read and followed alot of guidance by @Animosity022 replying to other users with a similar issue trying differnt things to get the service to start and actullay do what I can by running a command Manually.

Its now at the point where the service starts successfully but the google drive isn't viewable where it should be mounted.

What is the problem you are having with rclone?

Correctly mounting rclone at startup

What is your rclone version

rclone v1.53.3

  • os/arch: linux/amd64
  • go version: go1.15.5

Which OS you are using and how many bits?

Debian 4.19.160-2 (2020-11-28) x86_64

Which cloud storage system are you using?

Google Drive

The command you were trying to run

rclone mount --allow-non-empty --vfs-cache-mode=writes --allow-other --cache-db-purge gcache: /mnt/downloadhd/gdrive &

The rclone service config.

Service config evolution

A log from the command with the -vv flag

Journalctl

1 Like

I'd recommend to not use the cache backend.

Your service file needs to have a backslash at the end of the lines that continue on as the execstart is over multiple lines.

An example would be something like this:

ExecStart=/usr/bin/rclone mount gcrypt: /GD \
--allow-other \
--dir-cache-time 1000h \
--log-level NOTICE \
--log-file /opt/rclone/logs/rclone.log \
--poll-interval 15s \
--umask 002 \
--user-agent randomappname101 \
--rc \
--rc-addr :5572 \
--rc-no-auth \
--cache-dir=/cache \
--vfs-cache-mode full \
--vfs-cache-max-size 500G \
--vfs-cache-max-age 336h \
--bwlimit-file 16M

Notice the final line does not have the \ on it.

1 Like

And there you have it @Animosity022 you nailed it on the first response :smiley:

Previously when i added my rclone remote and mount location:
gdrive: /mnt/downloadhd/grdive

I was getting a failed service start about to many exceptions:

Command mount needs 2 arguments maximum: you provided 3 non flag arguments

This only stopped when i removed the mount location but resulted in the service starting but the drive not mounting correctly.

By removing the \ on the last flag allowed me to add my re-add my mount location, start the service and see my drive where it needed it to be :smiley:

So my correct winning service config is:

[Unit]
Description=GDrive (rclone)
RequiresMountsFor=/mnt/downloadhd/gdrive
After=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/rclone mount gdrive: /mnt/downloadhd/gdrive \
        --config /home/container/.config/rclone/rclone.conf \
        --allow-other \
        --allow-non-empty \
        --cache-db-purge \
        --max-transfer 750G \
        --vfs-cache-mode writes \
        --log-level INFO \
        --log-file /home/container/logs/rclone.log
ExecStop=/bin/fusermount -u /mnt/downloadhd/gdrive
Restart=always
RestartSec=10
User=container
Group=container

[Install]
WantedBy=default.target

Thanks for your swift response and resolution have a Merry Xmas :santa:t2:

hi,

  • based on @Animosity022 scripts, i would use
    ExecStop=/bin/fusermount -uz /mnt/downloadhd/gdrive
  • --allow-non-empty should be removed, unless 1000% sure it must be used
  • --cache-db-purge, if not using the cache remote, then this can be removed.

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