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:
- Add the author’s repository
1sudo add-apt-repository ppa:alessandro-strada/ppa - Update the package list
1sudo apt-get update - Install google-drive-ocamlfuse
1sudo apt-get 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
1 | google-drive-ocamlfuse |
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/
Once it’s created, go to the API Manager and enable the Drive API
Create OAuth2 credentials
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
1 | google-drive-ocamlfuse -headless -label LABEL -id CLIENT_ID -secret SECRET |
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.
1 2 | Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=…….apps.googleusercontent.com&redirect_uri=……;scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force Please enter the verification code: |
Mounting Google Drive
Finally, mount it with the following command, and that’s it.
1 | google-drive-ocamlfuse -label LABEL MOUNT_DIR |






