Pages

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

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.

There but for the grace...

Good Times...
We all have Good Days and we all have Bad Days.  I'd been having a Good Day so far - got stuff I wanted done in the garden; photographed a Sparrowhawk; cleaned the car and had a surprise visit from my daughter bearing home-baked muffins!

I had also finished copying all the files from my old server (running ClarkConnect) to my new server (running Amahi) and I was ready to decommission the old server.  All was going well.  I took apart the old server in readiness for fully decommissioning it and literally had a pile of disks, cables, a motherboard and a case in my workshop.

Then my Significant Other asked to go online and check our bank accounts with our accounts program, something she regularly does as a check and a monitor of how we are doing.

Bad Times...
Not good. The accounts program she uses couldn't find any datafiles!  All of a sudden the day was starting to look very far from good.  Looking at the files I had copied to the new server showed that everything else was copied across and was safe - including a two month old copy of our accounts - but not the up to date one she had been using.  Puzzling.  A bit of checking on her computer showed that I had copied the data two months ago but had not adjusted how the accounts program accessed the files, so the accounts package expected the files to be on the old server and was still updating the old server files instead of the copy I had made on the new server.  Add to this the fact that the latest backup she had of her data was three weeks old.  "Easy enough to fix", I hear you cry, "Just copy the files again from the old server to the new".  But, if you recall, I had decommissioned the old server and it now was a pile of disks, cables, a motherboard and a case on my worktop....My heart sank.

You know I had my share...
So, prepared for the worst, I took the lid off a test computer I use for all sorts of things - an old, venerable 2GHz Athlon processor.  I added the raid controller and the server system disk to the computer and then had to guess the order I needed to connect the three identical data disks in to re-create the RAID.  I booted it, stepped through the start-up, re-configured the hardware (although this was CentOS, a linux derivative.  It did the reconfiguring; all I did was confirm each step) and watched for errors.  None.  The system booted fine; all the disks in the right order.  All I had to do was to tell it what its IP address should have been and then connect to it and copy off the data.  A quick check to make sure and everything was fine.


So it actually turned out to be a Good Day (and an extremely LUCKY day) after all.