How to make rclone mount disk on boot restart in Openwrt?

What problem are you having with rclone?

I can't get rclone to mount virtual disk on restart using linux openwrt, I can only mount the disk on first boot, but on restart it doesn't boot again. I have to run the script manually for it to work.

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

root@OpenWrt:~# rclone --version
rclone v1.59.1

  • os/version: openwrt 22.03.0-rc6 (64 bit)
  • os/kernel: 5.10.134 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.18.4
  • go/linking: dynamic
  • go/tags: none

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

Google drive

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org

export PATH=/usr/sbin:/usr/bin:/sbin:/bin

exec &> /tmp/mount-gdrive.log

START=97
STOP=5

start() {
        rclone --config /root/.config/rclone/rclone.conf mkdir /tmp/gdrive
        rclone --config /root/.config/rclone/rclone.conf mount "gdrive:/" /tmp/gdrive/ --daemon --vfs-cache-mode full
}

stop() {
        fusermount -zu /tmp/gdrive

}

The contents of the rclone configuration with the secrets removed.

Configuration complete.
Options:
- type: drive
- scope: drive
- token: {"access_token": "secret"
- team_drive: "not configured"

A log of the command with the -vv flag

9/7/2022 10:29:13 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 [::1]:53: server misbehaving

A quick guess without knowing anything about openwrt:

The router hasn't fully established connection to the internet when it tries to start the mount, I would therefore (naively) try delaying the start with a 60 seconds sleep or similar.

I already tried to do that and it didn't work.
And amazingly, on other hardware
I managed to work perfectly.
The difference was that instead of installing just the rclone-config package, as the hardware had more space, I also installed the rclone packages (Rclone ("rsync for cloud storage") is a command line program to sync…), rclone-ng (An angular web application for rclone), rclone-webui-react(A full fledged UI for the rclone cloud sync tool.)

OK, sounds like you are already far ahead of me. Did you also try replacing the mount command with something simpler to verify the network connection?

Ideas: ping www.googleapis.com > trouble.log or rclone lsd gdrive: > trouble.log

I don't think the extra packages makes a difference.

hello and welcome to the forum,

based on START=97, the odds are the internet is up and running.

could be an issue with rclone accessing the local dns server over IPV6

might try to bind rclone to a IPV4 address, for example,
--bind=192.168.1.2

I think the way to solution is in the connection.
I just did some tests, an ip conflict is happening, I'm trying to solve it now. When configuring the rclone I did not configure the team-drive in the google account.
Can you tell if this configuration is mandatory if more than one machine wanted to access the same account?

I don’t know, perhaps @asdffdsa does?

in most cases, using the same config file, can run rclone on any number of machines at the same time,
based on the config file, you can do the same.
that has nothing to do teamdrive.

Finally!!! Finally!!!! Is alive!!!!
hahahahahahah!!!!" :crazy_face:
I feel like Dr. Frankenstein, :rofl: :rofl: :rofl:.
Sorry for the schizophrenia, but I'm really happy.
Hello everyone?
I managed to get rclone to mount the virtual disk on boot /restart.
I have a lot to thank, to all of you, and especially to Lynx, from the openwrt forum. Thank you very much. Without you I wouldn't be able to find a solution.
Thank you one more time!
I based it on the Lynx script and it looked like this:

#!/bin/sh /etc/rc.common
# Copyright (C) 2007 OpenWrt.org

export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export HOME=/root
exec &> /tmp/mount-Cam1-google-drive.log

START=97
STOP=5

start() {
       
reclone mout /Cam1: /mnt/sda3/Cam1
stop() {
        fusermount -zu /mnt/sda3/Cam1
}

The problem was in an ip conflict that wouldn't let the router connect to googledrive.
What made it difficult to find the problem was the fact that when running the script manually, it worked.
At first I did the tests on a VirtualBox vm, then I put it into production on a TP-Link 1043n router.
So... As we know... Information technology is not an exact science, when we replicate the procedure it fails, :rofl: :rofl: :rofl:.
I did something similar on a Banana-pi R2, but it failed. The script is more like yours though
I had to add a 40 second sleep before the "rclone mount" command. See how it turned out:
Preformatted text

#!/bin/sh /etc/rc.common


# Copyright (C) 2007 OpenWrt.org

export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export HOME=/root

exec &> /tmp/mount-rclone.log

START=99
STOP=4

sleep 40
start(){
       rclone mkdir /tmp/gdrive #--config /root/.config/rclone/
       rclone mount "gdrive:/" /tmp/gdrive/ --use-mmap --buffer-size 0 --cache-dir /tmp --vfs-cache-mode writes --vfs-cache-max-age 0s -- umask 000 --allow-other --daemon #--config /root/.config/rclone/
}

stop(){
       fusermount -zu /tmp/gdrive
       rclone rmdir /tmp/gdrive #--config /root/.config/rclone/
}

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