CentOS7使用rclone挂载OneDrive网盘

CentOS7使用rclone挂载OneDrive网盘

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

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

往期相关文章:

免费获取OneDrive 5T网盘

利用OneDrive搭建分享网盘

将OneDrive网盘挂载到电脑当磁盘使用

自建BT下载一键搭建Aria2+Aria2Ng+OneIndex

以下是爱游服务器的配置

服务器配置:

CPU:1核

内存:1GB

硬盘:20GB

系统:centos 7.6

类型:KVM

注意:服务器最好是KVM的,OpenVZ需要给你的服务商发TK告诉他们开一下FUSE,如果没有FUSE是没办法挂载的。

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

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

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

使用CMD打开运行以下命令

cd /d d:\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

输入命令后

2019/08/02 10:55:49 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/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 / A stackable unification remote, which can appear to merge the contents of several remotes
   \ "union"
 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 / Dropbox
   \ "dropbox"
 9 / Encrypt/Decrypt a remote
   \ "crypt"
10 / FTP Connection
   \ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Hubic
   \ "hubic"
14 / JottaCloud
   \ "jottacloud"
15 / Koofr
   \ "koofr"
16 / Local Disk
   \ "local"
17 / Mega
   \ "mega"
18 / Microsoft Azure Blob Storage
   \ "azureblob"
19 / Microsoft OneDrive
   \ "onedrive"
20 / OpenDrive
   \ "opendrive"
21 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
22 / Pcloud
   \ "pcloud"
23 / QingCloud Object Storage
   \ "qingstor"
24 / SSH/SFTP Connection
   \ "sftp"
25 / Webdav
   \ "webdav"
26 / Yandex Disk
   \ "yandex"
27 / http Connection
   \ "http"
Storage> 19

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

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

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> 
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>

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

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

是否使用自动设置,同样直接NO,选择n

Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
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个人版或是商业版

Choose a number from below, or type in an existing value
 1 / OneDrive Personal or Business
   \ "onedrive"
 2 / Root Sharepoint site
   \ "sharepoint"
 3 / Type in driveID
   \ "driveid"
 4 / Type in SiteID
   \ "siteid"
 5 / Search a Sharepoint site
   \ "search"
Your choice> 1

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

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

输入前面的序号就行

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

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

然后确认

y) Yes this is OK
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>

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

挂载

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

mkdir /home/onedrive

挂载为磁盘的命令如下

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 --allow-other --allow-non-empty --vfs-cache-mode writes

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

不出问题的情况下,输入

df -h

就可以看到Onedrive成功挂载。

以上就是在centos使用rclone挂载OneDrive网盘,如有疑问可以留言给我。

原文链接:https://www.vipiu.net/archives/2019/08/02/2172.html,转载请注明出处。
0

评论3

请先

  1. 在安装curl https://rclone.org/install.sh | sudo bash的时候卡住不动很久了 这个是怎么回事啊 腾讯云的服务器
    HuRan 2022-01-22 0
    • 你是什么系统的,建议使用debian
      爱游博客 2022-01-25 0
会员低至49元,开通享海量VIP资源免费下载 自助开通
显示验证码
没有账号?注册  忘记密码?