Total Pageviews

Saturday 23 July 2016

教你用 google-drive-ocamlfuse 在 Linux 上挂载 Google Drive

How to mount your Google Drive on Linux with google-drive-ocamlfuse

If you're looking for an easy way to mount your Google Drive folders to a Linux box, Jack Wallen shows you how with the help of google-drive-ocamlfuse. 

Google has yet to release a Linux version of its Google Drive app, though there are plenty of ways to gain access to your Drive files from Linux.
If you prefer a GUI tool, you've got Insync. If you prefer the command line, there are tools such as Grive2 and the incredibly easy to use FUSE-based system written in Ocaml. I'll show how to use the latter to mount your Google Drive account on your Linux desktop. Although it's done via the command line, you'll be surprised at how easy it is to pull off. It's so easy, anyone can do it.
This system features:
  • Full read/write access to ordinary files/folders
  • Read-only access to Google Docs, sheets, and slides
  • Access to your Drive's Trash (.trash) Directory
  • Duplicate file handling
  • Support for multiple accounts
Let's walk through the installation and setup of google-drive-ocamlfuse on a Ubuntu 16.04 desktop so you can gain access to your Drive files.

Installation

  1. Open a terminal window.
  2. Add the necessary PPA with the command sudo add-apt-repository ppa:alessandro-strada/ppa.
  3. When prompted, type your sudo password and hit Enter.
  4. Update app with the command sudo apt-get update.
  5. Install the software by issuing the command sudo apt-get install google-drive-ocamlfuse.

Authorization

The next step is to authorize google-drive-ocamlfuse so it will have access to your Google account. To do this, go back to the terminal window and issue the command google-drive-ocamlfuse. This command will open a browser window that will either prompt you to log into your Google account or, if you're already logged in, ask you to allow google-drive-ocamlfuse access to your Google account. If you've not logged in, do so and then click Allow. The next window (which appeared on a Ubuntu 16.04 desktop, but not an Elementary OS Freya desktop) will ask you to grant permission for both gdfuse and OAuth2 Endpoint to access your Google account. Click Allow again. The next browser screen will inform you to wait until the authorization tokens have downloaded; you can minimize the browser at this point. When your terminal prompt returns (Figure A), you know the tokens have been downloaded, and you're ready to mount.

Mounting your Google Drive

Before you mount your Google Drive, you must create a folder to serve as the mount point. From the terminal, issue the command mkdir ~/google-drive to create a new folder in your home directory. Finally, issue the command google-drive-ocamlfuse ~/google-drive to mount your Google Drive to the google-drive folder.

At this point, you should see your Google Drive files/folders populate in the google-drive folder. You can work with Google Drive as if it were a local folder system.
When you want to unmount the google-drive folder, issue the command fusermount -u ~/google-drive.

It's no GUI, but it works like a champ

I find this particular system really handy to use. It's incredibly fast at syncing with Google Drive, and it can make for an elegant means of backing up your Google Drive account locally.
Give google-drive-ocamlfuse a go, and see what kind of magic you can make with it.

Also see

from http://www.techrepublic.com/article/how-to-mount-your-google-drive-on-linux-with-google-drive-ocamlfuse/
-------------

编译自:http://www.techrepublic.com/article/how-to-mount-your-google-drive-on-linux-with-google-drive-ocamlfuse/
原创:https://linux.cn/article-7604-1.html

Google 还没有发行 Linux 版本的 Google Drive程序,尽管现在有很多方法从 Linux 中访问你的 GOOGLE Drive。

如果你喜欢界面化的工具,你可以选择 Insync。如果你喜欢用命令行,有很多像 Grive2 这样的工具,以及更容易使用的以 Ocaml 语言编写的基于 FUSE 的文件系统。我将会用后面这种方式演示如何在 Linux 桌面上挂载你的 Google Drive。尽管这是通过命令行完成的,但是它的用法会简单到让你吃惊。它太简单了以至于谁都能做到。
这个系统的特点:
  • 对普通文件/文件夹有完全的读写权限
  • 对于 Google Docs,sheets,slides 这三个应用只读
  • 能够访问 Drive 回收站(.trash)
  • 处理重复文件功能
  • 支持多个帐号
让我们接下来完成 google-drive-ocamlfuse 在 Ubuntu 16.04 桌面的安装,然后你就能够访问云盘上的文件了。

安装

  1. 打开终端。
  2. 用 sudo add-apt-repository ppa:alessandro-strada/ppa 命令添加必要的 PPA
  3. 出现提示的时候,输入你的 root 密码并按下回车。
  4. 用 sudo apt-get update 命令更新应用。
  5. 输入 sudo apt-get install google-drive-ocamlfuse 命令安装软件。

授权

接下来就是授权 google-drive-ocamlfuse,让它有权限访问你的 Google 账户。先回到终端窗口敲下命令 google-drive-ocamlfuse, 这个命令将会打开一个浏览器窗口,它会提示你登陆你的 Google 帐号或者如果你已经登陆了 Google 帐号,它会询问是否允许 google-drive-ocamlfuse 访问 Google 账户。如果你还没有登录,先登录然后点击“允许”。接下来的窗口(在 Ubuntu 16.04 桌面上会出现,但不会出现在 Elementary OS Freya 桌面上)将会询问你是否授给 gdfuse 和 OAuth2 Endpoint 访问你的 Google 账户的权限,再次点击“允许”。然后出现的窗口就会告诉你等待授权令牌下载完成,这个时候就能最小化浏览器了。当你的终端提示如下图一样的内容,你就能知 道令牌下载完了,并且你已经可以挂载 Google Drive 了。

挂载 Google Drive

在挂载 Google Drive 之前,你得先创建一个文件夹,作为挂载点。在终端里,敲下mkdir ~/google-drive命令在你的家目录下创建一个新的文件夹。最后敲下命令google-drive-ocamlfuse ~/google-drive将你的 Google Drive 挂载到 google-drive 文件夹中。
这时你可以查看本地 google-drive 文件夹中包含的 Google Drive 文件/文件夹。你可以把 Google Drive 当作本地文件系统来进行工作。
当你想卸载 google-drive 文件夹,输入命令 fusermount -u ~/google-drive

没有 GUI,但它特别好用

我发现这个特别的系统非常容易使用,在同步 Google Drive 时它出奇的快,并且这可以作为一种本地备份你的 Google Drive 账户的巧妙方式。(LCTT 译注:然而首先你得能使用……)
试试 google-drive-ocamlfuse,看看你能用它做出什么有趣的事.