Rclone configuration for OpenWrt (mounting OneDrive and Google Drive)

In this post, I would like to share my experience of mounting OneDrive and Google Drive by setting up rclone on OpenWrt router.

  • I spent some time figuring out the details, and I hope this guide will help others mount Microsoft OneDrive and/or Google Drive disks on OpenWrt router. This guide focuses on the rclone setup, and sharing the mounted drives via Samba4 is out of scope for this topic.

So, let's get started.
1. Prepare for authorization: since rclone needs access to your OneDrive and Google Drive accounts (tokens, IDs, etc.), the easiest way to achieve this is by using a Linux machine with a UI. note: if you’re a Windows user like me, you can install Ubuntu in virtual machine (e.g use VirtualBox).

2. Open Linux terminal in your virtual machine with Ubuntu and install rclone:

sudo apt update
sudo apt install rclone

3. Run the following command in the terminal to configure rclone to work with OneDrive:
rclone config
Proceed with all the questions for OneDrive configuration until the Remote config question, to which you should answer Y. As a result, the Microsoft OneDrive page will automatically open in the Ubuntu's browser, asking you to log in and authorize the rclone application for OneDrive.

See the command details and screenshots for OneDrive.
test@test-VirtualBox:~$ rclone config
2025/03/08 17:16:42 NOTICE: Config file "/home/test/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> onedrive
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / 1Fichier
   \ "fichier"
 2 / Alias for an existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, Tencent COS, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Dropbox
   \ "dropbox"
10 / Encrypt/Decrypt a remote
   \ "crypt"
11 / FTP Connection
   \ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
15 / Hubic
   \ "hubic"
16 / In memory object storage system.
   \ "memory"
17 / Jottacloud
   \ "jottacloud"
18 / Koofr
   \ "koofr"
19 / Local Disk
   \ "local"
20 / Mail.ru Cloud
   \ "mailru"
21 / Microsoft Azure Blob Storage
   \ "azureblob"
22 / Microsoft OneDrive
   \ "onedrive"
23 / OpenDrive
   \ "opendrive"
24 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
25 / Pcloud
   \ "pcloud"
26 / Put.io
   \ "putio"
27 / SSH/SFTP Connection
   \ "sftp"
28 / Sugarsync
   \ "sugarsync"
29 / Transparently chunk/split large files
   \ "chunker"
30 / Union merges the contents of several upstream fs
   \ "union"
31 / Webdav
   \ "webdav"
32 / Yandex Disk
   \ "yandex"
33 / http Connection
   \ "http"
34 / premiumize.me
   \ "premiumizeme"
35 / seafile
   \ "seafile"
Storage> 22
** See help for onedrive backend at: https://rclone.org/onedrive/ **

OAuth Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> 
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> 
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> Y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=XXXXXXXXXXXXXXXXX
Log in and authorize rclone for access
Waiting for code...
.........

4. Run the following command in the terminal to configure rclone to work with Google Drive:
rclone config
Proceed with all the questions for Google Drive configuration until the Remote config question, to which you should answer Y. As a result, the Google Drive page will automatically open in the Ubuntu's browser, asking you to log in and authorize the rclone application for GoogleDrive.

See the command details and screenshots for Google Drive.
test@test-VirtualBox:~$ rclone config
2025/03/08 17:22:32 NOTICE: Config file "/home/test/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> googledrive      
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / 1Fichier
   \ "fichier"
 2 / Alias for an existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, Tencent COS, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Dropbox
   \ "dropbox"
10 / Encrypt/Decrypt a remote
   \ "crypt"
11 / FTP Connection
   \ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
15 / Hubic
   \ "hubic"
16 / In memory object storage system.
   \ "memory"
17 / Jottacloud
   \ "jottacloud"
18 / Koofr
   \ "koofr"
19 / Local Disk
   \ "local"
20 / Mail.ru Cloud
   \ "mailru"
21 / Microsoft Azure Blob Storage
   \ "azureblob"
22 / Microsoft OneDrive
   \ "onedrive"
23 / OpenDrive
   \ "opendrive"
24 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
25 / Pcloud
   \ "pcloud"
26 / Put.io
   \ "putio"
27 / SSH/SFTP Connection
   \ "sftp"
28 / Sugarsync
   \ "sugarsync"
29 / Transparently chunk/split large files
   \ "chunker"
30 / Union merges the contents of several upstream fs
   \ "union"
31 / Webdav
   \ "webdav"
32 / Yandex Disk
   \ "yandex"
33 / http Connection
   \ "http"
34 / premiumize.me
   \ "premiumizeme"
35 / seafile
   \ "seafile"
Storage> 13
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id> 
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> 
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 1
ID of the root folder
Leave blank normally.

Fill in to access "Computers" folders (see docs), or for rclone to use
a non root folder as its starting point.

Enter a string value. Press Enter for the default ("").
root_folder_id> 
Service Account Credentials JSON file path 
Leave blank normally.
Needed only if you want use SA instead of interactive login.

Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.

Enter a string value. Press Enter for the default ("").
service_account_file> 
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> Y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=xxxxxxxxxxxx
Log in and authorize rclone for access
Waiting for code...
Got code
Configure this as a team drive?
y) Yes
n) No (default)
y/n> n
--------------------
[googledrive]
scope = drive
token = {"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"Bearer","refresh_token":"xxxxxxxxxxxxxx","expiry":"xxxxxxxxxxxxxx"}
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name                Type
=========       ====
googledrive       drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q



5. Now we need the rclone config file, which contains all the authorization details we obtained for OneDrive and Google Drive. This file will be used in OpenWrt.

test@test-VirtualBox:~$ rclone config file
Configuration file is stored at:
/home/test/.config/rclone/rclone.conf

Let's copy rclone.conf file to Ubuntu desktop ("test" folder):

test@test-VirtualBox:~/Desktop$ mkdir ~/Desktop/test
test@test-VirtualBox:~/Desktop$ cp /home/test/.config/rclone/rclone.conf ~/Desktop/test/rclone.conf

6. Transfer rclone.conf file from Ubuntu desktop into your OpenWrt router, e.g. into /etc/config/ folder in OpenWrt (use any method convenient for you to transfer the file).
Install rclone in OpenWrt:

opkg update & opkg install rclone

7. In OpenWrt, copy rclone.conf file from /etc/config/ folder to /root/.config/rclone/ folder (rclone uses this location by default for the configuration file).

root@OpenWrt:~# rclone config file
Configuration file is stored at:
/root/.config/rclone/rclone.conf
root@OpenWrt:~# cp /etc/config/rclone.conf /root/.config/rclone/rclone.conf

8. Let's mount OneDrive and Google Drive on OpenWrt ( :exclamation: note: use only /tmp (router's RAM) folder for mounting to prevent any writes to the router's NAND flash chip).

root@OpenWrt:~# mkdir /tmp/onedrive
root@OpenWrt:~# mkdir /tmp/googledrive
root@OpenWrt:~# rclone mount onedrive: /tmp/onedrive/ --use-mmap --buffer-size 0 --cache-dir /tmp --vfs-cache-mode writes --vfs-cache-max-age 0s --umask 000 --allow-other --daemon
root@OpenWrt:~# rclone mount googledrive: /tmp/googledrive/ --use-mmap --buffer-size 0 --cache-dir /tmp --vfs -cache-mode writes --vfs-cache-max-age 0s --umask 000 --allow-other --daemon

To test access, run the following commands one by one:

root@OpenWrt:~# rclone lsd onedrive:
root@OpenWrt:~# rclone lsd /tmp/onedrive
root@OpenWrt:~# rclone lsd googledrive:
root@OpenWrt:~# rclone lsd /tmp/googledrive

That's it. After completing all these steps, your OneDrive and Google Drive should be mounted on OpenWrt. You can now share them as network folders using Samba4.

  • note: configuration in the point 8 is not permanent and will be lost after a router reboot. To address this, you’ll need to create a shell script that runs automatically after the OpenWrt reboot to mount the disks again. For example, you can adapt this script from @Lynx.

I appreciate any feedback on my configuration, particularly suggestions for optimizing the parameters in point 8 for the rclone mount. Thank you.

root@OpenWrt:~# rclone --version
rclone v1.69.1
- os/version: openwrt 24.10.0 (64 bit)
- os/kernel: 6.6.73 (aarch64)
- os/type: linux
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.23.6
- go/linking: dynamic
- go/tags: none
2 Likes

I’ve used that script for years and it’s worked well. Users of rclone: take care to avoid any writes to router flash and hence rapid flash wear! Rather /tmp (router RAM) should for used for everything. That’s something that I tried to ensure with those various options in the script - especially the buffer and caching options.

See here:

That forum is a good source of help if needed.

1 Like