使用Rclone挂载Google Drive网盘教程 VPS扩容

教程评论1,345字数 2401阅读模式

Rclone是一个网盘本地挂载软件,能将全世界多个热门的网盘挂载为系统本地磁盘,实现方便快捷的云盘文件管理效果。搭配无限空间的Google Drive网盘,相当于在电脑上安装了一个无比巨大的磁盘。

一般挂载Google Drive的时候,默认是使用的官方提供的api,所以高峰期上传文件的时候,由于很多人在用,导致api的流量上限,会出现各种403ratelimit等错误,最常见的报错提示为:Failed to get file: googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded,然后目前的解决方法就是使用自己的api文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

今天和大家分享在VPS上使用Google Drive API挂载Google Drive网盘的方法。文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

一、安装挂载工具rclone

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

二、配置rclone

rclone config

name 可以自定义文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

Choose a number from below, or type in your own value
选谷歌 (13) 可能会因为版本的不同而改变 注意选择 Google drive文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

client_id> 可以用自己的Google Drive API的client_id,也可以直接回车文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

关于Google Drive API的client_id和client_secret的获取方法可以参考这个教程?文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

参考教程:获取/启用自己的Google Drive API凭证教程文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

client_secret> 可以用自己的Google Drive API的client_secret,也可以直接回车文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

Choose a number from below, or type in your own value
scope> 1 选1 有最大的使用权限。文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html

Enter a string value. Press Enter for the default ("").
root_folder_id> 直接回车文章源自合一学院-https://unvmax.com/%e4%bd%bf%e7%94%a8rclone%e6%8c%82%e8%bd%bdgoogle-drive%e7%bd%91%e7%9b%98%e6%95%99%e7%a8%8b-vps%e6%89%a9%e5%ae%b9.html


service_account_file> 直接回车

Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n #不用别的高级配置

Use auto config?

y/n> n

浏览器打开链接登录谷歌账号获取Key

Please go to the following link: https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Log in and authorize rclone for access
Enter verification code>贴入你获取到的key

Configure this as a team drive?
y) Yes
n) No (default)
y/n> 挂载共享网盘选择 y 挂载自己的网盘目录选 n

确认配置是否正确

y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> 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

三、挂载Google Drive

1.创建一个/GoogleDrive目录,作为挂载目录

mkdir -p /GoogleDrive

2.挂载

/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 &

--后面跟的是参数 可以自己调整

如果如下报错内容:

Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

Centos解决办法:

yum install fuse -y

Debian/Ubuntu解决办法:

apt-get install fuse -y

3.查看挂载

df -h

4.设置自动挂载和开机自启动

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命令看来控制rclone挂载

启动

systemctl start rclone

开机启动

systemctl enable rclone

重新启动

systemctl restart rclone

停止

systemctl stop rclone
教程最后更新:2023-2-21
匿名

发表评论

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

拖动滑块以完成验证