CFanのBlog

A good day for snow-viewing

Mounting Google Drive as a local directory

Translated from the Chinese original by Claude.

The VPS I’m using is about to be shut down, and while backing it up I found that uploading to Baidu Netdisk was painfully slow, while Google’s was a good deal faster, so I went looking for a script to upload to Google Drive and came across this handy thing…
Google-drive-ocamlfuse (ocamlfuse) works with the contents of Google Drive through the Google Drive API, and can map Google Drive straight onto a local directory. It’s a bit of a faff to install, though…

Installing ocamlfuse

On Debian/Ubuntu, just run these few commands:

  1. Add the author’s repository
  2. Update the package list
  3. Install google-drive-ocamlfuse

For other ways to install it, see the official wiki

Getting access to the Google Drive API

If you have a desktop, you can just run this in a terminal

and a browser window pops up for you to authenticate.

Without a desktop you need headless mode

First create a project at https://console.cloud.google.com/

QQ screenshot 20160523000512

Once it’s created, go to the API Manager and enable the Drive API

QQ screenshot 20160523000716

 

Create OAuth2 credentials

QQ screenshot 20160523000912

For the application type choose Other, give it any name you like, and you’ll get an API secret and a client ID.

Authorising google-drive-ocamlfuse to access Google Drive

Enter the following command

Just replace CLIENT_ID and SECRET with the ones you’ve just got. LABEL is there to tell accounts apart and can be anything you like; the default is default.

It then gives you a URL: open it in a browser, authenticate, and paste in the verification code you get back.

Mounting Google Drive

Finally, mount it with the following command, and that’s it.

Leave a comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.