What to do if the VPS space is too small? Why not use rclone to mount the OD drive locally, isn't that great?#
1. Obtain token (locally)#
1) Windows 10 method#
- Click here to download the token tool
- Unzip and enter the directory where rclone.exe is located
- Shift + right-click and select Open PowerShell here
![Snipaste_2021-08-20_21-04-44.png][1]
[1]: https://z-r.cc/usr/uploads/2021/08/3425953120.png - Enter
./rclone.exe authorize "onedrive"
Then follow the prompts
5. Copy the returned
From {"access_token":
Copy to
"expiry":"your time"}
And save it to a text file for later use
2) Windows 7 method#
- Click here to download the token tool
- Unzip and enter the directory where rclone.exe is located
- Copy rclone.exe to C:\Windows\System32
- Enter
rclone authorize "onedrive"
```shell
Then follow the prompts
5. Copy the returned
From {"access_token":
Copy to
"expiry":"your time"}
And save it to a text file for later use
***
## 2. Installation (on VPS)
1. Install rclone
```shell
wget https://z-r.cc/rclone_ubuntu.sh && bash rclone_ubuntu.sh
- Configure initialization
rclone config
Then the following information will appear
n) New remote
s) Set configuration password
q) Quit config
n/s/q>
Input: n
Then it will show
name>
You can enter anything here, let's use yourname as a placeholder
Then
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 Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, and Tencent COS
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Citrix Sharefile
\ "sharefile"
9 / Compress a remote
\ "compress"
10 / Dropbox
\ "dropbox"
11 / Encrypt/Decrypt a remote
\ "crypt"
12 / Enterprise File Fabric
\ "filefabric"
13 / FTP Connection
\ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
15 / Google Drive
\ "drive"
16 / Google Photos
\ "google photos"
17 / Hadoop distributed file system
\ "hdfs"
18 / Hubic
\ "hubic"
19 / In memory object storage system.
\ "memory"
20 / Jottacloud
\ "jottacloud"
21 / Koofr
\ "koofr"
22 / Local Disk
\ "local"
23 / Mail.ru Cloud
\ "mailru"
24 / Mega
\ "mega"
25 / Microsoft Azure Blob Storage
\ "azureblob"
26 / Microsoft OneDrive
\ "onedrive"
27 / OpenDrive
\ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
29 / Pcloud
\ "pcloud"
30 / Put.io
\ "putio"
31 / QingCloud Object Storage
\ "qingstor"
32 / SSH/SFTP Connection
\ "sftp"
33 / Sugarsync
\ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
35 / Transparently chunk/split large files
\ "chunker"
36 / Union merges the contents of several upstream fs
\ "union"
37 / Webdav
\ "webdav"
38 / Yandex Disk
\ "yandex"
39 / Zoho
\ "zoho"
40 / http Connection
\ "http"
41 / premiumize.me
\ "premiumizeme"
42 / seafile
\ "seafile"
Storage>
Here find Microsoft OneDrive
Input: 26 (based on your actual situation)
** 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>
Just press Enter
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Just press Enter
Choose national cloud region for OneDrive.
Enter a string value. Press Enter for the default ("global").
Choose a number from below, or type in your own value
1 / Microsoft Cloud Global
\ "global"
2 / Microsoft Cloud for US Government
\ "us"
3 / Microsoft Cloud Germany
\ "de"
4 / Azure and Office 365 operated by 21Vianet in China
\ "cn"
region>
Choose based on your actual situation
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n>
Input: 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>
Input: n
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "onedrive"
Then paste the result below:
result>
Here paste the token obtained earlier
Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
\ "url"
4 / Search for a Sharepoint site
\ "search"
5 / Type in driveID (advanced)
\ "driveid"
6 / Type in SiteID (advanced)
\ "siteid"
7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
\ "path"
Your choice>
Choose based on your situation
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=****
Chose drive to use:> 0
Found drive 'root' of type 'business', URL: ****
Is that okay?
y) Yes (default)
n) No
y/n>
Input: y
[onedrive]
type = onedrive
region = global
token = {"access_token":"***:"2021-05-12T21:26:23.034940078-04:00"}
drive_id = b!HZQ8fVjEAkirFu8ARagwdQSJ8f6tKihCnEfvBcs_KuyXtvHlOzf1SJDUs8WRpgXq
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>
Input: y
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>
Press q to exit
3. Mount as a disk#
mkdir /root/OneDrive # Create a new local folder, path is up to you, i.e., the LocalFolder below
rclone mount yourname:/ LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --vfs-cache-mode writes # yourname is the name filled in during initialization, / is the root directory in OneDrive, it can be other values, LocalFolder is the local folder on the VPS.
If the following error appears
NOTICE: One drive root 'test': poll-interval is not supported by this remote
Please ignore it
After successful mounting, disconnect directly. Reconnect and enter the df -h command to check
4. Unmount the disk (if needed)#
fusermount -qzu LocalFolder
5. Set to start on boot#
- Create rclone.service file:
command="mount yourname:/ LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --vfs-cache-mode writes"
- Write in
# The following is a complete command, copy it all to the SSH client to run
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target
[Service]
Type=simple
ExecStart=$(command -v rclone) ${command}
Restart=on-abort
User=root
[Install]
WantedBy=default.target
EOF
Note: ExecStart is the command you entered in the previous step
3. Reload the daemon to make the new service file effective:
systemctl daemon-reload
- Start:
systemctl start rclone
systemctl enable rclone
- Other commands:
Restart: systemctl restart rclone
Stop: systemctl stop rclone
Status: systemctl status rclone
Article link: https://z-r.cc/2021/08/20/%E5%9C%A8Ubuntu%E4%B8%8A%E4%BD%BF%E7%94%A8rclone%E6%8C%82%E8%BD%BDOneDrive%E7%BD%91%E7%9B%98.html
Please indicate the source when reprinting!