Windows下用rclone挂载OneDrive为本地硬盘

1、rclone下载地址

官方文档:https://rclone.org/docs/

官网下载:https://rclone.org/downloads/

null

GitHub下载:https://github.com/ncw/rclone/releases/tag/v1.45

null

下载完成后在解压到你喜欢的文件夹下,例如我的:

null

另外Windows使用rclone还需要另一个依赖工具winfsp,下载地址:http://www.secfs.net/winfsp/download/

2、配置环境变量

把刚才解压到的文件路径新加到Path,比喻我的C:\Software\Tools\rclone-v1.45-windows-amd64

null

3、检查rclone是否配置成功

win+X,然后按A,输入rclone --version,如果出现下面的输出则安装成功,否则重复上面步骤。

null

4、开始配置rclone

C:\WINDOWS\system32>rclone config
2018/12/14 18:07:53 NOTICE: Config file "C:\\Users\\Alien\\.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
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 a existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)
   \ "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 / Local Disk
   \ "local"
16 / Mega
   \ "mega"
17 / Microsoft Azure Blob Storage
   \ "azureblob"
18 / Microsoft OneDrive
   \ "onedrive"
19 / OpenDrive
   \ "opendrive"
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
21 / Pcloud
   \ "pcloud"
22 / QingCloud Object Storage
   \ "qingstor"
23 / SSH/SFTP Connection
   \ "sftp"
24 / Webdav
   \ "webdav"
25 / Yandex Disk
   \ "yandex"
26 / http Connection
   \ "http"
Storage> 18
** See help for onedrive backend at: https://rclone.org/onedrive/ **

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>
Edit advanced config? (y/n)
y) Yes
n) No
y/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
n) No
y/n> y
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...

此时会浏览器会弹出登录Microsoft账号页面,输入账号密码登陆,点

此时终端会提示你继续操作像这样:

null

因为我是拿个人账号写教程的,所以就选1

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
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:  (personal) id=28acee48ba0a80c9
Chose drive to use:> 0
Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=28acee48ba0a80c9
Is that okay?
y) Yes
n) No
y/n> y
--------------------
[OneDrive]
type = onedrive
token = {"access_token":"EwB4A8l74t6GzbtsBBeBUYAAZr+nsbvDJvpTZnIGTclACszh9PmiR6klQruRt9oBU5AD5ReAZLULrKBbFjgQzmUJHTW1Qg9EI2zCoj+/XMlp4M0V2sraXxwnDZvP/xHtLgMGIF3PLOjlSU0Thh3KCdA4/RIkAALoI7x5ycwXQLuBJ+D/iX3QwJFhVO4or7ogiaVUF0I3oF/A7dOEBJljUwHnBhYeyjOEpCRtoOXIrKl08afJbKtjVDXricLu4aXAIfBYibI7wffxQNxC2AW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XotNGEFHrASLP583x2fpX5Da3VY*AFM18uIpsvg7i0aTj*02e1fAplBUmMzDoo8gd*xqZYYe7eQWaAv1SYuMBFw5TsdYONN5y!ewQcrv9*hhxoLI8xK7VY8VSwG8!9e21N6yLYFFHsTYZMMUOcF0LFEJmo1b29xRkShfuXXk6mxajTCn3IUbOKKP9EW","expiry":"2018-12-14T19:12:44.8939629+08:00"}
drive_id = 28acce58ba0a81c9
drive_type = personal
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name                 Type
====                 ====
OneDrive             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>

到这里已经把OneDrive配置好了,选择q结束配置,

注:配置文件在当前用户家目录

null

5、挂载OneDrive为本地硬盘

null
rclone mount OneDrive:/ H: --cache-dir E:\OneDrive --vfs-cache-mode writes &

如果出现:The service rclone has been started.则说明挂载成功(看到我很可怜了吧,只有15G的空间,求大佬送号😄)。

效果图:

null

好了,就是这样,更多rclone相关的知识自行Google

最后说一点,执行上面这条命令退出终端后台挂载程序也会退出,达不到我们的目的,所以在命令后面加一个&符号就行了,这样退出终端后台程序照样运行,像这样:

null

其他盘如GoogleDriveDropBox等等也可以通过这种方式挂载,这样使得云端文件就像本地文件一样,只要你宽带够大,可以与本地硬盘一样无差别体验。

6、设置开机自启动

6.1 创建 rclone.bat

在D盘或者其他本地硬盘下创建 rclone.bat 内容就是上面挂载的命令,比如:

rclone mount OneDrive:/ H: –cache-dir E:\OneDrive –vfs-cache-mode writes &

把这个命令行拷贝到文本里,另存即可。

6.2 创建rclone.vbs

在启动目录里创建一个rclone.vbs,

C:\Users\你的用户名\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

内容是 CreateObject(“WScript.Shell”).Run “cmd /c D:/rclone.bat”,0

把这个命令行拷贝到文本里,另存到STARTUP目录里即可。

null

重启电脑试一试。。。

7、补充

  • 上述操作成功不用管这部分。有朋友反应最后一行命令执行后显示挂载成功但是并没有盘符出现,本人不懂批处理。。。经测试发现cmd不认识&,并且不能用管理员方式运行cmd,直接运行:start /b rclone mount OneDrive:/ H: --cache-dir E:\OneDrive --vfs-cache-mode writes,并且不要关闭终端,此时应该就可以看到盘符了。效果图如下,但是你关闭终端,盘符就不见了。。。
null
  • 所以我们还是老老实实用Git Bash代替cmd,直接运行rclone mount OneDrive:/ H: --cache-dir E:\OneDrive --vfs-cache-mode writes &就行了,注意退出Git Bash不要点X退出,运行exit退出。此时你应该就可以成功挂载网盘了。
  • rclone更新之后配置过程有点变化,按照提示操作就行,其余步骤一模一样。
「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!