rclone挂载Google Drive谷歌云盘的安装配置教程
前言
此篇决定写一篇使用rclone挂载Google Drive的安装配置的教程,由于篇幅过于冗长,新手可以请别跳着看。不然
会漏看细节部分,这里我做个记录留以后方便查阅
安装
下载安装脚本
wget https://rclone.org/install.sh
进行安装,安装大约几秒钟就搞定了
bash install.sh
出现下面这些反馈,即是安装完成
rclone v1.60.0 has successfully installed.
Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.
配置
完成之后,我们输入下面命令进行配置
rclone config
这里我选择的是N,新建一个
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
输入新建的名称,随意写
Enter name for new remote.
name> ivpsr
这里让你选择要挂载的网盘类型,我选择的是18,Google Drive
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
1 / 1Fichier
\ (fichier)
2 / Akamai NetStorage
\ (netstorage)
3 / Alias for an existing remote
\ (alias)
4 / Amazon Drive
\ (amazon cloud drive)
5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, China Mobile, Cloudflare, ArvanCloud, Digital Ocean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Lyve Cloud, Minio, Netease, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Tencent COS, Qiniu and Wasabi
\ (s3)
6 / Backblaze B2
\ (b2)
7 / Better checksums for other remotes
\ (hasher)
8 / Box
\ (box)
9 / Cache a remote
\ (cache)
10 / Citrix Sharefile
\ (sharefile)
11 / Combine several remotes into one
\ (combine)
12 / Compress a remote
\ (compress)
13 / Dropbox
\ (dropbox)
14 / Encrypt/Decrypt a remote
\ (crypt)
15 / Enterprise File Fabric
\ (filefabric)
16 / FTP
\ (ftp)
17 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
18 / Google Drive
\ (drive)
19 / Google Photos
\ (google photos)
20 / HTTP
\ (http)
21 / Hadoop distributed file system
\ (hdfs)
22 / HiDrive
\ (hidrive)
23 / In memory object storage system.
\ (memory)
24 / Internet Archive
\ (internetarchive)
25 / Jottacloud
\ (jottacloud)
26 / Koofr, Digi Storage and other Koofr-compatible storage providers
\ (koofr)
27 / Local Disk
\ (local)
28 / Mail.ru Cloud
\ (mailru)
29 / Mega
\ (mega)
30 / Microsoft Azure Blob Storage
\ (azureblob)
31 / Microsoft OneDrive
\ (onedrive)
32 / OpenDrive
\ (opendrive)
33 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ (swift)
34 / Oracle Cloud Infrastructure Object Storage
\ (oracleobjectstorage)
35 / Pcloud
\ (pcloud)
36 / Put.io
\ (putio)
37 / QingCloud Object Storage
\ (qingstor)
38 / SMB / CIFS
\ (smb)
39 / SSH/SFTP
\ (sftp)
40 / Sia Decentralized Cloud
\ (sia)
41 / Storj Decentralized Cloud Storage
\ (storj)
42 / Sugarsync
\ (sugarsync)
43 / Transparently chunk/split large files
\ (chunker)
44 / Union merges the contents of several upstream fs
\ (union)
45 / Uptobox
\ (uptobox)
46 / WebDAV
\ (webdav)
47 / Yandex Disk
\ (yandex)
48 / Zoho
\ (zoho)
49 / premiumize.me
\ (premiumizeme)
50 / seafile
\ (seafile)
Storage> 18
这里要求我们填写OAuth client ID,就是下方输入client_id、client_secret,如果需要申请OAuth client ID
看我这里的申请OAuth client ID的教程
Option client_id.
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 value. Press Enter to leave empty.
client_id> 填写你申请OAuth client ID的client_id
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> 填写你申请OAuth client ID的client_secret
选择Rclone对Google Drive谷歌云盘的操作权限,我这里选择1,完全访问所有文件,不包括应用程序
数据文件夹
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
回车默认
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
Edit advanced config?
y) Yes
n) No (default)
y/n> n
这里就询问是不是自动配置,我选择N,然后跳出rclone authorize的代码,老版本是直接复制到浏览器。新版的需要下载windows
端的rclone,在windows端进行验证。
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
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" "eyJjbGllbnRfaffiOiI3NzA5OTIwNzAyNDItczFqMGMzMGdiOGJyNDQ0bjAyMmo0cmNnaTFnb2FyaTUuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJjbGllbnRfc2VjcmV0IjoiR09DU1BYLXBjSzZnUGt1UDF5cEYtNlYtemdPYmduaG1HWkciLCJzY29wZSI6ImRyaXZlIn0"
Then paste the result.
Enter a value.
config_token>
这里我准备好了rclone windows版,地址https://rclone.org/downloads/
下载完后,解压rclone windows版,把下面这段复制到cmd里回车
rclone authorize "drive" "eyJjbGllbnRfaffiOiI3NzA5OTIwNzAyNDItczFqMGMzMGdiOGJyNDQ0bjAyMmo0cmNnaTFnb2FyaTUuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJjbGllbnRfc2VjcmV0IjoiR09DU1BYLXBjSzZnUGt1UDF5cEYtNlYtemdPYmduaG1HWkciLCJzY29wZSI6ImRyaXZlIn0"
就会弹到浏览器去验证你得谷歌号,看到如下的界面,“此应用未经google验证”,不用去管,直接点继续
继续让rclone访问谷歌获得授权
最后生成token code填到我们配置的config_token,如果这里电脑端的cmd一直卡在Waiting for code... Got
code就不动了的话,然后最后报错个超时,不生成token code,就看我写的这一篇有解决方法
这里我们将token code填到我们配置的config_token后,进行下一步,询问是不是团队的云盘,这里我选择N
Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n> n
到这里,配置阶段就已经结束了
rclone参数
根据需求不同,可参考下表自行修改,其他配置参数可前往Rclone官网查阅:
参数 | 说明 |
---|---|
–allow-other | 允许非当前rclone用户外其它用户进行访问 |
–attr-timeout 5m | 文件属性缓存,(大小,修改时间等)的时间。如果VPS |
–vfs-cache-mode full | 开启VFS文件缓存,可减少rclone与API交互,同时可提高文件读写效率 |
–vfs-cache-max-age 24h | VFS文件缓存时间,这里设置24小时,如果文件很少更改,建议设置更长时间 |
–vfs-cache-max-size 10G | VFS文件缓存上限大小,请根据服务器剩余磁盘自行调节 |
–vfs-read-chunk-size-limit 100M | 分块读取大小,这里设置的是100M,可提高文件读的效率,比如1G的文件,大致分为10个块进行读取,但与此同时API请求次数也会增多 |
–buffer-size 32M | 该参数为读取每个文件时的内存缓冲区大小,控制rclone上传和挂载的时候的内存占用,调低点可以防止内存占用过高而崩溃,但太低可能会影响部分文件的传输速度,请根据服务器内存大小自行设置 |
–low-level-retries | 该参数为传输文件没速度的时候重试次数,没速度的时候,单个会自动睡眠10ms起,然后再重试,不行,再睡眠更长一段时间,再重试,这样可以稍微加快文件上传进度 |
–transfers | 该参数控制最大同时传输任务数量,如果你cpu性能差,建议调低,但太低可能会影响多个文件同时传输的速度 |
–daemon | 后台运行程序 |