Pages

How to mount Google Drive on Linux

A short tutorial showing you how to install google-drive-ocamlfuse on a Linux Mint 17 system to access the contents of your Google Drive

Introduction
Most linux users who have tried to access their Google Drive contents will realise that there isn't an official Drive client for Linux yet - despite the wide availability of Drive clients for Windows and for Android devices.  Luckily there are alternatives available and this article shows you how to install google-drive-ocamlfuse on a system running Mint-17.

What is google-drive-ocamlfuse?
Technically, google-drive-ocamlfuse is a FUSE filesystem backed by Google Drive, written in OCaml. It lets you mount your Google Drive on Linux in a folder you choose during setup.  It has the following features:
  • Full read/write access to ordinary files and folders
  • Read-only access to Google Docs, Sheets, and Slides (exported to configurable formats)
  • Multiple account support
  • Duplicate file handling
  • Access to trash (.Trash directory)

The version I installed at the time I wrote this was google-drive-ocamlfuse 0.5.16.  The software is hosted on GitHub and more information is available on the project's GitHub page.

Installation instructions
The author has set up a .deb repository for installation under Ubuntu 14.04, 12.04 etc.  This means that any ubuntu derivatives (such as Mint) can use the same repository to install google-drive-ocamlfuse. To do this, open a Terminal window and enter the commands below
$ sudo add-apt-repository ppa:alessandro-strada/ppa $ sudo apt-get update $ sudo apt-get install google-drive-ocamlfuse
Once this has completed you need to configure google-drive-ocamlfuse to suit your system. First run google-drive-ocamlfuse without any parameters
$ google-drive-ocamlfuse
This command will create a folder (~/.gdfuse/default) containing the configuration files for the application and will also open a web browser asking you to confirm that you want the application to access your Google Drive.

Once access has been authorised the web browser will close and you will be returned to your Terminal window. You can then mount your Google Drive folder in your filesystem. In this tutorial I decided to keep things simple, so I created a Drive folder in my home area and configured google-drive-ocamlfuse to mount my Google Drive at this point.
$ mkdir -p ~/Drive $ google-drive-ocamlfuse ~/Drive
When you've done this you should see the files appearing as part of your new ~/Drive folder, depending on the speed of your Internet connection. Now be aware that there are two things you need to understand in order to get the best from this tutorial:
  • The first is that your Google Drive is mapped from the web. The files in your Google Drive stay in the cloud and are not synchronised with your local hard drive. This means that files take a while to open and close, as they are literally coming in from Google's servers. It also means that no Internet access equals no access to your Google Drive files. You can get round this by using rsync to sync or mirror another local folder with your Drive folder but that is a tutorial for another day.
  • The second is that the mount of your Google Drive is lost after a reboot or if you log out of your session. To get around this I added a couple of steps to the installation instructions you normally find so that your Google Drive reappears at the start of a new session.
Automounting your Google Drive
Open a Terminal session and create a shell script named gdfuse in /usr/bin.
$ sudo nano /usr/bin/gdfuse
Copy and paste the following lines into the script changing $username to match your username:

#!/bin/bash

su $username -l -c "google-drive-ocamlfuse -label $1 $*"
exit 0


Give the new script exec permissions
$ sudo chmod +x /usr/bin/gdfuse
Now edit /etc/fstab
$ sudo nano /etc/fstab
And add the following lines like this: (but remember to change uid and gid and /path/to/your/gdrive in the line below to the values of your username and of the path to your Google Drive folder accordingly.)

# Google Drive Automount
gdfuse#default /path/to/your/gdrive fuse uid=1000,gid=1000 0 0


You can then use mount to mount your Google Drive (again, with your Google Drive path in place of my example):
$ sudo mount /path/to/your/gdrive
That should be it. To test this, reboot the workstation and log back in again. After your desktop is ready you should see the Drive folder once more in place and if you click on the folder your Google Drive files should be visible again.

One final touch I did was to alter the file icon for my Drive folder so that it looked like a Google Drive folder.  I downloaded a suitable Drive icon from the web and adjusted the Properties of my Drive folder so that it showed the Google Drive icon instead.


I hope this tutorial has been of use to you. The steps involved took about ten minutes to complete and finally I have access to my Google Drive contents from my Mint workstation.