Rc in rclone systemd mount helper script

Hello Guys,

today I tried to switch from my old systemd service to the systemd mount via new rclone mount helper introduced in v.1.57.0.

First of all my setup

  • Ubuntu 20.04
  • rclone version v.1.57.0
  • remote: crypted GDrive

my old systemd service:

[Unit]
Description = rclone crypt mount /mnt/rclone
After = network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/rclone mount GD_crypt:myFolder /mnt/rclone \
        --allow-other \
        --uid 997 \
        --gid 997 \
        --umask 002 \
        --dir-perms 775 \
        --file-perms 664 \
        --dir-cache-time 720h \
        --poll-interval 30s \
        --transfers 4 \
        --buffer-size 32M \
        --drive-chunk-size 256M \
        --drive-pacer-min-sleep 10ms \
        --drive-pacer-burst 1000 \
        --vfs-read-ahead 512M \
        --vfs-cache-max-age 2h \
        --vfs-cache-mode full \
        --vfs-cache-max-size 10G \
        --vfs-read-chunk-size 128M \
        --vfs-read-chunk-size-limit off \
        --log-file=/var/log/rclone/mount_rclone.log \
        --log-level=INFO \
        --rc \
        --rc-addr "0.0.0.0:5572" \
        --rc-enable-metrics \
        --rc-user rclone \
        --rc-pass myPassw0rd \
        --user-agent "GoogleDriveFS/51.0.16.0 (Windows;OSVer=10.0.22000;)"
ExecStop=/bin/fusermount -u -z /mnt/rclone
Restart=on-failure
RestartSec=20
User=root

[Install]
WantedBy=multi-user.target

I have changed this successfully to this one... and it worked!

[Unit]
Description=rclone crypt mount /mnt/rclone
Requires=systemd-networkd.service
Wants=network-online.target
After=network-online.target

[Mount]
What=GD_crypt:myFolder
Where=/mnt/rclone
Type=rclone
TimeoutSec=30
Options=defaults,nofail,args2env,config=/etc/.rclone.conf,cache-dir=/var/cache/rclone,allow-other,uid=997,gid=997,umask=002,dir-perms=775,file-perms=664,dir-cache-time=720h,poll-interval=30s,transfers=4,buffer-size=32M,drive-chunk-size=256M,drive-pacer-min-sleep=10ms,drive-pacer-burst=1000,vfs-read-ahead=512M,vfs-cache-max-age=2h,vfs-cache-mode=full,vfs-cache-max-size=10G,vfs-read-chunk-size=128M,vfs-read-chunk-size-limit=off,log-file=/var/log/rclone/mount_rclone.log,log-level=INFO

[Install]
WantedBy=multi-user.target

My Problem is, that when I add rc or even rc,rc-enable-metrics (I need this for monitoring), the mount fails.

● mnt-rclone.mount - rclone crypt mount /mnt/rclone
     Loaded: loaded (/etc/systemd/system/mnt-rclone.mount; enabled; vendor preset: enabled)
     Active: failed (Result: timeout) since Tue 2021-11-02 00:53:17 CET; 908ms ago
      Where: /mnt/rclone
       What: GD_crypt:myFolder
      Tasks: 0 (limit: 2286)
     Memory: 748.0K
     CGroup: /system.slice/mnt-rclone.mount

Nov 02 00:52:47 NAV systemd[1]: Mounting rclone crypt mount /mnt/rclone...
Nov 02 00:53:17 NAV systemd[1]: mnt-rclone.mount: Mounting timed out. Terminating.
Nov 02 00:53:17 NAV systemd[1]: mnt-rclone.mount: Mount process exited, code=killed, status=15/TERM
Nov 02 00:53:17 NAV systemd[1]: mnt-rclone.mount: Failed with result 'timeout'.
Nov 02 00:53:17 NAV systemd[1]: Failed to mount rclone crypt mount /mnt/rclone.

Log:

2021/11/02 01:30:43 INFO  : Using --user rclone --pass XXXX as authenticated user
2021/11/02 01:30:43 NOTICE: Serving remote control on http://localhost:5572/
2021/11/02 01:30:44 INFO  : Using --user rclone --pass XXXX as authenticated user
2021/11/02 01:30:44 Failed to start remote control: start server failed: listen tcp 127.0.0.1:5572: bind: address already in use
2021/11/02 01:31:13 INFO  : Signal received: terminated
2021/11/02 01:31:13 INFO  : Exiting...

Thanks in advance for your help!
P.S. would be nice when you give me some advices for my new systemd mount :slight_smile:

edit: I think I found it on github

Both ways are systemd and not sure what benefit one provides over the other. I'd just use the first way that worked imo.

From the error, it's saying it's already running / listening on the port you are trying to bind. Is another rclone mount already running?

@Dual-O

Correct. --rc does not yet work together with --daemon which is implied by the mount helper mode.

I have just added a disclaimer in rclone mount helper script · rclone/rclone Wiki · GitHub

@Animosity022

Yes, this user report considers only systemd way. Pure mount does not add any new functions but ugly one-line option syntax.

The main target of this change is fstab and automount. More methods are described in the wiki and in the rclone mount manual rclone mount.
In the above page I also mention the /etc/fstab method which became possible after 1.57

I expect the classic Automountd to start working with rclone after 1.57. I'm waiting for user responses to describe expeerience/caveats in the docs since I don't use it myself.

2 Likes

a little Feedback:
systemd mount and automount works really great in my dynamic cloud environment. The GDrive is mounting just in time, if I use it (ls /mnt/rclone). I will use this seamless mount integration in the feature.
Looking forward for the Remote-Control integration.

special thanks to @ivandeex and @ncw for this great feature

mnt-rclone.mount:

[Unit]
Description = rclone crypt mount  /mnt/rclone
Requires=systemd-networkd.service
Wants=network-online.target
After=network-online.target

[Mount]
What=GD_crypt:
Where= /mnt/rclone
Type=rclone
TimeoutSec=30
Options=rw,async,nouser,noauto,args2env,env.HOME=/root,allow-other

[Install]
WantedBy=multi-user.target

mnt-rclone.automount:

[Unit]
Description = automount rclone crypt /mnt/rclone
After=network-online.target
Before=remote-fs.target

[Automount]
Where=/mnt/rclone
TimeoutIdleSec=600

[Install]
WantedBy=multi-user.target
1 Like

Rclone is not aware of timeout enforced by systemd. It obeys its own timeout option daemon-wait=N which is 60 seconds by default (don't confuse it with daemon-timeout which is a historical setting for macOS kernels). It's up to you to make them consistent. At any rate a stuck mount will be killed by systemd or by rclone itself depending on which wait/timeout is shorter.

https://rclone.org/commands/rclone_mount/#options

1 Like

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