Quantcast
Channel: 看得透又看得远者prevail.ppt.cc/flUmLx ppt.cc/fqtgqx ppt.cc/fZsXUx ppt.cc/fhWnZx ppt.cc/fnrkVx ppt.cc/f2CBVx
Viewing all articles
Browse latest Browse all 20473

CentOS桌面系统下,挂载gdrive谷歌硬盘当本地磁盘

$
0
0
原理:Linux下挂载网盘是利用用户空间文件系统(Filesystem in Userspace/fuse)为基础。

1、安装 Python 以及相关工具
本文是在CentOS7环境下测试的,CentOS6/RHEL6下需要先升级Python版本到2.7以上。而CentOS7默认源就有Python2.7。

yum install epel-release
yum install python2
yum install python-pip python-devel libxslt-devel libffi-devel openssl-devel
yum install gcc gcc-c++ kernel-devel
2、既然利用到fuse了,就要安装fuse

yum install fuse fuse-devel
3、安装GDriveFS
源码Github上有:https://github.com/dsoprea/GDriveFS
作者上传到官方pip源了,使用pip安装即可

pip install gdrivefs
安装过程中可能会出现编译错误

Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-HfrhOn/gevent/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-y4aFBQ-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-HfrhOn/gevent/
gevent_error.png
看了一下是gevent编译错误,没关系:
yum install python-gevent
4、获取Access Token
首先获取OAuth链接

gdfstool auth -u
输入上边的命令并回车后会给出一个OAuth链接,复制到浏览器中打开。
gdfs_auth.png
然后就是理所当然的登录谷歌账号
google_login.png
接着是OAuth授权
google_authorize.png
允许之后就会给出授权码,请把授权吗复制下来,后边有用。
google_auth_code.png
接着通过获取Access Token,把授权码替换成上边获得的授权码,Access Token将会保存到/var/cache/gdfs.creds

gdfstool auth -a /var/cache/gdfs.creds "授权码"
出现Authorization code recorded.即可。
authorized_success.png
5、挂载gdrive

mkdir /gdrive
gdfstool mount /var/cache/gdfs.creds /gdrive

6、检测挂载是否成功

cd /gdrive && ls
df -h

Viewing all articles
Browse latest Browse all 20473

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>