Linux下使用rclone挂载网盘到本地

geteshi
2022-06-21 / 0 评论 / 26 阅读 / 正在检测是否收录...

Linux下使用rclone挂载网盘到本地

Rclone是一个支持挂载多数国外网盘的工具。

Rclone官网传送们

目前Rclone支持挂载的网盘有:Google Drive、 Dropbox 、Google Cloud Storage 、Microsoft One Drive 、Hubic、 Backblaze B2 、Yandex Disk 、Openstack Swift / Rackspace cloud files / Memset Memstore 等。更强大的是,Rclone还支持SFTP 、FTP 、HTTP挂载。

配置步骤(以Ubuntu为例)

第一步:安装rclone



1.  方法一:rclone一键安装脚本
    
2.  curl https:
    

4.  方法二:
    
5.  wget https:
    

第二步:授权(以onedrive为例)

rclone authorize "onedrive"

会出现以下信息:



1.  2018/01/23 20:28:56 NOTICE: Config file "C:\\Users\\Administrator\\.config\\rclo
    
2.  ne\\rclone.conf" not found - using defaults
    
3.  Choose OneDrive account type?
    
4.   * Say b for a OneDrive business account
    
5.   * Say p for a personal OneDrive account
    
6.  b) Business
    
7.  p) Personal
    
8.  b/p> p  
    
9.  If your browser doesn't open automatically go to the following link: http://127.
    
10. 0.0.1:53682/auth  #接下来会弹出浏览器,要求你登录账号进行授权
    
11. Log in and authorize rclone for access
    
12. Waiting for code...
    
13. Got code
    
14. Paste the following into your remote machine --->
    
15. {"access_token":"xxxx"}  #请复制{xx}整个内容,后面需要用到
    
16. <---End paste
    

第三步:配置(链接网盘,以onedrive为例)

rclone config

会出现以下信息:



1.  n) New remote
    
2.  s) Set configuration password
    
3.  q) Quit config
    
4.  n/s/q> n
    
5.  name> Rats             #随便填,后面要用到
    
6.  Type of storage to configure.
    
7.  Choose a number from below, or type in your own value
    
8.  1 / Amazon Drive
    
9.     \ "amazon cloud drive"
    
10. 2 / Amazon S3 (also Dreamhost, Ceph, Minio)
    
11.    \ "s3"
    
12. 3 / Backblaze B2
    
13.    \ "b2"
    
14. 4 / Box
    
15.    \ "box"
    
16. 5 / Cache a remote
    
17.    \ "cache"
    
18. 6 / Dropbox
    
19.    \ "dropbox"
    
20. 7 / Encrypt/Decrypt a remote
    
21.    \ "crypt"
    
22. 8 / FTP Connection
    
23.    \ "ftp"
    
24. 9 / Google Cloud Storage (this is not Google Drive)
    
25.    \ "google cloud storage"
    
26. 10 / Google Drive
    
27.    \ "drive"
    
28. 11 / Hubic
    
29.    \ "hubic"
    
30. 12 / Local Disk
    
31.    \ "local"
    
32. 13 / Microsoft Azure Blob Storage
    
33.    \ "azureblob"
    
34. 14 / Microsoft OneDrive
    
35.    \ "onedrive"
    
36. 15 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
    
37.    \ "swift"
    
38. 16 / Pcloud
    
39.    \ "pcloud"
    
40. 17 / QingCloud Object Storage
    
41.    \ "qingstor"
    
42. 18 / SSH/SFTP Connection
    
43.    \ "sftp"
    
44. 19 / Webdav
    
45.    \ "webdav"
    
46. 20 / Yandex Disk
    
47.    \ "yandex"
    
48. 21 / http Connection
    
49.    \ "http"
    
50. Storage> 14      #选择14,Microsoft OneDrive
    
51. Microsoft App Client Id - leave blank normally.
    
52. client_id>       #留空 
    
53. Microsoft App Client Secret - leave blank normally.
    
54. client_secret>   #留空 
    
55. Remote config
    
56. Choose OneDrive account type?
    
57.  * Say b for a OneDrive business account
    
58.  * Say p for a personal OneDrive account
    
59. b) Business
    
60. p) Personal
    
61. b/p> p           #这里选择个人版,你想挂载Business就选择b
    
62. Use auto config?
    
63.  * Say Y if not sure
    
64.  * Say N if you are working on a remote or headless machine
    
65. y) Yes
    
66. n) No
    
67. y/n> n           #选择n
    
68. For this to work, you will need rclone available on a machine that has a web browser available.
    
69. Execute the following on your machine:
    
70.     rclone authorize "onedrive"
    
71. Then paste the result below:
    
72. result> {"access_token":""}  #输入之前在客户端授权的内容
    

74. [Rats]
    
75. client_id = 
    
76. client_secret = 
    
77. token = {"access_token":""}
    

79. y) Yes this is OK
    
80. e) Edit this remote
    
81. d) Delete this remote
    
82. y/e/d> y        #  选择y
    
83. Current remotes:
    

85. Name                 Type
    
86. ====                 ====
    
87. Rats                 onedrive
    

89. e) Edit existing remote
    
90. n) New remote
    
91. d) Delete remote
    
92. r) Rename remote
    
93. c) Copy remote
    
94. s) Set configuration password
    
95. q) Quit config
    
96. e/n/d/r/c/s/q> q    #选择q退出
    

第四步:网盘挂载

挂载为目录



1.  举例:
    
2.  目标:将rclone中的OneDrive挂载到本地/home/songtianlun/onedrive目录下,并清空本地目录内容(--allow-non-empty)
    

4.  rclone mount OneDrive: /home/songtianlun/onedrive --allow-non-empty
    

6.  注:网盘目录和本地目录名称不可一致,否则报错
    

利用Screen让Rclone在后台运行

screen -S onedrive

之后再运行挂载命令。

挂载完成后再用快捷键CTRL-a d 来暂时断开当前会话。最后用screen -r <screen_pid>重新连接上。

若没有安装Screen,可以使用如下命令安装:



1.  yum install screen  #centos系统
    
2.  apt-get install screen  #debian/ubuntu系统
    

第五步:卸载磁盘



1.  fusermount -qzu LocalFolder
    



常用命令



1.  rclone config – 以控制会话的形式添加rclone的配置,配置保存在.rclone.conf文件中。 
    
2.  rclone copy – 将文件从源复制到目的地址,跳过已复制完成的。 
    
3.  rclone mount-挂载
    
4.  rclone sync – 将源数据同步到目的地址,只更新目的地址的数据。 
    
5.  rclone move – 将源数据移动到目的地址。
    
6.  rclone delete – 删除指定路径下的文件内容。 
    
7.  rclone purge – 清空指定路径下所有文件数据。 
    
8.  rclone mkdir – 创建一个新目录。 
    
9.  rclone rmdir – 删除空目录。 
    
10. rclone check – 检查源和目的地址数据是否匹配。
    
11. rclone ls – 列出指定路径下所有的文件以及文件大小和路径。
    
12. rclone lsd – 列出指定路径下所有的目录/容器/桶。
    
13. rclone lsl – 列出指定路径下所有文件以及修改时间、文件大小和路径。
    
14. rclone md5sum – 为指定路径下的所有文件产生一个md5sum文件。 
    
15. rclone sha1sum – 为指定路径下的所有文件产生一个sha1sum文件。 
    
16. rclone size – 获取指定路径下,文件内容的总大小。
    
17. rclone version – 查看当前版本。 
    
18. rclone cleanup – 清空remote。 
    
19. rclone dedupe – 交互式查找重复文件,进行删除/重命名操作。
    

0

评论 (0)

取消