Rclone mount on reboot using a service

What is the problem you are having with rclone?

Autostart service on RPI reboot will not start.  
I have Google searched this topic and unable to find a solution that works
rclone is running great when I mount it manually after a reboot
I can mount GDrive manually no issue using: rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC
After mounting, the following will also work to unmount: fusermount -u  $HOME/mnt/GDrivePMSC
When I use: sudo systemctl start GoogleDrive.service
Yes, I have used: sudo systemctl daemon-reload
I get the following error: Job for GoogleDrive.service failed because the control process exited with error code.

Run the command 'rclone version' and share the full output of the command.

running on a RPI4, 32 bit system. with latest upgrades installed.
rclone v1.53.3-DEV
- os/arch: linux/arm
- go version: go1.15.5

Are you on the latest version of rclone? You can validate by checking the version listed here: Rclone downloads
--> The pi is up to date

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

Google Drive

The GoogleDrive.service file is located here:

/etc/systemd/system

and looks like this
All the #remmed out lines did not work....

[Unit]
Description=Auto Mount GDrivePMSC config  %i
Documentation=man:rclone(1)
#AssertPathIsDirectory=/home/ken/mnt/GDrivePMSC
After=multi-user.target

[Service]
#Type=simple
Type=notify
#ExecStartPre=/bin/mkdir -p %h/mnt/%i
#ExecStart= \
#  /usr/bin/rclone mount \
#    --fast-list \
#    --vfs-cache-mode writes \
#    --vfs-cache-max-size 100M \
#    %i: %h/mnt/%i
#ExecStart= rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC
#ExecStart= /usr/bin/rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon
ExecStart= /usr/bin/rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC

#ExecStop=/usr/bin/fusermount -u $HOME/mnt/GDrivePMSC
#Restart=always
#RestartSec=10

[Install]
WantedBy=multi-user.target

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

sudo systemctl start GoogleDrive.service
or a full pi reboot

1. List item

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

Usage:
  rclone config [flags]
  rclone config [command]

Available Commands:
  create      Create a new remote with name, type and options.
  delete      Delete an existing remote `name`.
  disconnect  Disconnects user from remote
  dump        Dump the config file as JSON.
  edit        Enter an interactive configuration session.
  file        Show path of configuration file in use.
  password    Update password in an existing remote.
  providers   List in JSON format all the providers and options.
  reconnect   Re-authenticates user with remote.
  show        Print (decrypted) config file, or the config for a single remote.
  update      Update options in an existing remote.
  userinfo    Prints info about logged in user of remote.

Flags:
  -h, --help   help for config

Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.

A log from the command that you were trying to run with the -vv flag

GoogleDrive.service - Auto Mount GDrivePMSC config  
     Loaded: loaded (/etc/systemd/system/GoogleDrive.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-10-14 06:09:58 PDT; 1min 11s ago
       Docs: man:rclone(1)
    Process: 8207 ExecStart=/usr/bin/rclone mount /home/ken/mnt/GDrivePMSC: $HOME/mnt/GDrivePMSC (code=exited, status=1/FAILURE)
   Main PID: 8207 (code=exited, status=1/FAILURE)
        CPU: 103ms

Oct 14 06:09:58 Rpi4Test rclone[8207]:       --vfs-write-wait duration                Time to wait for in-sequence write before giving error.>
Oct 14 06:09:58 Rpi4Test rclone[8207]:       --volname string                         Set the volume name (not supported by all OSes).
Oct 14 06:09:58 Rpi4Test rclone[8207]:       --write-back-cache                       Makes kernel buffer writes before sending them to rclon>
Oct 14 06:09:58 Rpi4Test rclone[8207]: Use "rclone [command] --help" for more information about a command.
Oct 14 06:09:58 Rpi4Test rclone[8207]: Use "rclone help flags" for to see the global flags.
Oct 14 06:09:58 Rpi4Test rclone[8207]: Use "rclone help backends" for a list of supported services.
Oct 14 06:09:58 Rpi4Test rclone[8207]: Command mount needs 2 arguments minimum: you provided 1 non flag arguments: ["/home/ken/mnt/GDrivePMSC>
Oct 14 06:09:58 Rpi4Test systemd[1]: GoogleDrive.service: Main process exited, code=exited, status=1/FAILURE
Oct 14 06:09:58 Rpi4Test systemd[1]: GoogleDrive.service: Failed with result 'exit-code'.
Oct 14 06:09:58 Rpi4Test systemd[1]: Failed to start Auto Mount GDrivePMSC config  .

welcome to the forum,

  1. uninstall v1.53.3-DEV
  2. install v1.64.0
  3. use a rclone debug log. try something like
    --log-level=DEBUG --log-file=$HOME/path/to/rclone.log
  4. test again

OK, I reinstalled RClone and having the same issues
If anyone has a sample that they can provide or suggestions....
Again, manually - everything is good. But on reboot of the RPI, I loose the mount.

Trying to mount GDrive on boot on a Rpi4
I can do this manually running
rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC

When I try to do it on boot as a service
(file name is saved as :/etc/systemd/system/GoogleDrive.service )

Description=Auto Mount GDrivePMSC config  %i
Documentation=man:rclone(1)
#AssertPathIsDirectory=/home/ken/mnt/GDrivePMSC
After=multi-user.target

[Service]
Type=notify
#ExecStart= rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC
#ExecStart= \
#  /usr/bin/rclone mount \
#    --fast-list \
#    --vfs-cache-mode writes \
#    --vfs-cache-max-size 100M \
#    %i: %h/mnt/%i
#ExecStart= /usr/bin/rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon
ExecStart= /usr/bin/rclone mount /home/ken/mnt/GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon

[Install]
WantedBy=multi-user.target

I have tried all the remmed out lines, none work
I get the following error

● GoogleDrive.service - Auto Mount GDrivePMSC config  
     Loaded: loaded (/etc/systemd/system/GoogleDrive.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2023-10-15 09:39:39 PDT; 9min ago
       Docs: man:rclone(1)
    Process: 29233 ExecStart=/usr/bin/rclone mount /home/ken/mnt/GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon (code=exited, status=1/FAILURE)
   Main PID: 29233 (code=exited, status=1/FAILURE)
        CPU: 282ms

Oct 15 09:39:39 Rpi4Test rclone[29233]:       --min-age Duration                    Only transfer files older than this in s or suffix ms|s|m|h|d>
Oct 15 09:39:39 Rpi4Test rclone[29233]:       --min-size SizeSuffix                 Only transfer files bigger than this in KiB or suffix B|K|M|G>
Oct 15 09:39:39 Rpi4Test rclone[29233]: Additional help topics:
Oct 15 09:39:39 Rpi4Test rclone[29233]: Use "rclone [command] --help" for more information about a command.
Oct 15 09:39:39 Rpi4Test rclone[29233]: Use "rclone help flags" for to see the global flags.
Oct 15 09:39:39 Rpi4Test rclone[29233]: Use "rclone help backends" for a list of supported services.
Oct 15 09:39:39 Rpi4Test rclone[29233]: Command mount needs 2 arguments minimum: you provided 1 non flag arguments: ["/home/ken/mnt/GDrivePMSC:"]
Oct 15 09:39:39 Rpi4Test systemd[1]: GoogleDrive.service: Main process exited, code=exited, status=1/FAILURE
Oct 15 09:39:39 Rpi4Test systemd[1]: GoogleDrive.service: Failed with result 'exit-code'.
Oct 15 09:39:39 Rpi4Test systemd[1]: Failed to start Auto Mount GDrivePMSC config  .

When you try to run it from cmd you run:

rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC

but from service file you run:

/usr/bin/rclone mount /home/ken/mnt/GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon

so obviously results are different.

Run the same command and you will be closer to solving the problem.

Appreciate the thoughts and reply - really I do!

the following works at the cmd line:

rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC

For the service file, I have tried the following and all did not work:

ExecStart=rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC
ExecStart=rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon
ExecStart= /usr/bin/rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon
ExecStart= /usr/bin/rclone mount /home/ken/mnt/GDrivePMSC: $HOME/mnt/GDrivePMSC --daemon

Nothing seems to work.
Others have to have a service running...
Looking for ideas where I should look

start with:

ExecStart=rclone mount GDrivePMSC: $HOME/mnt/GDrivePMSC

but add debug logging to file and provide results here

also why do use $HOME when your service file is run as root $HOME might be not what you want

Here good tested example of service file to mount remote with comments.

Adapt it for your needs and remote - start with basics with logging. When it works you can make it funky.

Still playing with this code to try and get it working...
Yes - this is my first RClone attempt :slight_smile:
I now have the service running (ie not crashing), but my folders do not show up.....
This is the service

#/etc/systemd/system/GDrive.service
[Unit]
Description=Auto Mount GDrivePMSC
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/home/ken/.config/rclone/rclone.conf
ExecStartPre=/bin/mkdir -p /home/ken/mnt/GDrivePMSC
ExecStart= /usr/bin/rclone mount \
        --log-file /home/ken/Documents/logs/rclone.log \
        --log-level INFO \
        --allow-non-empty \
        #--vfs-cache-poll-interval duration
        /home/ken/.config/rclone/GDrive: /home/ken/mnt/GDrivePMSC
ExecStop=/usr/bin/fusermount -u /home/ken/mnt/GDrivePMSC
[Install]
WantedBy=multi-user.target

The service runs - display from systemctl list-units --type=service

GDrive.service                                              loaded active run

and the Log file:

2023/10/17 21:47:30 INFO  : Local file system at /home/ken/.config/rclone/GDrive:: poll-interval is not supported by this remote

and the output from running: systemctl status GDrive.service

GDrive.service - Auto Mount GDrivePMSC
    Loaded: loaded (/etc/systemd/system/GDrive.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2023-10-17 21:47:30 PDT; 32min ago
   Process: 22973 ExecStartPre=/bin/mkdir -p /home/ken/mnt/GDrivePMSC (code=exited, status=0/SUCCESS)
  Main PID: 22974 (rclone)
     Tasks: 11 (limit: 1599)
       CPU: 807ms
    CGroup: /system.slice/GDrive.service
            └─22974 /usr/bin/rclone mount --log-file /home/ken/Documents/logs/rclone.log --log-level INFO --allow-non->

Oct 17 21:47:30 raspberrypi systemd[1]: Starting Auto Mount GDrivePMSC...
Oct 17 21:47:30 raspberrypi systemd[1]: Started Auto Mount GDrivePMSC.
Oct 17 22:07:54 raspberrypi systemd[1]: /etc/systemd/system/GDrive.service:1: Assignment outside of section. Ignoring.

My issue is that the mnt folders GDrivePMSC show nothing
Yet I can manually rclone them and they show fine.

Any suggestions?
Thanks in advance.

  1. mount your remote - not some random local folder:

Do you have remote called /home/ken/.config/rclone/GDrive: ???

  1. Your service runs as root and you try to access mount probably as a user. Either add to your service instructions to run it on behalf of specific user or make mount accessible for other users ( --allow-other flag).

All together try:

#/etc/systemd/system/GDrive.service
[Unit]
Description=Auto Mount GDrivePMSC
Wants=network-online.target
After=network-online.target

[Service]
Type=notify
Environment=RCLONE_CONFIG=/home/ken/.config/rclone/rclone.conf
ExecStartPre=/bin/mkdir -p /home/ken/mnt/GDrivePMSC
ExecStart= /usr/bin/rclone mount \
        --log-file /home/ken/Documents/logs/rclone.log \
        --log-level DEBUG \
        --allow-non-empty \
        --allow-other \
        GDrivePMSC: /home/ken/mnt/GDrivePMSC
ExecStop=/usr/bin/fusermount -u /home/ken/mnt/GDrivePMSC
[Install]
WantedBy=multi-user.target

Any issues post content of /home/ken/Documents/logs/rclone.log

So Close. And many thanks for your help so far.
OK, I have the service starting and stopping using sudo systemctl start GDrive.service and stop
but it fails to run on reboot.
Error msg is about Root directory ID...
Any suggestions?

Question: See comments about user vs system service.
No clue what the difference is, and first time ever using a service.
Would this be easier if a user service?
The RPI will only be run by the user ken, no other.

# /etc/systemd/system/GDrive.service
[Unit]
Description=Auto Mount GDrivePMSC
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
Environment=RCLONE_CONFIG=/home/ken/.config/rclone/rclone.conf
ExecStartPre=/bin/mkdir -p /home/ken/mnt/GDrivePMSC
ExecStart= /usr/bin/rclone mount \
        --log-file /home/ken/Documents/logs/rclone.log \
        --log-level DEBUG \
# if no issues and to reduce overhead
#       --log-level INFO \
        --allow-non-empty \
        --allow-other \
        GDrive: /home/ken/mnt/GDrivePMSC
ExecStop=/usr/bin/fusermount -u /home/ken/mnt/GDrivePMSC

[Install]
WantedBy=multi-user.target

The log file shows an error:

2023/10/19 17:18:39 DEBUG : rclone: Version "v1.53.3-DEV" starting with parameters ["/usr/bin/rclone" "mount" "--log-file" "/home/ken/Documents/logs/rclone.log" "--log-level" "DEBUG" "--allow-non-empty" "--allow-other" "GDrive:" "/home/ken/mnt/GDrivePMSC"]
2023/10/19 17:18:39 DEBUG : Creating backend with remote "GDrive:"
2023/10/19 17:18:39 DEBUG : Using config file from "/home/ken/.config/rclone/rclone.conf"
2023/10/19 17:18:39 DEBUG : pacer: low level retry 1/1 (error Get "https://www.googleapis.com/drive/v3/files/root?alt=json&fields=id&prettyPrint=false&supportsAllDrives=true": dial tcp: lookup www.googleapis.com on 192.168.1.1:53: dial udp 192.168.1.1:53: connect: network is unreachable)
2023/10/19 17:18:39 DEBUG : pacer: Rate limited, increasing sleep to 1.994412087s
2023/10/19 17:18:39 Failed to create file system for "GDrive:": couldn't find root directory ID: Get "https://www.googleapis.com/drive/v3/files/root?alt=json&fields=id&prettyPrint=false&supportsAllDrives=true": dial tcp: lookup www.googleapis.com on 192.168.1.1:53: dial udp 192.168.1.1:53: connect: network is unreachable

that is a network issue, something to do with dns.

The service works after a reboot by using the following cmd:

sudo systemctl start GDrive.service
  or
sudo systemctl restart GDrive.service

but not on reboot
Suggestion is that it is a network issue. And I also see that in the forums...
But no solutions/resolutions posted that I see.
Any ideas?
Is there a way to delay the execution and run the service in another way?
Could it be a user rights issue?
Looking for ideas where I should look....

if you want have a systemd service run at boot, you have to enable it.
sudo systemctl enable GDrive.service

fwiw, i am not an expert with systemd.
i searched the internet for systemd gudies and just followed them.

I believe that I have solved my issue
In the service section, use
Type=idle
and now it seams to start fine!
Once I test, I will post up my solution.

1 Like

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