CentOS7使用rclone挂载OneDrive网盘

Rclone是一个多平台可以挂载OneDrive/Google Drive/Amazon Drive等云存储的软件,平台可以在Windows、Mac OS、Linux上进行使用。这篇文章主要分享CentOS7使用Rclone挂载OneDrive的过程,其它系统或者挂载其它网盘原理和方法大致相同。

首先我们需要先获取到onedrive的access_token

获取方式:先到https://rclone.org/downloads/下载win版本的Rclone

下载后解压,把文件夹更名为rclone

使用CMD打开运行以下命令


C:\Users882>cd D:\Program Files\rclone

C:\Users882>D:

D:\Program Files\rclone>rclone authorize "onedrive"
运行后会自动打开浏览器,然后登录帐号,登录后会跳转到授权成功的页面。
授权成功后回到CMD窗口,会看到如下:

把{}括号里面的内容复制下来保存好,后面需要用到(包含括号一起复制保存

到这里我们都win下面就操作完了,现在需要到服务器去操作下。

准备

先安装一下基本组件

yum -y install wget unzip screen fuse fuse-devel

使用官方的一键安装命令即可,输入下面的命令:

curl https://rclone.org/install.sh | sudo bash

安装完成后会提示

rclone v1.48.0 has successfully installed.
Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.

这样我们就可以直接使用rclone config命令在设置

配置

接着就输入以下命令进行rclone设置

rclone config

输入命令后

[[email protected] ~]# rclone config
Current remotes:

Name                 Type
====                 ====
onedrive             onedrive

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> n

这里我们选择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 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> 26

我们今天主要是挂在onedrive,所以这里选择26,根据实际来选择,rclone版本不一样选择也不一样。

下面就是client_id>和client_secret> ,这两项直接回车,不管

这里选择1默认就好

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> 1

是否配置高级设置,这里我们直接No,选择n

Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n

是否使用自动设置,同样直接NO,选择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

这一步就需要用到我们刚才在win获取到的access_token

For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine:
	rclone authorize "onedrive"
Then paste the result below:
result>

按照图片格式把获取到的access_token粘贴进去

这里选择1,onedrive个人版或是商业版

3Choose 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> 1

然后会提示找到一个驱动器

Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!W-sxPWSRIUuTGYQQIuTK37gJTrXNfmJLghYN8U_emTz_ULq0nlB4Rr1bDtiPPzvP
Chose drive to use:> 0

输入前面的序号就行

下面直接yes,大概的意思是找到这个驱动器,不知道对不对

Found drive 'root' of type 'business', URL: https://axzm-my.sharepoint.com/personal/jaco_axzm_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
y/n> y

然后确认

--------------------
[onedrive_e5]
type = onedrive
region = global
token = {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6ImRQX3NkV3JhVVJ1ZTd0b3BQS0N3bU40NW1oVS1NaXZQZFZxZmtTMkxOTGsiLCJhbGciOiJSUzI1NiIsIng1dCI6Imwzc1EtNTBjQ0g0eEJWWkxIVEd3blNSNzY4MCIsImtpZCI6Imwzc1EtNTBjQ0g0eEJWWkxIVEd3blNSNzY4MCJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53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M5h5KTIOzCX---S7QD8TJWWEAtUO1EgpqR6E_Y9YNOLSG6JLDeae8OaFKRcEU8PzfaA9Uj8q_1ufQu7pYZwXP8yE0dgrqmTjIQJwJ35PotJPtZ8d9gmesCyZAcVfVjvbKVcaX63oTwPCv4XNFiSeaxbwlaE26f4ucvW_ZUMwS-ZtcUXPu7FQMTEnweoM3SqqR1I_xZqcoFHDQ4VIB7dkbr_G3D-qBAIBYusNKaq5h968od3BRBfHCMlV3mJWEXsGXzFe_0KbdKcWEEC3J00WKTaAVRs3wxPEfV_91EjjAfkW0DAFwhJMrLJhhXzlaMTTd_8BNdqQmDEexczY-Q5Fh6ayTsSBuPQKrSfebWgBH0ecBibnHiYNXyzX5bCcoP-bn9TLyhD3TqQgKCKvjWw2gvcaNVk6_0pcLsETUdK6H-AhxrRZF_WHFhFVEPBWzRD3cwKIol0nBkrgmvQMo43QJX2tzCpozknab0L86kOBQmfsIuobCDSfvFZJfrRhxnOS7clreL2MayApAJwoN5OjRmjWbxbUsfl5FLsTWdlP6YHJQ6tJlzCtLazQGSihVU4XrzRhrIXzWE6bjbuKbBiAwl6GQPSAmzUsm3zdj2BuTFNuB0v3GYAiXvBDgkxWg5w5-NJDH19IAhKlA4l0dDWM4BZ9ORxyUTTRFTONrHbtNgCa0kAmjqPvjkVUU6qjfiAfdx0GBtIpfmBHPc2KvwGbrRKUB6PDps_lF_zXFEBIoJdRDdlrIxLNc1y9GG57aTXGT26e4Zekrt6HvHsQn5iLh0FcDrfgW_8_fS1olzqkdUCdBxLgsprj11FBcIjx-nvNZmsubqndkohNqhnrpvvuCdWgZaf5u8IxQMq9a-oOj-0t_CBNldpESlM6CJ2MzEa3TX2kGMRDc8Aw","expiry":"2021-10-29T14:10:27.3090854+08:00"}
drive_id = b!W-sxPWSRIUuTGYQQIuTK37gJTrXNfmJLghYN8U_emTz_ULq0nlB4Rr1bDtiPPzvP
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

然后退出配置 q

Current remotes:

Name                 Type
====                 ====
onedrive             onedrive  这是我以前挂载的
onedrive_e5          onedrive  这个是这次挂载的

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

以上就配置好了,剩下的就是挂载了

挂载

首先创建一个本地文件夹,我创建的是/home/onedrive_e5 ,路径可以你自己定, 也就是下面的LocalFolder

mkdir /home/onedrive_e5

挂载为磁盘的命令如下

rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate
--allow-other --allow-non-empty --umask 000

如果你和我一样设置的挂载命令是:

rclone mount onedrive: /home/onedrive_e5 --allow-other --allow-non-empty --vfs-cache-mode writes

在运行挂载命令后,SSH窗口会出现中断,光标丢失,此时关掉窗口即可。如需另外再挂载网盘,只需要重新连接。

不出问题的情况下,输入

df -h

版权声明:
作者:即小兴
链接:https://blog.a-my.top/748.html
来源:即小兴
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>