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

原创 教程 精选评论1,727字数 612

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

一、安装Rclone

使用官方安装脚本一键安装文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

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

二、配置Rclone

开始配置▼文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

rclone config #配置rclone
n #新建一个配置
GoogleDrive #输入配置的名称 名称可以自定义

因为连接的是Google Drive,所以这里选择18 ▼文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

输入自己在谷歌获取的ClientId和Client Secret。文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

相关教程:获取/启用自己的Google Drive API凭证教程文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

如果自己用的话,直接选1,获取所有权限 ▼文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

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获取方法文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

注意:获取的Windows系统全局代理,不然会失败!文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

1.下载rclone Windows版文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

下载地址文章源自合一学院-https://unvmax.com/linux-vps%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98.html

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

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

-------------------------------------------------------------------------------------------------

将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
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证