Centos 系统下如何使用 rclone 挂载 Google 云盘

广告:如果需要 Gsuite 商务版 请联系 @lsedog

说明:我们很多人喜欢用VPS做离线下载,不过由于有的服务器硬盘太小了,这个教程主要介绍如何挂载Google Drive网盘的方法,毕竟Google Drive有15G免费的空间,商业版也有无限空间,都可以利用上去。不过单个离线文件不能超过你的实际磁盘大小,所有选择VPS的时候还是要注意硬盘大小的。以下安装教程适用于Centos 7

安装

  1. 安装 rclone
    进入官网获取最新版本:https://rclone.org/downloads/ (不建议,可能接下来的步骤有点出入,出现问题请自行解决)
    或者执行:

    • sudo su
    • yum -y install wget unzip nload htop fuse p7zip-full && wget https://downloads.rclone.org/v1.42/rclone-v1.42-linux-amd64.zip &&
      unzip rclone-v1.42-linux-amd64.zip && cd rclone-v1.42-linux-amd64
    • cp rclone /usr/bin/
    • sudo chown root:root /usr/bin/rclone
    • sudo chmod 755 /usr/bin/rclone
    • mkdir -p /usr/local/share/man/man1
    • cp rclone.1 /usr/local/share/man/man1/
    • mandb
  2. 生成配置文件
    • rclone config


    [root@centos-s-2vcpu-4gb-sfo2-01 ~]# rclone config

    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> n # n 新建

    name> gc # gc为你自定义的配置名,后面挂载要用到

    Type of storage to configure.

    Choose a number from below, or type in your own value

    1 / Alias for a existing remote

       \ "alias"

    2 / Amazon Drive

       \ "amazon cloud drive"

    3 / Amazon S3 Compliant Storage Providers (AWS, Ceph, Dreamhost, IBM COS, Minio)

       \ "s3"

    4 / Backblaze B2

       \ "b2"

    5 / Box

       \ "box"

    6 / Cache a remote

       \ "cache"

    7 / Dropbox

       \ "dropbox"

    8 / Encrypt/Decrypt a remote

       \ "crypt"

    9 / FTP Connection

       \ "ftp"

    10 / Google Cloud Storage (this is not Google Drive)

       \ "google cloud storage"

    11 / Google Drive

       \ "drive"

    12 / Hubic

       \ "hubic"

    13 / Local Disk

       \ "local"

    14 / Mega

       \ "mega"

    15 / Microsoft Azure Blob Storage

       \ "azureblob"

    16 / Microsoft OneDrive

       \ "onedrive"

    17 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)

       \ "swift"

    18 / Pcloud

       \ "pcloud"

    19 / QingCloud Object Storage

       \ "qingstor"

    20 / SSH/SFTP Connection

       \ "sftp"

    21 / Webdav

       \ "webdav"

    22 / Yandex Disk

       \ "yandex"

    23 / http Connection

       \ "http"

    Storage> 11 # 选择你的云盘类型,这里选择 11

    Google Application Client Id - leave blank normally.

    client_id>

    Google Application Client Secret - leave blank normally.

    client_secret>

    Scope that rclone should use when requesting access from drive.

    Choose a number from below, or type in your own value

    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 完全权限

    ID of the root folder - leave blank normally.  Fill in to access "Computers" folders. (see docs).

    root_folder_id>

    Service Account Credentials JSON file path  - leave blank normally.

    Needed only if you want use SA instead of interactive login.

    service_account_file>

    Remote config

    Use auto config?

    * Say Y if not sure

    * Say N if you are working on a remote or headless machine or Y didn't work

    y) Yes

    n) No

    y/n> n # 选择 n 打开给定的网址,登陆后输入你的授权码

    If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=202264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=abb02a08ad387591e56a90072611f8c3

    Log in and authorize rclone for access

    Enter verification code> 4/AADjNEUk-VAC5jGSnXIw1s1OM-fpUJzZvaL #填你的授权码

    Configure this as a team drive?

    y) Yes

    n) No

    y/n> n # 不配置为驱动

    --------------------

    [gc]

    type = drive

    client_id =

    client_secret =

    scope = drive

    root_folder_id =

    service_account_file =

    token = {"access_token":"ya29.GlviBYygA6C37jN","token_type":"Bearer","refresh_token":"1/LFJQmYE","expiry":"2018-06-23T08:17:26.848556422+08:00"}

    --------------------

    y) Yes this is OK

    e) Edit this remote

    d) Delete this remote

    y/e/d> y # 输入 y 确认配置 

    Current remotes:

    Name                 Type

    ====                 ====

    gc                   drive

    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 # 输入 q 退出向导

  3. 挂载
    • mkdir /gc # 你需要挂载的硬盘目录
    • rclone mount gc:(把 “gc” 替换为你的配置文件 “:”  后面为你网盘挂载的目录) /gc(把 /gc 修改为你需要挂载的硬盘目录) --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000  --vfs-cache-mode >= writes &

    查看是否挂载成功

    [root@centos-s-2vcpu-4gb-sfo2-01 ~]# df -h

    文件系统        容量  已用  可用 已用% 挂载点

    devtmpfs        2.0G     0  2.0G    0% /dev

    tmpfs           2.0G   28K  2.0G    1% /dev/shm

    tmpfs           2.0G  177M  1.8G    9% /run

    tmpfs           2.0G     0  2.0G    0% /sys/fs/cgroup

    /dev/vda1        80G   15G   65G   19% /

    tmpfs           395M     0  395M    0% /run/user/0

    gd:             1.0P  371G  1.0P    1% /gd

    [root@centos-s-2vcpu-4gb-sfo2-01 ~]#

    显示信息有你的挂载目录就表示挂载成功了。

点赞
  1. 寫作服務说道:
    Firefox Windows 10

    感谢楼主的分享,赞赞

  2. jk说道:
    Google Chrome Windows 8.1

    电子邮件地址不会被公开。必填项已用 * 标注

发表评论

电子邮件地址不会被公开。必填项已用 * 标注