Mount a Gdrive

Example lead - highlighted near the title

Mount a Gdrive
Page content

Installing Google Drive Ocamlfuse on Ubuntu 18.04

[TOC]

To install the Google Drive Ocamlfuse run the following commands in that order

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

Once successfully installed, authorize google-drive-ocamlfuse client with your desired Google account using the following command.

# google-drive-ocamlfuse

This is going to pop open a page on your browser where Google will request you to choose a Gmail account to continue with the setup

This is going to pop open a page on your browser where Google will request you to choose a Gmail account to continue with the setup

img

Next, Gdfuse will request access to your account.

img

Click on the ‘Allow’ button to allow google-drive-ocamlfuse to access your Google Drive.

You’ll then be prompted for your password

img

You will then be asked to choose the account to use

img

Finally, create a mount point in your home directory and mount the directory

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

Automounting

Cody Benkoski edited this page on Jun 30 · 17 revisions

There is a way to automount the filesystem at boot, although it’s not very straightforward. After completing the authorization process, you can follow the following steps, to enable mounting your Google Drive using the mount command. Be sure to replace $USERNAME with your actual username.

  1. Create a shell script named gdfuse in /usr/bin (as root) with this content:
#!/bin/bash

su $USERNAME -l -c "google-drive-ocamlfuse -label $1 $*"
exit 0
  1. Give it the exec permission:
$ sudo chmod +x /usr/bin/gdfuse
  1. Create a mountpoint (e.g. ~/gdrive):
$ mkdir ~/gdrive
  1. Edit /etc/fstab adding a line like this. Be sure to replace $USERNAME with your actual username.
gdfuse#default  /home/$USERNAME/gdrive     fuse    uid=1000,gid=1000,allow_other,user,_netdev     0       0

If uid and gid of your user are different from 1000, modify the above line accordingly. Note that the “user” option implies noexec, nosuid and nodev. To be able to execute scripts etc. in gdrive, append “,exec” to “user”.

The _netdev option is to make sure the filesystem is mounted after the network becomes available (see man 8 mount)

And then you can use mount to mount your Google Drive. Maybe you will be asked for your password.

$ mount ~/gdrive

If you have another account you can mount it specifying the label after the # character. E.g.:

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