Rclone安装挂载教程


rclone安装

如有问题可加入tg交流群:点我

rclone安装可以使用官方提供的自动安装脚本安装。

稳定版安装:

curl https://rclone.org/install.sh | sudo bash

Beta版安装:

curl https://rclone.org/install.sh | sudo bash -s beta

配置config

初始化配置

rclone config

键入上面的命令并回车,会进入config配置界面:

Name                 Type
====                 ====
day                  drive

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>
n/s/q> n # n为新建
name> day  # 名称,根据喜好填写即可
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 Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Dropbox
   \ "dropbox"
10 / Encrypt/Decrypt a remote
   \ "crypt"
11 / FTP Connection
   \ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
15 / Hubic
   \ "hubic"
16 / In memory object storage system.
   \ "memory"
17 / JottaCloud
   \ "jottacloud"
18 / Koofr
   \ "koofr"
19 / Local Disk
   \ "local"
20 / Mail.ru Cloud
   \ "mailru"
21 / Mega
   \ "mega"
22 / Microsoft Azure Blob Storage
   \ "azureblob"
23 / Microsoft OneDrive
   \ "onedrive"
24 / OpenDrive
   \ "opendrive"
25 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
26 / Pcloud
   \ "pcloud"
27 / Put.io
   \ "putio"
28 / QingCloud Object Storage
   \ "qingstor"
29 / SSH/SFTP Connection
   \ "sftp"
30 / Sugarsync
   \ "sugarsync"
31 / Transparently chunk/split large files
   \ "chunker"
32 / Union merges the contents of several remotes
   \ "union"
33 / Webdav
   \ "webdav"
34 / Yandex Disk
   \ "yandex"
35 / http Connection
   \ "http"
36 / premiumize.me
   \ "premiumizeme"
Storage> 13   #选择网盘类型,谷歌网盘选择13,onedrive选择23,其余网盘自行查看
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id>  # 可直接回车,使用默认的client_id,如果自己创建有client_id可填入,效果比默认更好

Google Application Client Secret 
Setting your own is recommended.
Enter a string value. Press Enter for the default ("").
client_secret> # client_id为默认请直接回车,使用自己创建的client_id,此处应填入对应Client Secret

Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 1   #根据需求选择授权类型,一般选择1,给予最高权限
ID of the root folder
Leave blank normally.

Fill in to access "Computers" folders (see docs), or for rclone to use
a non root folder as its starting point.

Note that if this is blank, the first time rclone runs it will fill it
in with the ID of the root folder.

Enter a string value. Press Enter for the default ("").
root_folder_id>  #直接回车
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file>   #直接回车
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> n  

#是否自动跳转到授权界面,VPS请选择n,以获取链接,手动打开授权,如果在本地电脑配置可以选择y自动跳转到授权界面

Please go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=

#复制link: 后的链接至浏览器打来,登陆谷歌云盘账号,给予权限,获取授权码

Log in and authorize rclone for access
Enter verification code>  #输入授权码
Configure this as a team drive?
y) Yes
n) No (default)
y/n> #输入n
--------------------
[day]
type = drive
scope = drive
token = {"access_token":"  ","token_type":"Bearer","refresh_token":"  ","expiry":"  "}
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> #输入y
Current remotes:
Name                 Type
====                 ====
day                  drive

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保存退出

配置文件config配置一次可以多处使用,以后可以将配置文件复制到其它设备直接使用

挂载为磁盘

如需将云盘挂载到本地可使用下面的命令

rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

DriveName为初始化配置填的name,如本文中的dayFolderGoogle Drive里的文件夹,可留空,留空为挂载整个网盘LocalFolder为VPS上的本地文件夹,网盘会被挂载于此处。

查看是否挂载成功:

df -f  #输入此命令查看是否存在挂载的网盘,无限盘容量一般显示为1.0P或者1.5P

开机自启

挂载的网盘重启后会失效,可使用systemd实现开机自动挂载,适用于CentOS 7Debian 8+Ubuntu 16+

创建systemd配置文件:

#将后面修改成你上面手动运行命令中,除了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


文章作者: 向阳而生
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 向阳而生 !
 上一篇
Dropbox扩容至18G或18.38G永久容量 Dropbox扩容至18G或18.38G永久容量
Dropbox是一款优秀的云端同步工具,可以把文件备份到云端,并且在不同设备间同步,对于跨设备间的文件编辑与使用具有良好的支持。 Dropbox对每位新注册的用户提供了2G的初始容量,如果有更大的容量需求的话需要购买套餐,但是官方也提供了一
2020-11-01 向阳而生
下一篇 
Git入门笔记 Git入门笔记
git diff #查看工作区与暂存区差异 git diff --cached #查看暂存区与仓库差异 git HEAD #查看工作区与仓库的差异 git ch
2020-09-02 向阳而生