其实 rclone 挂载 Google Drive 网上的教程已经很多了,但是大多数的教程都有一点点过时,与现在的实际操作有一点出入,故整理了当前的挂载操作,以防忘记。

一、 安装并配置 rclone

安装unzip和curl:

Debian/Ubuntu系统

1
2
sudo apt-get update
sudo apt-get install curl unzip

CentOS

1
sudo yum install curl unzip

安装依赖:

1
2
3
4
# centos
yum install -y fuse fuse3 或者 yum install fuse3
# debian
apt-get install fuse3

一键安装rclone脚本

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

vps上开始配置rclone:

1
rclone config

选择 n,新建一个

1
2
3
4
5
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

输入新建的名称,随意写:比如 gd

1
2
Enter name for new remote.
name>gd

选择要挂载的网盘类型,选择18Google Drive

输入client_idclient_secret

选择Google Drive 谷歌云盘的操作权限,选择1完整的访问权限

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
Option scope.
Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 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
2
3
4
5
6
7
Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>

是否要编辑高级配置,我这里选择n

1
2
3
4
Edit advanced config?
y) Yes
n) No (default)
y/n> n

下面注意了,选择n,表示自行配置,

1
2
3
4
5
6
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   

复制代码(下图红色框起来的地方),等下会用到

二、获取授权

一:下载rclone (windows)

https://rclone.org/downloads/

二:获取授权码

打开cmd: 进入你的 rclone目录空白处右键在此处打开命令行窗口

如果开启了科学上网,输入以下命令:

1
2
set http_proxy=socks5://127.0.0.1:7890
set https_proxy=socks5://127.0.0.1:7890

取消sock5代理 (可选)

1
2
set http_proxy=
set https_proxy=

粘贴VPS生成的代码回车

浏览器自动打开进入到谷歌账号登录界面,并选择同意授权。由于是新申请的 API,所以谷歌会提醒该应用未经验证。但是左下角有一行小灰字,点击选择继续就能授权

授权成功浏览器会提示 success:

此时返回CMD命令行,等待几秒就能看见授权的 code 了。

复制授权,回到vps终端,粘贴到 vps 中。红色框起来的地方

image-20230810014110112

接下来 rclone 会询问是否为团队盘:选择n

1
2
3
4
Configure this as a Shared Drive (Team Drive)?

y) Yes
n) No (default)

如果您要挂载的就是团队盘,那么选择 y,不是的话就选择 n

此时配置就已经结束了,退出 clone,开始挂载。

三、 挂载 Google Drive

首先新建一个文件夹用于挂载:

1
mkdir -p /home/google

开始挂载:

1
rclone mount gd: /home/google --allow-other --vfs-cache-mode writes --allow-non-empty --no-modtime &

其中 gd 是 rclone 配置时输入的配置名称/home/google 是挂载目录

还可以自定义设置网盘里的文件夹路径,例如:

1
rclone mount gd:backup /home/google --allow-other --vfs-cache-mode writes --allow-non-empty --no-modtime &

gd 为 rclone 的配置名称:backup 为网盘里的目录名

检查挂载:

1
df -h

卸载挂载:(/home/google 为挂载目录)

1
fusermount -qzu /home/google

完结~