说明:之前发了个Google Drive
网盘挂载教程,参考:在Debian/Ubuntu上使用rclone挂载Google Drive网盘,然后博主想用同样的方法试试挂载OneDrive
网盘,可是卡在了授权那里,然后只有请求Vicer
大佬帮忙解决了,这里分享下挂载教程。
提示:本教程挂载OneDrive for Business
和个人版的方法都一样,这里以个人版为参考。
说明
本教程只适用Debian
/Ubuntu
系统,如果你是CentOS
或者其它Linux
系统,请使用以下命令安装rclone
:
curl https://rclone.org/install.sh | sudo bash
客户端授权、初始化配置和挂载方法和下面一样,开机自启可参考该教程→传送门。
客户端授权
在本地Windows
电脑上下载rclone
,下载地址:https://rclone.org/downloads/。然后解压出来,比如我解压到D
盘,文件夹命名rclone
,此时点击Win+R
,然后输入cmd
,确定。再输入以下命令:
cd /d d:\rclone
rclone authorize "onedrive"
会出现以下信息:
C:\Users\Administrator>cd /d d:\rclone
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":"xxxx"} #请复制{xx}整个内容,后面需要用到
<---End paste
安装rclone
本教程只适用Debian
/Ubuntu
系统,如果你是CentOS
,请参考:https://rclone.org/install/,安装rclone
。挂载方法和下面差不多。
1、安装rclone
wget https://www.moerats.com/usr/shell/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
#挂载为磁盘,下面的DriveName、Folder、LocalFolder参数根据说明自行替换
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
DriveName
为初始化配置填的name
,Folder
为OneDrive
里的文件夹,LocalFolder
为VPS
上的本地文件夹。
如果挂载过程中出现NOTICE: One drive root 'test': poll-interval is not supported by this remote
错误,可以无视该错误。
挂载成功后,输入df -h
命令查看即可!
2、卸载磁盘
fusermount -qzu LocalFolder
开机自启
先新建systemd
配置文件,适用CentOS 7
、Debian 8+
、Ubuntu 16+
。
再使用命令:
#将后面修改成你上面手动运行命令中,除了rclone的全部参数
command="mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000"
#以下是一整条命令,一起复制到SSH客户端运行
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
开始启动:
systemctl start rclone
设置开机自启:
systemctl enable rclone
其他命令:
重启:systemctl restart rclone
停止:systemctl stop rclone
状态:systemctl status rclone
如果你想挂载多个网盘,那么将systemd
配置文件的rclone.service
改成rclone1.service
即可,重启动什么的同样换成rclone1
。
试了无数次都出错!!!蒙了
Your choice> 1
2019/03/17 14:33:43 Failed to query available drives: HTTP error 429 (429 ) returned body: "{rn "error": {rn "code": "activityLimitReached",rn "message": "The request has been throttled",rn "innerError": {rn "request-id": "3dfea95c-a4ff-4c4d-acde-2d7183c6195b",rn "date": "2019-03-17T14:33:43"rn }rn }rn}"
貌似提示你被限制了
我也显示这个了:Failed to query available drives: HTTP error 429 (429 ) returned body 是不是rclone被限制了?
再挂一次看看,或者换个账号
大佬求救,前几天挂在成功了今天突然出现这个,是咋回事啊?求救
2019/02/21 01:05:23 Failed to query available drives: HTTP error 429 (429 ) returned body: "{rn "error": {rn "code": "activityLimitReached",rn "message": "The request has been throttled",rn "innerError": {rn "request-id": "ee6dd622-3cd5-44a8-8a55-b6b6bc725b76",rn "date": "2019-02-20T17:05:20"rn }rn }rn}"
看错误好像是被限制了
04:54:35 Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
挂载的时候出现这个怎么办? 大佬
root@debian:~# /usr/bin/rclone mount onedrive:CC /root/OneDrive \
--umask 0000 \
--default-permissions \
--allow-non-empty \
--allow-other \
--buffer-size 32M \
--dir-cache-time 12h \
--vfs-read-chunk-size 64M \
--vfs-read-chunk-size-limit 1G
2019/02/15 05:01:46 Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
安装fuse看看,命令:
Debian/Ubuntuapt-get install fuse
CentOSyum install fuse
可以,谢谢大佬
大佬好,又有问题请教您,按照您的教程,我一共配置了两个OneDrive,想让它们都可以重启自动挂载,要怎么操作?你的这个自启挂载脚本要怎么修改才能支持?
这个不好说,你可以直接复制个同样的自启脚本,改成其他名称,然后里面照着填。
手动测试可行,不过运行第二个的时候会提示rclone已在运行中!,不过也可以把第二个挂载上
请教一下,我是centos7,已经按教程挂载一个Mega网盘,rcloned文件重命名为Mega。在挂载第二个网盘onedrive时,rclone mount能挂载成功,但是复制rcloned文件并重命名为sdd1后,使用chkconfig sdd1 on,显示rclone正在运行,chkconfig --list能看到sdd1在运行,但是df -h没有sdd1,宝塔里也看不到这个磁盘
我把开机自启方法改了,你再看看
能挂上的话,要是都没问题就行了。
老大这个脚本更新了,咋玩啊,小白求教
哪里更新了,你是说配置过程变了么?
最后输入token配置时显示
OEf2JSXKZs5aqlOug00__igXUMNJwcmAez6BoB5vPaIdWe6Y_fxKWaKLzHBNXnD8iXRG5WUhnwUenwn03yxuuV0Fc2BApylvpAZaUGHXrrOCYavQ_nYN9S_uCXdJjBXvkh3T6CG6knEvjyupxEC1d-t1ftB89FUeRoXT9k-JiwxiOxpP9aYgAA","expiry":"2019-01-31T04:57:14.6898148+08:00"}
2019/01/31 04:22:24 ERROR : Failed to save new token in config file: section 'one' not found
挂载磁盘显示
2019/01/31 04:25:16 Failed to create file system for "one:ccc": failed to get root: unauthenticated: Must be authenticated to use '/drive' syntax
不知道哪里错了请教大佬
配置的时候,好像说你的token不对,导致挂不上
谢谢大佬已经解决了.这个原因是因为客户端是最新版.服务器是旧版的rcloned 可能是token不兼容吧
U0ODMzNTcwMCwibmJmIjoxNTQ4MzM1NzAwLCJleHAiOjE1NDgzMzk2MDAsImFjciI6IjEiLCJhaW8iOi
-bash: U0ODMzNTcwMCwibmJmIjoxNTQ4MzM1NzAwLCJleHAiOjE1NDgzMzk2MDAsImFjciI6IjEiLCJhaW8iOi: command not found
就是输入token就这样
配置的时候输的?注意下不要包含空格
为什么我输入完token会出现
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就好了,有时候配置可能会有轻微变化。
U0ODMzNTcwMCwibmJmIjoxNTQ4MzM1NzAwLCJleHAiOjE1NDgzMzk2MDAsImFjciI6IjEiLCJhaW8iOi
-bash: U0ODMzNTcwMCwibmJmIjoxNTQ4MzM1NzAwLCJleHAiOjE1NDgzMzk2MDAsImFjciI6IjEiLCJhaW8iOi: command not found
这样是为什么啊?请问!
Access token has expired。每次获取的token有效期都只有1小时。这个怎么办。。
这个不是很清楚。
一般获取的token过期时间有多久。。
我之前没搞懂你的意思,你要token有效期变长干啥?
我每次在PC上获取的那一串,也就是token。挂上VPS以后。一个小时就报错了。提示Access token has expired。然后我看了一下每次获取token里面的参数有效期都是1个小时。。或者说我的操作有哪一步不对么。我试了3次。每次一开始都能挂载成功。然后1个小时就报错退出了。
这个问题我还真没遇到过,不知道你换个账号会不会好些?