rclone 挂载 Google drive
- 安装 rclone
sudo apt update && sudo apt install -y curl fuse3 && curl https://rclone.org/install.sh | sudo bash
- 挂载 Google drive
rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n # n 创建新的
Enter name for new remote.
name> gd # 命名
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 S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, ChinaMobile, Cloudflare, Cubbit, DigitalOcean, Dreamhost, Exaba, FileLu, FlashBlade, GCS, Hetzner, HuaweiOBS, IBMCOS, IDrive, Intercolo, IONOS, Leviia, Liara, Linode, LyveCloud, Magalu, Mega, Minio, Netease, Outscale, OVHcloud, Petabox, Qiniu, Rabata, RackCorp, Rclone, Scaleway, SeaweedFS, Selectel, Servercore, SpectraLogic, StackPath, Storj, Synology, TencentCOS, Wasabi, Zata, Other
\ (s3)
5 / Backblaze B2
\ (b2)
6 / Better checksums for other remotes
\ (hasher)
7 / Box
\ (box)
8 / Cache a remote
\ (cache)
9 / Citrix Sharefile
\ (sharefile)
10 / Cloudinary
\ (cloudinary)
11 / Combine several remotes into one
\ (combine)
12 / Compress a remote
\ (compress)
13 / DOI datasets
\ (doi)
14 / Dropbox
\ (dropbox)
15 / Encrypt/Decrypt a remote
\ (crypt)
16 / Enterprise File Fabric
\ (filefabric)
17 / FTP
\ (ftp)
18 / FileLu Cloud Storage
\ (filelu)
19 / Files.com
\ (filescom)
20 / Gofile
\ (gofile)
21 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
22 / Google Drive
\ (drive)
23 / Google Photos
\ (google photos)
24 / HTTP
\ (http)
25 / Hadoop distributed file system
\ (hdfs)
26 / HiDrive
\ (hidrive)
27 / ImageKit.io
\ (imagekit)
28 / In memory object storage system.
\ (memory)
29 / Internet Archive
\ (internetarchive)
30 / Jottacloud
\ (jottacloud)
31 / Koofr, Digi Storage and other Koofr-compatible storage providers
\ (koofr)
32 / Linkbox
\ (linkbox)
33 / Local Disk
\ (local)
34 / Mail.ru Cloud
\ (mailru)
35 / Mega
\ (mega)
36 / Microsoft Azure Blob Storage
\ (azureblob)
37 / Microsoft Azure Files
\ (azurefiles)
38 / Microsoft OneDrive
\ (onedrive)
39 / OpenDrive
\ (opendrive)
40 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
\ (swift)
41 / Oracle Cloud Infrastructure Object Storage
\ (oracleobjectstorage)
42 / Pcloud
\ (pcloud)
43 / PikPak
\ (pikpak)
44 / Pixeldrain Filesystem
\ (pixeldrain)
45 / Proton Drive
\ (protondrive)
46 / Put.io
\ (putio)
47 / QingCloud Object Storage
\ (qingstor)
48 / Quatrix by Maytech
\ (quatrix)
49 / Read archives
\ (archive)
50 / SMB / CIFS
\ (smb)
51 / SSH/SFTP
\ (sftp)
52 / Sia Decentralized Cloud
\ (sia)
53 / Storj Decentralized Cloud Storage
\ (storj)
54 / Sugarsync
\ (sugarsync)
55 / Transparently chunk/split large files
\ (chunker)
56 / Uloz.to
\ (ulozto)
57 / Union merges the contents of several upstream fs
\ (union)
58 / Uptobox
\ (uptobox)
59 / WebDAV
\ (webdav)
60 / Yandex Disk
\ (yandex)
61 / Zoho
\ (zoho)
62 / iCloud Drive
\ (iclouddrive)
63 / premiumize.me
\ (premiumizeme)
64 / seafile
\ (seafile)
Storage> 22 # 选择Google drive
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> # 直接回车
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> # 直接回车
Option scope.
Comma separated list of scopes 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
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>
Edit advanced config?
y) Yes
n) No (default)
y/n> # 直接回车
Use web browser to automatically authenticate rclone with remote?
* Say Y if the machine running rclone has a web browser you can use
* Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes (default)
n) No
y/n> 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" "eyJzY29wxxxxxxxxxxxxx"
Then paste the result.
Enter a value.
config_token> # 复制rclone authorize 到本地rclone cmd执行-注意本地需要全局eyJ0b2tlbixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n> # 直接回车
Configuration complete.
Options:
- type: drive
- scope: drive
- token: {"access_token":xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
- team_drive:
Keep this "gd" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> # 直接回车
Current remotes:
Name Type
==== ====
gd drive
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
需先创建本地挂载目录
如 mkdir -p /home/gd
rclone mount 网盘名:网盘下的目录 即将挂载到的目录 --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --daemon
如
rclone mount gd:/file /home/gd --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --daemon
3. 挂载Google Drive网盘
根据需求不同,可参考下表自行修改,其他配置参数可前往Rclone官网查阅:
| 参数 | 说明 |
|---|---|
| –allow-other | 允许非当前rclone用户外其它用户进行访问 |
| –attr-timeout 5m | 文件属性缓存,(大小,修改时间等)的时间。 |
| –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 | 后台运行程序 |
这里给出一个模板:
rclone mount <配置的云盘名称>:<要挂载的云盘目录> <作为挂载点的本地目录> \
--umask 0000 \
--default-permissions \
--allow-non-empty \
--allow-other \
--attr-timeout 5m \
--transfers 4 \
--buffer-size 32M \
--low-level-retries 200 \
--vfs-read-chunk-size 32M \
--vfs-read-chunk-size-limit 128M \
--vfs-cache-mode full \
--vfs-cache-max-age 24h \
--vfs-cache-max-size 10G \
--daemon
rclone mount gd:/file /home/gd \
--umask 0000 \
--default-permissions \
--allow-non-empty \
--allow-other \
--attr-timeout 3m \
--transfers 8 \
--buffer-size 512M \
--low-level-retries 200 \
--vfs-read-chunk-size 64M \
--vfs-read-chunk-size-limit 512M \
--vfs-cache-mode full \
--vfs-cache-max-age 24h \
--vfs-cache-max-size 50G \
--daemon
如果需要取消挂载,使用如下命令:
fusermount -qzu <挂载路径>
如
fusermount -qzu /home/gd 
Comments NOTHING