[最新]在CentOS/Debian/Ubuntu上使用rclone挂载OneDrive网盘

本教程只适用Debian/Ubuntu系统,如果你是CentOS或者其它Linux系统,请使用以下命令安装rclone

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

在本地Windows电脑上下载rclone,下载地址:https://rclone.org/downloads/。然后解压出来,比如我解压到C:\Windows\System32,然后按组合键Win R,输入cmd,回车键确定。再输入以下命令:

rclone authorize "onedrive"

会出现以下信息:

会出现以下信息:

d:\rclone>rclone authorize "onedrive"
2018/01/23 20:28:56 NOTICE: Config file "C:\\Users\\Administrator\\.config\\rclo
ne\\rclone.conf" not found - using defaults
Choose OneDrive account type?
 * Say b for a OneDrive business account
 * Say p for a personal OneDrive account
b) Business
p) Personal
b/p> p  #这里选择个人版,你想挂载Business就选择b
If your browser doesn\'t open automatically go to the following link: http://127.
0.0.1:53682/auth  #接下来会弹出浏览器,要求你登录账号进行授权
Log in and authorize rclone for access
Waiting for code...
Got code
Paste the following into your remote machine --->
{"access_token":"xxxxxxxxxxx"}  #请复制{xxxxxx}整个内容,后面需要用到
<---End paste

(附1):我们这里可以直接将Windows上的rclone配置文件直接上传到VPS中

在Windows命令行中输入 rclone -h ,找到有关config的内容,能找到rclone配置文件默认存放的位置C:\Users\用户名\.config\rclone

在VPS上,输入 rclone -h,找到rclone配置文件默认存放位置(一般配置文件存放位置/root/.config/rclone/rclone.conf”)

然后将Windows rclone配置文件里的内容都复制到VPS上rclone配置文件中,如果没有这个配置文件,可以新建一个,名称那些一定要对应其默认值,并且保存。

在VPS上输入 rclone config,不出意外能正常读取到你Windows rclone配置文件的内容

 

安装rclone

本教程只适用Debian/Ubuntu系统,如果你是CentOS,请参考:https://rclone.org/install/,安装rclone。挂载方法和下面差不多。

1、安装rclone

wget http://www.vipkj.net/soft/Linux/rclone_debian.sh && bash rclone_debian.sh

2、初始化配置

rclone config

会出现以下信息:

n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> Rats  #随便填,后面要用到
Type of storage to configure.
Choose a number from below, or type in your own value
 1 / Amazon Drive
   \ "amazon cloud drive"
 2 / Amazon S3 (also Dreamhost, Ceph, Minio)
   \ "s3"
 3 / Backblaze B2
   \ "b2"
 4 / Box
   \ "box"
 5 / Cache a remote
   \ "cache"
 6 / Dropbox
   \ "dropbox"
 7 / Encrypt/Decrypt a remote
   \ "crypt"
 8 / FTP Connection
   \ "ftp"
 9 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
10 / Google Drive
   \ "drive"
11 / Hubic
   \ "hubic"
12 / Local Disk
   \ "local"
13 / Microsoft Azure Blob Storage
   \ "azureblob"
14 / Microsoft OneDrive
   \ "onedrive"
15 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
16 / Pcloud
   \ "pcloud"
17 / QingCloud Object Storage
   \ "qingstor"
18 / SSH/SFTP Connection
   \ "sftp"
19 / Webdav
   \ "webdav"
20 / Yandex Disk
   \ "yandex"
21 / http Connection
   \ "http"
Storage> 14  #选择14,Microsoft OneDrive
Microsoft App Client Id - leave blank normally.
client_id>  #留空 
Microsoft App Client Secret - leave blank normally.
client_secret>  #留空 
Remote config
Choose OneDrive account type?
 * Say b for a OneDrive business account
 * Say p for a personal OneDrive account
b) Business
p) Personal
b/p> p  #这里选择个人版,你想挂载Business就选择b
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  #选择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:
    rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":""}  #输入之前在客户端授权的内容
--------------------
[Rats]
client_id = 
client_secret = 
token = {"access_token":""}
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y  选择y
Current remotes:

Name                 Type
====                 ====
Rats                 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  #选择q退出

挂载

1、挂载为磁盘

#新建本地文件夹,路径自己定,即下面的LocalFolder
mkdir /root/OneDrive
#挂载为磁盘
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

DriveName为初始化配置填的nameFolderOneDrive里的文件夹,LocalFolderVPS上的本地文件夹。

如果挂载过程中出现NOTICE: One drive root \'test\': poll-interval is not supported by this remote错误,可以无视该错误。

挂载成功后,输入df -h命令查看即可!

请输入图片描述

请输入图片描述

2、卸载磁盘

fusermount -qzu LocalFolder

自启动

1、下载并编辑脚本
使用命令:

wget  && nano rcloned

修改一下内容:

NAME=""  #rclone name名,及配置时输入的Name
REMOTE=\'\'  #远程文件夹,OneDrive网盘里的挂载的一个文件夹
LOCAL=\'\'  #挂载地址,VPS本地挂载目录

2、设置自启
使用命令:

#Debian系统
apt-get install sudo -y

#设置自启
mv rcloned /etc/init.d/rcloned
chmod  x /etc/init.d/rcloned
update-rc.d -f rcloned defaults
bash /etc/init.d/rcloned start

检测信息显示rclone启动成功即可。

请输入图片描述

请输入图片描述

最后我们就可以利用OneDrive for BusinessLinux VPS增加5TB的空间了。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情图片

    暂无评论内容