欢迎光临
我们一直在努力

rclone挂载世纪互联(onedrive)

Rclone官方版1.54.0已正式支持世纪互联(含sharepoint)了。

一、获取应用 ID 和密匙

地址:https://portal.azure.cn/,登录完成后按下面步骤进行

1.左侧Azure Active Directory->应用注册->新注册.

2.名称部分:随便写->受支持的账户类型:任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户
—重定向 URI (可选):http://localhost:53682—注册

3.应用程序(客户端) ID

4.获取密匙:左侧证书和密码—
右侧客户端密码部分:+新客户端密码

说明:自己填写—截止日期:2 年内—添加

5.左侧 API 权限—
添加权限—Microsoft Graph—委托的权限— 搜索并勾选下面 6 个权限:

    Files.Read
    Files.Read.All
    Files.ReadWrite
    Files.ReadWrite.All
    offline_access
    User.Read

到这样,就注册结束了!用记事本记录一下 ID 和密匙(后面用到)

二、rclone配置世纪互联

1、简介

目前最新版本是1.54.0,已经正常支持世纪互联(含sharepoint)!

官网:https://rclone.org/

项目:https://github.com/rclone/rclone

下载:https://github.com/rclone/rclone/releases

2、windonws10安装rclone

1)Windows客户端:rclone-v1.54.0-windows-amd64.zip

2)下载后将其解压,并将rclone.exe移动到C:\Windows\System32这个目录,这样就可以使用rclone命令了

3)在cmd窗口继续输入命令rclone config进行配置,输入n新建一个远程,并取一个名字,比如od

4)输入名称后,找到OneDrive,目前最新版1.54.0,od序号是26,不是固定的,会随着版本号改变。

5)下面就需要输入Client Secret和Client Id

应用程序(客户端) ID(client_id

客户端密码部分:值(client_secret

6)选择世纪互联和其他一堆操作。

我们看到序号4,是世纪互联,其他就跟着教程走。这里就不细说了。

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> 4  #选择4
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n  #这里选择n
Remote config
Make sure your Redirect URL is set to "http://localhost:53682/" in your custom 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> y #选择y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=A_tjjKrdfKTLdPftq9phRw
Log in and authorize rclone for access
Waiting for code...
Got code

7)这之后,会进入登录页面,输入你的账号和密码登录即可,会自动获得token,如果打不开可以把前面的网址换为:https://login.chinacloudapi.cn/common,后面的都不要动。之后的操作如下:

Choose 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  #这里选择1,od和sharepoint都是支持的,自己根据需要选择
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!5sR5nrtytytytytytytyVITcXXmJQaF8EznkrHDU
Chose drive to use:> 0  #选择0
Found drive 'root' of type 'business', URL: https://universitytongji-my.sharepoint.cn/personal/suoquhao_alumni_tongji_edu_cn/Documents
Is that okay?
y) Yes (default)
n) No
y/n> y  #选择y

8)之后会出现token等配置,会自动生产配置文件,这里配置好,就算是结束了,下面的工作就是挂载,具体如下:

--------------------
[od]
type = onedrive
client_id = a58cc5
client_secret = YQ
region = cn
token = {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IjhrZ19JdUR0XzNzaklJanVlb052cFozVjlqWGp5czhRbE03Ym9WYmtkSE0iLCJ0VuE-hIAA","expiry":"2021-02-04T17:41:16.475507+08:00"}
drive_id = b!5sR5nWktPUG
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y  #选择y
Current remotes:
 
Name                 Type
====                 ====
od                   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退出配置

三、rclone挂载世纪互联

1、windows挂载之前需要下载Winfsp,没有这玩意挂载会出错。

Winfsp下载:https://github.com/billziss-gh/winfsp/releases

下载之后直接安装即可,无需修改安装位置,一路按默认的点下去就可。

打开cmd,输入如下挂载命令。

rclone mount od:/ F: --cache-dir D:\Temp\OneDrive --vfs-cache-mode writes

挂载成功如下:

C:\Users\ddd>rclone mount od:/ F: --cache-dir D:\Temp\OneDrive --vfs-cache-mode writes
The service rclone has been started.

2、Linux挂载

mkdir /mnt/od
rclone mount od: /mnt/od --allow-other --allow-non-empty &

如果在挂载的时候出现了类似下面的提示:failed to mount FUSE fs

需要安装 fuse。

CentOS/Fedora 安装 fuse:

yum install -y fuse 

Ubuntu/Debian 安装 fuse:

apt install -y fuse

四、开机自动挂载

到这里还没结束,电脑重启后磁盘会消失,下面看看怎么解决。

windows系统新建两个文件,分别为rclone.bat和rclone.vbs

1)rclone.bat中写入上述挂载命令:

rclone mount od:/ F: --cache-dir D:\Temp\OneDrive --vfs-cache-mode writes

2)rclone.vbs设置开机自动调用cmd运行rclone.bat文件并退出cmd,写入如下代码:

CreateObject("WScript.Shell").Run "cmd /c D:/rclone.bat",0

3)将rclone.bat文件放到D盘(或其他的盘)目录下,我放在了D盘,所以在rclone.vbs中该文件的路径就是D:/rclone.bat

4)将rclone.vbs文件放到windows系统启动项目录下,在文件夹的路径框中输入如下代码:即可进入启动项目录

%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

至此,onedrive磁盘的挂载完成,且电脑下次开机时onedrive磁盘也不会消失,同理sharepoint同样的挂载方法。

Linux系统先新建systemd配置文件,适用CentOS 7Debian 8+Ubuntu 16+

#以下是一整条命令,一起复制到SSH客户端运行
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target

[Service]
Type=simple
ExecStart=$(command -v rclone) mount od: /mnt/od --allow-other --allow-non-empty
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

5、最后

挂载后,访问速度不是太快,个人感觉没有微软官方提供的OneDrive程序打开的速度快。配置也很麻烦,其实完全可以用微软官方提供的OneDrive程序来部署。

 收藏 (0) 打赏

您可以选择一种方式赞助本站

支付宝扫一扫赞助

微信钱包扫描赞助

未经允许不得转载:家里蹲的狐狸 » rclone挂载世纪互联(onedrive)

分享到: 生成海报
avatar

热门文章

  • 评论 3

    • QQ号
    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址
    1. #1
      avatar

      Linux挂载就不做介绍了,然后标题是Linux下如何挂载?

      天使泪King3年前 (2021-02-27)国内网友谷歌浏览器  MI 9 Transparent Edition) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.116 Mobile Safari/537.36 EdgA/46.01.4.5140 回复
      • avatar

        哈哈,没注意。。不好意思,没想到会有人看。。。本意是自己记录下怕以后自己会忘记。。我再补充下

        hqhyco3年前 (2021-02-27)国内网友谷歌浏览器 Windows 10 回复
    2. #2
      avatar

      现在我的世纪互联和商业版都挂载不了,正好看看

      hy3年前 (2021-09-09)Taiwan; Republic of China (ROC)谷歌浏览器 Windows 10 回复

    登录

    忘记密码 ?

    切换登录

    注册

    我们将发送一封验证邮件至你的邮箱, 请正确填写以完成账号注册和激活