Featured image of post Windows平台下使用 Rclone 挂载 OneDrive 为本地硬盘

Windows平台下使用 Rclone 挂载 OneDrive 为本地硬盘

Rclone (rsync for cloud storage) 是一个命令行程序,用于同步文件和目录,支持常见的 Amazon Drive 、Google Drive 、OneDrive 、Dropbox 等云存储。本文将演示在 Windows 平台下将 OneDrive 挂载为本地硬盘,并使用跨平台的 Rclone GUI 连接到云盘。

一、环境安装

1、rclone下载

官网下载:https://rclone.org/downloads/ enter description here

Github下载:https://github.com/rclone/rclone/releases enter description here

下载后解压到一个英文路径中 enter description here

2、安装winfsp

官网下载:http://www.secfs.net/winfsp/rel/ enter description here

Github下载:https://github.com/billziss-gh/winfsp/releases enter description here

下载完毕后安装

01 02 03

3、安装Git

官网地址:https://git-scm.com/downloads enter description here

第一步:点击上图中表示的地方进行下载,得到Git-2.17.1.2-64-bit.exe文件。如果你的系统是32位的,可以通过如下方式下载: enter description here 第二步:双击下载好的git安装包,弹出提示框,如下图: enter description here 第三步:直接点击“Next”进入下一步,选择安装路径,如下图: enter description here 第四步:选择好安装路径后,点击“Next”进入下一步,弹出安装配置窗口,包括git命令行、git图形窗口等,如下图所示: enter description here 第五步:按照上述默认配置,直接点击“Next”进入下一步,弹出“选择开始菜单文件夹”的窗口,如下图所示 enter description here 第六步:按照默认路径即可,直接点击“Next”,进入下一步,进入“选择Git使用的默认编辑器”窗口,如下图所示: enter description here 第七步:点击“Next”,进入下一步,进入“调整Path环境变量”窗口,如下图所示: enter description here 第八步:选第二项,然后点击“Next”进入下一步,选择HTTPS传输后端,如下图所示: enter description here 第九步:选择"Use the OpenSSL library",点击“Next”进入下一步,配置行结束符,如下图所示: enter description here 第十步:选择第一项,点击“Next”进入下一步,配置终端模拟器,如下图所示: enter description here 第十一步:选择第一项,直接点击“Next”进入下一步,配置额外选项,如下图所示: enter description here 第十二步:使用默认配置,直接点击“Install”开始安装,如下图所示: enter description here 第十三步:安装完成 enter description here

4、为rclone配置环境变量

  • (1)在电脑桌面右键点击“此电脑”的“属性”选项
  • (2)选择“高级系统设置”选项
  • (3)在系统变量中找到path,添加刚才解压后的路径 enter description here
  • (4)检查rclone是否配置成功 按win+X,然后按A 打开 powershell ,当然也可以去打开 cmd ,输入rclone --version,如果出现下面的输出则安装成功,否则检查上面步骤的环境变量是否配置正确。 enter description here

二、配置挂载

1、rclone配置

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
C:\Users\Administrator>rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n *//第一步:新建配置*
name> e5
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 *//第二步:选择26 Microsoft OneDrive*
** See help for onedrive backend at: https://rclone.org/onedrive/ **

OAuth Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Choose national cloud region for OneDrive.
Enter a string value. Press Enter for the default ("global").
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 *//第三步:选择1 国际版*
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n *//第四步:选择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> y *//第五步:输入y 使用自动配置授权*

*//输入y后会打开默认浏览器 登录Microsoft账号后 选择 是 即可*

If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=bWBcEsbfRHRZIgcZY7Fg_w
Log in and authorize rclone for access
Waiting for code...
Got code
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 onedrive*
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=******************
Chose drive to use:> *0 //第七步:选择0: 账号ID*
Found drive 'root' of type 'business', URL: *******************
Is that okay?
y) Yes (default)
n) No
y/n> y *//第八步:选择y 获取账号root权限*
--------------------
[e5]
type = onedrive
region = global
token = *******
drive_id = *********
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
====                 ====
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 *//第十步:选择q 退出*

C:\Users\Administrator>

C:\Users\你的用户名\.config\rclone文件夹下就可以看见配置文件 rclone.conf 啦。 enter description here

2、挂载OneDrive为本地硬盘

此时请使用 git bash 的终端执行以下命令,因为我使用cmd 和 powershell 都出现关闭终端后挂载程序退出、本地挂载的OneDrive退出的现象。 如果你的windows没有安装git , 请自行安装。若你使用 cmd 的话 ,cmd 是不能退出的,要保持 cmd 不退出本地硬盘才一直挂载着。

在 git bash 中输入以下挂载命令:

1
rclone mount OneDrive_local:/  Q: --cache-dir E:\OneDrive --vfs-cache-mode writes &

其中:

  • OneDrive_loca 替换为你自己前面设置的名称 。
  • Q: 替换为你想要挂载后硬盘的盘符名称即可,记得不要和本地的C盘、D盘等重复。
  • E:\OneDrive 为本地缓存目录,可自行设置 。

出现:The service rclone has been started 则说明挂载成功。

然后输入 exit 退出终端即可。

然后就可以看见本地多了一个盘,往里面复制文件就是上传,从里面复制文件到其它盘就是下载。

3、设置开机自启动挂载

创建一个名称为 startup_rclone.bat 的文件,里面填写上面的挂载命令:

1
rclone mount OneDrive_local:/  Q: --cache-dir E:\OneDrive --vfs-cache-mode writes &

将这个文件放在C:\Users\用户名\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

重启计算机后就会自动挂设置的云盘了,当然这样做由于调用的是 cmd 因此还是不能关闭运行的 cmd。下面介绍一种利用 Rclone GUI 的进行管理的使用方法。

三、可视化上传下载 RcloneBrowser

Github下载地址:https://github.com/kapitainsky/RcloneBrowser/releases

enter description here

下载好后进行安装,然后进行配置。配置 rclone.exe的路径还有 rclone.conf 配置文件的路径。 enter description here enter description here enter description here enter description here enter description here enter description here enter description here 在 Jobs当中还可以查看任务的进度、速度等。 enter description here 另外还可以设置代理,见下图: enter description here

comments powered by Disqus
本博客已稳定运行
发表了77篇文章 · 总计103.35k字