前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >rclone挂载Google Drive

rclone挂载Google Drive

作者头像
行 者
发布2023-10-20 14:46:43
3210
发布2023-10-20 14:46:43
举报
文章被收录于专栏:运维技术迷运维技术迷

元旦在土区成功购买Google one 2T之后,就着手开始用rclone挂载Google Drive

安装rclone

代码语言:javascript
复制
curl https://rclone.org/install.sh | sudo bash

申请Google API

  1. 首先登录到Google API console,创建一个应用,点击"启用API和服务",找到Google Drive并启用;
  2. 点击OAuth同意屏幕,用户类型选择外部,应用名称随便填写,比如"rclone"就可以。用户支持电子邮件和开发者联系邮箱都填写您自己的就可以,点击保存并继续,剩下的参数都是用默认就可以了。
  3. 点击凭据,屏幕上方点击创建凭据,选择OAuth 客户端ID,应用类型选择桌面应用,名称随便填,点击创建。创建后会向您提供您的客户端ID 和客户端密码,务必记下这些数据,并且填写到rclone中。
  4. 最后选择OAuth同意屏幕,选择发布应用。此时应该能看到发布状态变为了正式版。 至此Google API就申请完成了,继续返到rclone中进行配置。

配置

配置rclone google drive

代码语言:javascript
复制
root@rac:/# rclone config
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> google

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, DigitalOcean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Liara, 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

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> 你在google 申请的

Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> 你在google 申请的

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> 

Edit advanced config?
y) Yes
n) No (default)
y/n> 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
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" "XXXXXXXXXXXXXXXXXX"
Then paste the result.
Enter a value.
config_token> xxxxxxxxxxxxxxxxxxxxx

鉴于某些不可描述的原因,我们需要在本地安装rclone(下载地址)并且执行上面的rclone authorize "drive" "XXXXXXXXXXXXXXXXXX"来获取config_token。而后降获取到的config_token复制上去,继续进行下面的操作。

代码语言:javascript
复制
Configure this as a Shared Drive (Team Drive)?

y) Yes
n) No (default)
y/n> n

Configuration complete.
Options:
- type: drive
- client_id: xxxxxxxxxxxxxxxxx
- client_secret: xxxxxxxxxxxxxxxxx
- scope: drive
- token: {"access_token":"xxxxxxxxxxxxxxxxx","token_type":"Bearer","refresh_token":"1//0xxxxxxxxxxxxxx","expiry":"2023-01-06T13:41:29.7979612+08:00"}
- team_drive: 
Keep this "google" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> 

Current remotes:

Name                 Type
====                 ====
google               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

代码语言:javascript
复制
# CentOS
yum install -y fuse 
   
# Debian/Ubuntu
apt install -y fuse
   
[root@VM-8-7-centos rclone]# mkdir /google
[root@VM-8-7-centos rclone]# rclone mount google:/ /google \
> --no-check-certificate \
> --no-gzip-encoding \
> --copy-links \
> --umask 0000 \
> --default-permissions \
> --allow-non-empty \
> --allow-other \
> --transfers 1 \
> --buffer-size 64M \
> --low-level-retries 200 \
> --dir-cache-time 12h \
> --vfs-read-chunk-size 32M \
> --vfs-read-chunk-size-limit 1G \
> --daemon

查看磁盘挂载,google drive已经挂上去了。

代码语言:javascript
复制
[root@VM-8-7-centos /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        989M     0  989M   0% /dev
tmpfs          1000M   24K 1000M   1% /dev/shm
tmpfs          1000M  600K  999M   1% /run
tmpfs          1000M     0 1000M   0% /sys/fs/cgroup
/dev/vda1        30G   15G   14G  51% /
tmpfs           200M     0  200M   0% /run/user/0
google:         2.0T  6.7G  2.0T   1% /google

卸载

代码语言:javascript
复制
fusermount -qzu /google
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2023-01-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装rclone
  • 申请Google API
  • 配置
    • 配置rclone google drive
      • 挂载Google Drive
        • 卸载
        相关产品与服务
        对象存储
        对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档