1.获取OneDrive 授权Token
下载Reclone
访问 https://rclone.org/downloads/ 下载对应版本的Rclone 并且将文件解压出来
下载完成后解压,进入存放 Rclone 的目录,以 Win11 为例,打开cmd 我的 Rclone文件放在 C:Usersduan2DesktopDJHrclone-v1.59.2 我可以输入:
cd C:\Users\duan2\Desktop\DJH\rclone-v1.59.2
然后执行
rclone.exe authorize "onedrive"
会弹出浏览器 登录Onedrive账户
之后会cmd会出现Token内容,复制该内容(中括号也要复制到)
2.Linux安装&配置Rclone
使用脚本下载安装 Rclone:
curl https://rclone.org/install.sh | sudo bash
配置Rclone
安装完成后输入:
rclone config
可以看到
2022/11/08 07:14:46 NOTICE: Config file "/root/.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(新建配置)
name 可以随便输入(我这里输入的名字是OneDrive01)
然后可以看到
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, 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 / Mega
"mega"
22 / Microsoft Azure Blob Storage
"azureblob"
23 / Microsoft OneDrive
"onedrive"
24 / OpenDrive
"opendrive"
25 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
"swift"
26 / Pcloud
"pcloud"
27 / Put.io
"putio"
28 / QingCloud Object Storage
"qingstor"
29 / SSH/SFTP Connection
"sftp"
30 / Sugarsync
"sugarsync"
31 / Transparently chunk/split large files
"chunker"
32 / Union merges the contents of several remotes
"union"
33 / Webdav
"webdav"
34 / Yandex Disk
"yandex"
35 / http Connection
"http"
36 / premiumize.me
"premiumizeme"
Storage>
直接输入序号
比如我挂载的是OneDrive就输入 23
client_id 可以直接回车默认
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>
输入n
会出现
For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine (same rclone version recommended) :
rclone authorize "onedrive"
Then paste the result below:
result>
粘贴第一步复制的Token内容
会出现
输入1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!Hu_exFnBoUqhLs7wz618RxDT-rHyWbdOtwaAsaiXTluoL0_AJZyITbOXcfXW4rcQ
Chose drive to use:>
输入0
Found drive 'root' of type 'business', URL: https://atgfwacnz-my.sharepoint.com/personal/ondrive20221107_365vip_eu_org/Documents
Is that okay?
y) Yes (default)
n) No
y/n>
输入y
drive_type = business
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>
输入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>
最后输入q退出
3.挂载OneDrive
首先新建一个文件夹用于挂载:
mkdir /OneDrive01
开始挂载(其中OneDrive01是rclone配置时输入的配置名称,/OneDrive01是挂载目录,–daemon是指后台运行。)
rclone mount OneDrive01: /OneDrive01 --allow-other --allow-non-empty --vfs-cache-mode writes --daemon
此时可能会报错:
Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
这是因为缺少依赖,我们选择安装
centos系使用:
yum install -y fuse
debian系使用:
apt install -y fuse
再次执行挂载命令,如果没有报错,就是挂载成功了。
检查挂载:
df -h
可以看到我们挂载的OneDrive
4.如何删除这个挂载盘
使用umount命令
umount /OneDrive01