Mount Google Drive in Linux with Google Drive Ocamlfuse client

Most of us have gmail account for email communication, moreover everyone use google drive as well to store documents.

Google drive is a traditional cloud storage and offering 15GB for free of cost.

It allows user to edit documents, spreadsheets, and presentations, share any documents over internet anywhere in the world, and synchronization.

This will help you to get a documents whenever you want (on demand) since we can access the drive anywhere, even we can edit the docs from mobile as well. You don’t want to carry a physical hard Drive and USB flash Drive.

Still there is no official google drive client for Linux. So today we are going to teach you about Google Drive Ocamlfuse app, it’s unofficial google drive client which allows us to sync the local files into google drive.

We had already written few articles in our website about google drive mapping with Linux.

If you would like to check those, navigate to the following link.

GNOME desktop offers easy way to Integrate Google Drive Using Gnome Nautilus File Manager in Linux without headache.

Also, you can give a try with DriveSync – Google Drive Client.

Google Drive Ocamlfuse is a FUSE-based file system backed by Google Drive, written in OCaml. It lets you mount your Google Drive on Linux and you can access your files and folders, either via command line or GUI file manager.

Google Drive Ocamlfuse 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)
  • Unix permissions and ownership
  • Symbolic links
  • Read-ahead buffers when streaming
  • Accessing content shared with you (requires configuration)

How to install Google Drive Ocamlfuse on Linux

As we told in the beginning of the article, there is no official client, so we need to install from third party repository.

For Ubuntu/LinuxMint users add below PPA and use apt-get command or apt command to install Google Drive Ocamlfuse.

$ sudo add-apt-repository ppa:alessandro-strada/ppa
$ sudo apt-get update
$ sudo apt-get install google-drive-ocamlfuse

For Arch Linux based systems, Google Drive Ocamlfuse is available in AUR repository, so use either Yaourt or Packer to install it.

$ yarout -S google-drive-ocamlfuse
$ packer -S google-drive-ocamlfuse

For Fedora users add below copr repository and use dnf command to install Google Drive Ocamlfuse.

$ sudo dnf copr enable sergiomb/google-drive-ocamlfuse
$ sudo dnf install google-drive-ocamlfuse

For CentOS/RHEL 7 users add below copr repository and use Yum command to install Google Drive Ocamlfuse. Make sure you have to install/enable EPEL repository too in order to install required dependenceI packages.

$ sudo yum-config-manager --add-repo
$ sudo yum makecache
$ sudo yum install ocamlfuse

It can be verified through the following command.

# yum --disablerepo="*" --enablerepo="sergiomb-google-drive-ocamlfuse" list available | more
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
ocaml-camlidl.x86_64          1.05-34.el7.centos sergiomb-google-drive-ocamlfuse
                              1.05-34.el7.centos sergiomb-google-drive-ocamlfuse
ocaml-camlidl-devel.x86_64    1.05-34.el7.centos sergiomb-google-drive-ocamlfuse
ocamlfuse.x86_64              2.7.1-6.cvs5.el7   sergiomb-google-drive-ocamlfuse
ocamlfuse-debuginfo.x86_64    2.7.1-6.cvs5.el7   sergiomb-google-drive-ocamlfuse

For openSUSE 42.3 users add below repository and use Zypper Command to install Google Drive Ocamlfuse.

$ zypper addrepo
$ zypper refresh
$ zypper install google-drive-ocamlfuse

For openSUSE 42.2 users add below repository and use Zypper Command to install Google Drive Ocamlfuse.

$ zypper addrepo
$ zypper refresh
$ zypper install google-drive-ocamlfuse

How to configure Google Drive Ocamlfuse

Once you have successfully installed Google Drive Ocamlfuse. First, you need to authorize google-drive-ocamlfuse client with your desired Google account using following command.

$ google-drive-ocamlfuse

It will open a google sign-in page in default web browser. Enter your credentials then hit Sign in button.

Hit Allow button to allow google-drive-ocamlfuse to access your Google Drive.

once again, it will ask your Password. Now, Allow gdfuse OAuth2 application to access your Google account.

Finally create a mount point called google-drive in your home directory and mount it.

$ mkdir ~/google-drive
$ google-drive-ocamlfuse ~/google-drive

You can verify the same with df command.

$ df -h

Alternatively, you can verify through file manager.

To test Auto Sync, we are going to upload below file.

The same has been verified in Web browser.

To add more than one account, use the following format. By default the configuration file is first created in ~/.gdfuse/default/config (or ~/.gdfuse/label/config if a label was specified on the command line).

$ google-drive-ocamlfuse -label label [mountpoint]

For testing purpose, we are going to mount one more account. For that create a new mount point then mount it. In my case, we have created a mount point called google-drive-1 in our home directory. Do the same above steps after running the below command to mount successfully.

$ mkdir ~/google-drive-1
$ google-drive-ocamlfuse -magi label ~/google-drive-1

Alternatively, you can verify through file manager. Both account got mounted successfully.

To unmount the Google Drive, run the following command.

$ fusermount -u ~/google-drive

To auto mount Google Drive in Linux. Create a shell script named gdfuse in /usr/bin (as root) with this content.

$ sudo vi /usr/bin/gdfuse

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

Set executable permission.

$ sudo chmod +x /usr/bin/gdfuse

Create a mount point.

$ mkdir ~/gdrive

Assign ownership to user.

$ chown magi.magi ~/gdrive

Add the below entries to /etc/fstab file at the bottom. Make sure the uid & gid should be the above user’s. Finally save and exit.

# vi /etc/fstab

gdfuse#account2  /home/$USERNAME/gdrive2     fuse    uid=1000,gid=1000     0       0

Run the following command to mount your Google Drive.

$ mount ~/gdrive

3 Comments on “Mount Google Drive in Linux with Google Drive Ocamlfuse client”

  1. Thanks for sharing this!
    In KDE Neon based on Ubuntu 16.04, I cannot use the ppa:

    $ add-apt-repository ppa:alessandro-strada/ppa
    Cannot add PPA: ‘ppa:~alessandro-strada/ubuntu/ppa’.
    ERROR: ‘~alessandro-strada’ user or team does not exist.

    $ cat /etc/*release*
    DISTRIB_DESCRIPTION=”KDE neon User Edition 5.10″
    NAME=”KDE neon”
    ID_LIKE=”ubuntu debian”
    PRETTY_NAME=”KDE neon User Edition 5.10″

    Any idea please?

  2. What is the point when Google Drive is being discontinued at the end of the current year.

    Do you have any information on the alternative and if there is a linux version, I would rather not resort to drop box.

Leave a Reply

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