Linux/VPS使用Rclone挂载Google Drive网盘

Linux/VPS使用Rclone挂载Google Drive网盘

Rclone挂载谷歌团队共享云盘非常方便,可以实现VPS扩容。由于Rclone挂载GoogleDrive的方法做了一些调整,今天研究了一下并记录下来,以防忘记。

一、安装Rclone

使用官方安装脚本一键安装

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

二、配置Rclone

开始配置▼

rclone config #配置rclone
n #新建一个配置
GoogleDrive #输入配置的名称 名称可以自定义
Linux/VPS使用Rclone挂载Google Drive网盘

因为连接的是Google Drive,所以这里选择18 ▼

Linux/VPS使用Rclone挂载Google Drive网盘

输入自己在谷歌获取的ClientId和Client Secret。

相关教程:获取/启用自己的Google Drive API凭证教程

Linux/VPS使用Rclone挂载Google Drive网盘

如果自己用的话,直接选1,获取所有权限 ▼

Linux/VPS使用Rclone挂载Google Drive网盘
service_account_file>回车
root_folder_id> # 回车
service_account_file> # 回车
--------------------------------------------------------------------
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> n
--------------------------------------------------------------------
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "drive" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Then paste the result.
Enter a value.
config_token>这里的config_token需要在自行获取
--------------------------------------------------------------------------------------------------

config_token获取方法

注意:获取的Windows系统全局代理,不然会失败!

1.下载rclone Windows版

下载地址

Linux/VPS使用Rclone挂载Google Drive网盘

解压后找到文件夹,在地址框输入 CMD 回车

Linux/VPS使用Rclone挂载Google Drive网盘

复制粘贴前面得到的 rclone authorize “drive” “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx” 这串字符 即可获得config_token

Linux/VPS使用Rclone挂载Google Drive网盘

————————————————————————————————-

将config_token粘贴到config_token>后继续操作

Log in and authorize rclone for access
Enter verification code> 4/0AGPbXQ9thkw4XynGuNP91QxL4g9Mz7Rubv7M_lajOCwd8GqHuTlOzI
Configure this as a team drive?
y) Yes
n) No (default)
y/n> n

随后会确认配置 选 y

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

三、挂载GoogleDrive开机自启动

安装fuse

#centos

yum install fuse fuse3 -y

#ubuntu&debian

apt-get install fuse fuse3 -y

创建一个 挂载目录

mkdir /GoogleDrive

在/etc/systemd/system/目录新建一个rclone.server文件:

cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
AssertPathIsDirectory=LocalFolder
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount GoogleDrive: /GoogleDrive \
 --umask 0000 \
 --default-permissions \
 --allow-non-empty \
 --allow-other \
 --buffer-size 32M \
 --dir-cache-time 12h \
 --vfs-read-chunk-size 64M \
 --vfs-read-chunk-size-limit 1G
ExecStop=/bin/fusermount -u LocalFolder
Restart=on-abort
User=root
[Install]
WantedBy=default.target
EOF

启动并设置为开机启动

systemctl start rclone && systemctl enable rclone

查看是否挂载成功

df -h
Linux/VPS使用Rclone挂载Google Drive网盘

【AD】DMIT优惠码 – 美国洛杉矶CN2 GIA VPS配置升级季付28美元起