静看光阴荏苒
不管不顾不问不说也不念

挂载GoogleDrive网盘到VPS当本地硬盘的两种方法

最近手上有一个GoogleDrive无限容量的网盘,由于GoogleDrive网盘(以下简称GD)内不能离线下载,在国内又是被墙的,闲着也是闲着,就想看能不能挂载到VPS中,然后在VPS内下载小姐姐资源到GD内,这样就可以实现离线和在线观看了,岂不是美滋滋~

本篇文章暂时先不介绍离线下载到GD网盘内的姿势,因为我实测这种挂载的盘子,如果直接写数据的话会出各种乱七八糟的错误,所以稍后我会写一篇文章专门介绍下如何正确将你的小姐姐资源转入到GD网盘内。所以我们当前要做的就是先把GD网盘挂载到VPS上面去~

注意:无论是哪种挂载方法,原生仅支持KVM,并不是说OpenVZ不支持,而是你需要给你的服务商发TK告诉他们开一下FUSE,如果没有FUSE是没办法挂载的。

第一种方法:Rclone挂载(推荐)。

安装EPEL源:

yum -y install epel-release

安装一些基本组件和依赖:

yum -y install wget unzip screen fuse fuse-devel

下载Rclone解压然后进入目录:

wget https://downloads.rclone.org/rclone-v1.39-linux-amd64.zip
unzip rclone-v1.39-linux-amd64.zip
cd rclone-v1.39-linux-amd64

运行Rclone开始配置:

./rclone config

第一步选择n,然后回车输入一个name,建议这个name设置的简单好记一点,如图所示:

然后选择我们要挂载的类型,这里选择10,切记要选对了:

接着client_id、client_secret、service_account_file都留空直接回车,Use auto config?这里我们选择n,如图所示:

现在rclone会在终端内给我们回显一个GoogleDrive的授权登录地址,如图所示:

我们复制这个地址然后用本地电脑的浏览器打开并登录(需翻墙),然后点击允许按钮,如图所示:

接着复制如下图所示的授权代码:

回到终端内粘贴授权代码然后回车,继续按如下图操作,依次输入n、y、q:

全部完成后,现在新建一个你要挂载的目录:

mkdir -p /lala/gdrive

用screen创建一个新的会话:

screen -S rclone

执行如下命令:

./rclone mount lala: /lala/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes

不出意外的话,就挂载成功了:

第二种方法:GDriveFS挂载(不推荐)。

安装EPEL源:

yum -y install epel-release

安装一些基本组件和依赖:

yum -y install fuse fuse-devel python-pip python-devel gcc gcc-c++ openssl-devel

升级一下pip:

pip install --upgrade pip

使用pip安装GDriveFS:

pip install gdrivefs

成功后如图所示:

安装完成后执行如下命令开始配置:

gdfstool auth -u

GDriveFS和Rclone一样,这里也会给你一个Google的登录授权地址:

还是一样登录然后授权允许:

然后复制授权代码:

回到终端内执行:

gdfstool auth -a /var/cache/gdfs.creds "你的授权码"

回显如图所示信息就说明成功了:

完成后新建一个你要挂载的目录:

mkdir -p /lala/gdrivefs

尝试挂载:

gdfstool mount /var/cache/gdfs.creds /lala/gdrivefs

不出意外的话,这里会报错,错误信息类似于:

httplib2.SSLHandshakeError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed

原因是httplib2的版本太低了,我们要卸载然后安装一个新版本。

卸载当前版本:

pip uninstall httplib2

安装新版本:

pip install httplib2

成功后如图所示,我们把0.8的httplib2换成了0.10.3:

现在重新执行挂载命令:

gdfstool mount /var/cache/gdfs.creds /lala/gdrivefs

查看一下,应该就成功了:

写在最后:

Q:为什么推荐Rclone而不推荐GDriveFS?

1、本质上来说,这两个东西挂载的原理都是一样的,但是我实测Rclone挂载后加载网盘的速度比GDriveFS快一些。

2、Rclone有一个缓存模式,开了这个模式后,我们在VPS上往GD盘写数据的时候出错的概率要大幅降低,虽然还是有。。。

3、Rclone安装更简单,不折腾~

Q:VPS重启后挂载盘就没了?

默认是这样子的,当然你可以把挂载命令写到开机启动项里面,或者如果你用的Rclone可以写一个服务来启动。假设这里我用的Rclone挂载的,服务可以这样子写:

先把rclone的可执行文件复制到/usr/bin:

cp /root/rclone-v1.39-linux-amd64/rclone /usr/bin/rclone

新建一个rclone.service文件:

vi /usr/lib/systemd/system/rclone.service

写入:

[Unit]
Description=rclone
    
[Service]
User=root
ExecStart=/usr/bin/rclone mount lala: /lala/gdrive --allow-other --allow-non-empty --vfs-cache-mode writes
Restart=on-abort
    
[Install]
WantedBy=multi-user.target

重载daemon,让新的服务文件生效:

systemctl daemon-reload

现在就可以用systemctl来启动rclone了:

systemctl start rclone

设置开机启动:

systemctl enable rclone

停止、查看状态可以用:

systemctl stop rclone
systemctl status rclone

重启你的VPS,然后查看一下rclone的服务起来没,接着查看一下盘子挂上去没:

reboot
systemctl status rclone
df -h

可以看到一切都是如此完美:

赞(5)
未经允许不得转载:荒岛 » 挂载GoogleDrive网盘到VPS当本地硬盘的两种方法
分享到: 更多 (0)

评论 59

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    google-drive-ocamlfuse也不错

    Escape6年前 (2018-03-14) Google Chrome 64.0.3282.186 Google Chrome 64.0.3282.186 Windows 10 x64 Edition Windows 10 x64 Edition回复
  2. #2

    Ubuntu 14.04
    安装 google-drive-ocamlfuse
    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:alessandro-strada/ppa
    sudo apt-get update
    sudo apt-get install google-drive-ocamlfuse

    ubuntu简单方便

    Escape6年前 (2018-03-14) Google Chrome 64.0.3282.186 Google Chrome 64.0.3282.186 Windows 10 x64 Edition Windows 10 x64 Edition回复
  3. #3

    其实我比较好奇怎么实现在线观看哈哈哈哈哈 :oops: 希望博主出后续教程

    shmily6年前 (2018-03-18) Google Chrome 64.0.3282.186 Google Chrome 64.0.3282.186 Windows 8.1 x64 Edition Windows 8.1 x64 Edition回复
    • 前两天就打算写你说的后续教程了,但是有点忙一直没时间。。。

      LALA6年前 (2018-03-18) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
  4. #4

    rclone mount lala: /lala/gdrive –allow-other –allow-non-empty –vfs-cache-mode writes
    这里出现错误请指教,
    2018/03/23 01:31:20 Fatal error: failed to mount FUSE fs: fusermount: exec: “fusermount”: executable file not found in $PATH
    不知道怎么回事,求博主大大解答下 :???:

    陆伯言6年前 (2018-03-23) Google Chrome 64.0.3282.140 Google Chrome 64.0.3282.140 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 已经解决 yum install fuse 即可,谢谢博主

      陆伯言6年前 (2018-03-23) Google Chrome 64.0.3282.140 Google Chrome 64.0.3282.140 Windows 10 x64 Edition Windows 10 x64 Edition回复
  5. #5

    成功挂载GoogleDrive网盘到VPS,为什占用vps空间?

    laoshu6年前 (2018-03-23) Firefox 57.0 Firefox 57.0 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 怎么可能会占用你VPS本地的空间。

      LALA6年前 (2018-03-23) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
  6. #6

    装Rclone的时候wget的链接不是那个,是这个
    https://downloads.rclone.org/v1.39/rclone-v1.39-linux-amd64.zip

    迷路的6年前 (2018-03-24) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 很凑巧,rclone的官网就在前两天改版了,所以下载地址也变了。。。

      LALA6年前 (2018-03-24) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
      • rclone更新到了V1.40,挂载的一些步骤也变了

        Lvv6年前 (2018-03-25) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 7 x64 Edition Windows 7 x64 Edition回复
        • 是,GoogleDrive改成11了,另外中间多了几个选项,可以直接回车跳过,如果不熟悉的话可以继续用1.39。

          LALA6年前 (2018-03-25) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
          • 同挂载后上传文件到挂载盘会占用本地内存,只有同步功能,貌似不能单独作为一个独立盘使用

            Lvv6年前 (2018-03-25) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 7 x64 Edition Windows 7 x64 Edition
          • 应该是vfs-cache-mode的锅,可能文件缓存到本地硬盘了,ls -la看看,我记得有个隐藏目录下面是存放的缓存文件,可以直接删掉。

            LALA6年前 (2018-03-25) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition
          • 我也觉得是缓存,重启vps取消挂载之后会减少一部分占用,我找找

            Lvv6年前 (2018-03-25) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 7 x64 Edition Windows 7 x64 Edition
          • :cool: ojbk找到了/root/.cache/rclone/vfs/

            Lvv6年前 (2018-03-25) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 7 x64 Edition Windows 7 x64 Edition
  7. #7

    2018/03/25 23:39:58 mount helper error: fusermount: fuse device not foun

    乌班图系统,ovz,叫售后开fuse了还是出错。是和别人合租的,不想重装

    kenshin6年前 (2018-03-25) Google Chrome 65.0.3325.109 Google Chrome 65.0.3325.109 Android 4.4.4 Android 4.4.4回复
    • 还是开了一个小鸡装centOS7再按教程容易操作,咸鱼一点都不懂。

      kenshin6年前 (2018-03-31) Google Chrome 65.0.3325.109 Google Chrome 65.0.3325.109 Android 4.4.4 Android 4.4.4回复
  8. #8

    又来求助博主了,上次弄好以后没管,df -h查看显示df: ‘/lala/gdrive’: Transport endpoint is not connected
    又重新挂载了一次,过了半小时左右又断开了,求博主支援 :cry:

    陆伯言6年前 (2018-04-01) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 疑难杂症可能我也解决不了,毕竟我没遇到过这种问题,我也不知道怎么解决啊。。。

      LALA6年前 (2018-04-01) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
  9. #9

    Failed to execute operation: Bad message

    博主 请问这怎么解决呢···· 好久了愁眉 谢谢

    养鸽人6年前 (2018-04-01) UC Browser 6.2.3964.2 UC Browser 6.2.3964.2 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 我没碰到过这种问题,我解决不了。。。

      LALA6年前 (2018-04-01) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
      • 同样的问题,一些无奈 :cry:

        lyviecs6年前 (2018-07-08) Google Chrome 68.0.3440.42 Google Chrome 68.0.3440.42 Windows 10 x64 Edition Windows 10 x64 Edition回复
      • 还是不知道为什么出现这个,不过按照网上的方法运行ln -s /usr/lib/systemd/system/rclone.service /etc/systemd/system/multi-user.target.wants/rclone.service命令建了一个映射,能够开机自启了

        lyviecs6年前 (2018-07-27) Google Chrome 68.0.3440.68 Google Chrome 68.0.3440.68 Windows 10 x64 Edition Windows 10 x64 Edition回复
  10. #10

    https://downloads.rclone.org/rclone-v1.39-linux-amd64.zip
    404了

    梦回剑雨6年前 (2018-04-02) Google Chrome 65.0.3325.181 Google Chrome 65.0.3325.181 Windows 10 x64 Edition Windows 10 x64 Edition回复
  11. #11

    博主你好,冒昧将您的博客放到我的tg群 [ Google Drive 无限容量](https://t.me/google_drive) 了,可以么?

    CodyDoby6年前 (2018-05-13) Google Chrome 66.0.3359.158 Google Chrome 66.0.3359.158 Android 7.1.1 Android 7.1.1回复
    • 可以,放吧。

      LALA6年前 (2018-05-14) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
  12. #12

    博主你好,挂载大概要多久。我都输入最后命令10分钟都还没有反应

    奇葩兔6年前 (2018-05-19) Microsoft Edge 17.17134 Microsoft Edge 17.17134 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 正常应该是几秒钟就好了,10分钟都没反应肯定是哪里出问题了。

      LALA6年前 (2018-05-19) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
  13. #13

    ./rclone mount lala: /lala/gdrive –allow-other –allow-non-empty –vfs-cache-mode writes
    这条命令最后应该加个“ &”(空格&),我说怎么最后一直没反应。。

    J0ker6年前 (2018-05-22) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 文章内用的screen,不需要加。

      LALA6年前 (2018-05-22) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
      • 我是按照文章的步骤来的,用的screen,但是最后一步一直没反应,按CTRL+C停止后加上&再回车就正常了

        J0ker6年前 (2018-05-22) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 10 x64 Edition Windows 10 x64 Edition回复
        • 那可能是因为你在screen里面执行后没有按组合键Ctrl+A+D切换出来,你直接在screen里面按Ctrl+C就相当于把这条命令给终止了。
          既然你选择加&号运行rclone,那就没必要在screen里面运行了,直接原始的shell里面运行就行了。

          LALA6年前 (2018-05-23) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
          • 就是说新建了screen之后要切出来再执行后面那条命令吗,我太小白了没意识到。。

            J0ker6年前 (2018-05-24) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 10 x64 Edition Windows 10 x64 Edition
          • 嗷我懂了,在screen里执行命令后没反应是正常的,直接切出来就好了,此时输入df -h可以看到是正常挂载了的,感谢大佬

            J0ker6年前 (2018-05-24) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 10 x64 Edition Windows 10 x64 Edition
  14. #14

    运行了几天之后今天突然发现filebrowser打开之后显示服务器出现了点问题,然后连上vps使用systemctl status rclone结果返回
    ● rclone.service – rclone
    Loaded: loaded (/usr/lib/systemd/system/rclone.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Sat 2018-05-26 07:50:43 UTC; 20min ago
    Process: 15422 ExecStart=/usr/bin/rclone mount hnc277: /hnc277/gdrive –allow-other –allow-non-empty –vfs-cache-mode writes (code=exited, status=1/FAILURE)
    Main PID: 15422 (code=exited, status=1/FAILURE)

    May 26 07:50:42 vultr.guest systemd[1]: Started rclone.
    May 26 07:50:42 vultr.guest systemd[1]: Starting rclone…
    May 26 07:50:43 vultr.guest rclone[15422]: 2018/05/26 07:50:43 Failed to wri…e
    May 26 07:50:43 vultr.guest systemd[1]: rclone.service: main process exited,…E
    May 26 07:50:43 vultr.guest systemd[1]: Unit rclone.service entered failed s….
    May 26 07:50:43 vultr.guest systemd[1]: rclone.service failed.
    Hint: Some lines were ellipsized, use -l to show in full.
    然后df -h看了下vps的硬盘全满了,根本挂不上gd啊,请教下这个问题该咋解决。。

    J0ker6年前 (2018-05-26) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 7 x64 Edition Windows 7 x64 Edition回复
    • 我估计是缓存文件把本地硬盘撑爆了,在你的root目录下,ls -la查看,应该有一个.cache的隐藏目录,进去看看这些文件是不是你曾经上传过的文件,是的话可以全部删除。
      然后你把挂载命令的这段去掉,重新挂载一遍:–vfs-cache-mode writes

      LALA6年前 (2018-05-26) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
      • .cache目录里ls -la之后只有之前下载的aria和rclone,rm -rf *之后重新挂载了,但是df -h结果还是爆满:
        Filesystem Size Used Avail Use% Mounted on
        /dev/vda1 20G 20G 0 100% /
        devtmpfs 234M 0 234M 0% /dev
        tmpfs 245M 0 245M 0% /dev/shm
        tmpfs 245M 8.3M 236M 4% /run
        tmpfs 245M 0 245M 0% /sys/fs/cgroup
        hnc277: 1.0P 0 1.0P 0% /hnc277/gdrive
        tmpfs 49M 0 49M 0% /run/user/0
        我也觉得是缓存爆了,可是不知道问题具体出在哪,求解惑0.0

        J0ker6年前 (2018-05-26) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 7 x64 Edition Windows 7 x64 Edition回复
        • 那就只能在/dev/vda1里面自己翻目录了。。。

          LALA6年前 (2018-05-26) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
          • 我试试去 :cry:

            J0ker6年前 (2018-05-26) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 7 x64 Edition Windows 7 x64 Edition
          • 从根目录开始挨个du -sh *,最后发现是之前添加的一个离线任务文件太大了,超过了vps的容量,虽然下载失败了,但是已经下下来的文件还在downloads目录里,给填满了。。 :eek:

            J0ker6年前 (2018-05-26) Google Chrome 58.0.3029.61 Google Chrome 58.0.3029.61 Windows 7 x64 Edition Windows 7 x64 Edition
          • 233,看来你需要一个大盘鸡。

            LALA6年前 (2018-05-27) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition
  15. #15

    博主辛苦了,跟着你的教程搞好了gdrive,想问下你的最后的rclone挂载命令同样适用于onedrive的挂载吗,我已经在rclone里配置好了命名为one并新建了/lala/one文件夹,用./rclone mount one: /lala/one –allow-other –allow-non-empty –vfs-cache-mode writes时,提示create file system for “one:”: failed to get root: unauthenticated: Must be authenticated to use ‘/drive’ syntax.

    daivd6年前 (2018-06-01) Google Chrome 66.0.3359.181 Google Chrome 66.0.3359.181 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 我没有用rclone挂载过onedrive这个不是很清楚。。。

      LALA6年前 (2018-06-02) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
  16. #16

    :arrow: 执行到./rclone mount lala: /lala/gdrive –allow-other –allow-non-empty –vfs-cache-mode writes

    这步骤以后按了没反应……

    漆黑6年前 (2018-06-03) Google Chrome 66.0.3359.117 Google Chrome 66.0.3359.117 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 没反应就对了呀,有反应才是不正常。

      LALA6年前 (2018-06-04) TheWorld Browser TheWorld Browser Windows 7 x64 Edition Windows 7 x64 Edition回复
      • 然后要怎么回去看挂载情况呀

        shakechan6年前 (2018-06-23) Google Chrome 67.0.3396.87 Google Chrome 67.0.3396.87 Windows 10 x64 Edition Windows 10 x64 Edition回复
      • 步骤没问题。。返回发现没挂载上是什么情况。。

        shakechan6年前 (2018-06-23) Google Chrome 67.0.3396.87 Google Chrome 67.0.3396.87 Windows 10 x64 Edition Windows 10 x64 Edition回复
  17. #17

    博主为什么这样搭建的方法不能用rclone copy等命令进行增量备份呢?

    daivd6年前 (2018-06-18) Google Chrome 67.0.3396.87 Google Chrome 67.0.3396.87 Windows 10 x64 Edition Windows 10 x64 Edition回复
  18. #18

    bash: ./rclone: is a directory

    这怎么解决。。。。。。 :cool:
    还有个国内阿里云怎么绑定,到了授权码那应该是被墙了

    小虎牙6年前 (2018-07-30) Google Chrome 67.0.3396.99 Google Chrome 67.0.3396.99 Windows 10 x64 Edition Windows 10 x64 Edition回复
  19. #19

    挂载后报错,博主求解决!
    2018/08/04 09:29:18 mount helper error: fusermount: fuse device not found, try ‘modprobe fuse’ first
    2018/08/04 09:29:18 Fatal error: failed to mount FUSE fs: fusermount: exit status 1

    枭灬雄6年前 (2018-08-04) Sogou Explorer Sogou Explorer Windows 7 x64 Edition Windows 7 x64 Edition回复
  20. #20

    Command “/usr/bin/python2 -u -c “import setuptools, tokenize;__file__=’/tmp/pip-install-feGHzQ/gevent/setup.py’;f=getattr(tokenize, ‘open’, open)(__file__);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, __file__, ‘exec’))” install –record /tmp/pip-record-zfnBFP/install-record.txt –single-version-externally-managed –compile” failed with error code1 in /tmp/pip-install-feGHzQ/gevent/
    求解,装gdfs的时候出现的 :cry:

    anyong6年前 (2018-10-13) Unknown Unknown Unknown Unknown回复

分享创造快乐

广告合作资源投稿