centos7 vps 挂载谷歌硬盘当本地磁盘使用教程

230次阅读
没有评论

不支持 OpenVZ 架构

该教程并非很详细,在挂载的过程中会遇到一些错误,记录了遇到的各种错误及解决方案

使用的是 vultr centos 7。

1、 原理

Linux 下挂载网盘是利用用户空间文件系统(Filesystem in Userspace)为基础,基于 Fuse 的其实有很多了。网上也有一大堆,我就以 GDriveFS 为例子来讲解一下如何使用 Linux 挂载网盘,你可以在 Git 找到其他网盘挂载的代码,我以这个为例的原因仅仅是他是 Python 的。。。

先看以下我在 vps 挂载后的结果。。

centos7 vps 挂载谷歌硬盘当本地磁盘使用教程

2、 挂载过程

我这里只有 Centos 的小鸡。我就用它来讲解一下吧

1)        GDriveFS 是 Python 2.7 开发的,需要你安装 Python2.7 以上版本,很多小鸡 Centos 6.x 自身带的的就是 2.6.6.首先要做的就是升级到 2.7 以上。。

如何升级请参考 http://blog.csdn.net/jcjc918/article/details/11022345 ,我就不转帖了。

https://blog.fazero.me/2016/10/13/centos-update-python/

借用一下 fazero 的一键升级脚本(偷懒)

yum 升级后问题自行修改吧。

2)        安装 GDriveFS

https://github.com/dsoprea/GDriveFS 有完整的教程,我来汉化一下,顺便提醒以下要点。

首先需要安装 libfuse 库才能运行,官方省略了这个步骤,我这里加上。

64 位的请运行

yum install fuse-devel.x86_64 fuse.x86_64

32 位安装

yum install fuse-devel.i686 fuse.i686

运行

pip install gdrivefs

【注 1】【注 2】【注 3】,请解决完以上几个问题后,再运行该代码。

安装完成后首先运行

gdfstool auth -u

结果是

To authorize FUSE to use your Google Drive account, visit the following URL to produce an authorization code:

https://accounts.google.com/o/oauth2/auth

scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.file&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=626378760250.apps.googleusercontent.com&access_type=offline

拷贝你终端出现网址(不是上面的网址)到浏览器,会出现授权页面,

centos7 vps 挂载谷歌硬盘当本地磁盘使用教程

授权后会出现一个文本框,里面就是授权码。拷贝这个授权码(一定要完整)

centos7 vps 挂载谷歌硬盘当本地磁盘使用教程

gdfstool auth -a /var/cache/gdfs.creds “4/WUsOa-m2RhgQtf9_NFAMMbRC.cj4LQYdXfshQV0ieZDAqA-C7ecwI”

引号内替换成你的授权码。

出现【Authorization code recorded】.表示成功记录了。

3) 挂载网盘

mkdir /mnt/gdrivefs

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

其他挂载方式请看 Git。

然后享用你的大网盘吧。

4)注意事项

sudo gdfs -o big_writes /var/cache/gdfs.creds /mnt/gdrivefs 可实现 64K 块,读写加快,但是苹果不支持! 权限等问题在 Git 上自己看吧,不满意的自行修改 Python 代码。

BTW 。

1、OSX 下有很多可视化的工具,比如 Expandrive 。其他的请看 http://alternativeto.net/software/expandrive 基本都是收费的

2、Google Drive Api’s is. 1,000,000,000 requests/day.  Default Per-user limit is (you can increase it) 10 requests/second/user

Google drive 访问是有限制的,自用不存在,想开放,做好本地 cache,也能用

 

注 1:出现错误:【pip: command not found】,解决:

yum -y install epel-release

yum -y install python-pip

yum clean all

注 2 出现提示【You should consider upgrading via the ‘pip install –upgrade pip’ command.】,解决

pip install –upgrade pip

注 3 出现错误【error: command ‘gcc’ failed with exit status 1】,解决

yum -y install gcc gcc-c++ kernel-devel

yum -y install python-devel libxslt-devel libffi-devel openssl-devel

 
吾爱互联
版权声明:本站原创文章,由 吾爱互联 2020-01-05发表,共计2153字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
载入中...