Automatically mount Google Drive with google-drive-ocamlfuse at startup?

I got the google-drive-ocamlfuse to work using this link: http://bit.ly/2pVkFHY

Now I am trying to mount the Google Drive at startup. I did add the following command to Startup Applications: “google-drive-ocamlfuse ~/googledrive”

But after I boot up, the drive is still not mounted until I enter the above mount command manually. What am I doing wrong?

Appreciate any help on this…

I got it to work by changing the mount command in Startup Applications to the following:

google-drive-ocamlfuse “/home/john/googledrive”

2 Likes

Thanks for this question and solution. really helped me out.

I could not get it done on Ubuntu 18.04 LTS. The command “google-drive-ocamlfuse ~/mygoogledrive” works on the terminal, but it does not work when added to startup applications.

I have tried different options like “google-drive-ocamlfuse /home/mygoogledrive” or google-drive-ocamlfuse “/home/mygoogledrive” (with and without quotes), but no luck.

Any help appreciated!

You needed /home/username/googledrive not /home/googledrive

You don’t need any quotes unless “/path/to/googledrive” contains any spaces or other special characters that the shell might interpret. * & $ # ! ( ) { } [ ] " ’ ` < > ? ; \ | all have meanings to the shell and need to be not onlyt quoted but escaped if you have a directory or filename that includes one of those characters.

No matter what, you don’t want quotes around the entire command. That tells the shell to look for a file named “something [space] /path/to/foo”, and try to execute it with no arguments. There is no such program of course. :slight_smile: There is a program called “something” and you want to execute THAT with an argument of “/path/to/foo”

One thing I do not know myself yet because I have not tested yet: What happens if wifi isn’t working until long after the desktop session is started? IE, you start the desktop session, but there is no network until you log in to the captive portal at a coffee shop. But google-drive-ocamlfuse was executed right away as soon as you entered your pasword. Does it fail and thats that? or does it stay running even though it failed, and retry every 60 seconds regardless if the network is up or down, and then later when the network is up it just starts working? That could be one reason this might not work for some people sometimes yet work for other people other times, purely by the luck of the timing of how fast different things happen.

… and the answer, for me, is google-drive-ocamlfuse stays running even after the initial connection attempt fails, but does NOT start functioning when the network connection starts working later. It has been over 10 minutes now since I enabled wifi and connected to the access point. I even logged in to google drive in a browser just to prove that there is working connectivity and account access to google drive.

Also I verified that neither “~” nor “${HOME}” works for the path to my home dir in /home/bkw/.config/lxsession/Lubuntu/autostart
it must be “/home/bkw/GoogleDrive” (with or without quotes in this case, because there are no spaces in that path)

(I am using lubuntu & lxde, not mate, so some other desktop environment with some other software to run session programs may behave differently.)

I guess I have to wrap google-drive-ocamlfuse in my own shell script to check for network connectivity and loop, retrying periodically, and killing also when network connectivity drops, so that later when reconnecting you don’t get mutiple processes. That’s kind of crap, needing essentially a daemon to sit and watch another daemon, to sit and watch the google drive mount point. Maybe the pam_automount idea from the wiki on the gdfuse github is the way to go.

I've been a longtime google-drive-ocamlfuse user, moving over from Grive2 and Grive Indicator (yes, you can get them to work together).

I use the following shell script, and add it to my startup applications:

#!/bin/bash

ifonline ()
{
    if ping -c 1 google.com >> /dev/null 2>&1; then
        mount | grep '/home/monty/GoogleDrive' >/dev/null || /usr/bin/google-drive-ocamlfuse '/home/monty/GoogleDrive'
    else
        sleep 30s
        ifonline
    fi
}

ifonline
1 Like

I could get ocamlfuse to mount my google drive, but if I had it setup to run at startup it would cause caja to hang on loading and cause my desktop to not display for about 20 seconds...Getting it to actually run and mount the drive was a non-issue though.

How do you manage to do the same kind of script but for 2 different label accounts? (I have different shared drives)

Hope someone knows how to because I can't manage to make it work. Thanks!

Thank you!

As an amateur Linux user it has been a hell of a battle to get everything I used to use Windows for up and running.

I was using KIO-Gdrive, it worked but felt like a hacky KDE plug-in. The mount point showed up as some strange file that I could not navigate into from the terminal or from anything that didn't use Dolphin's file dialog. It could have (was most likely) just my lack of understanding. I was so happy to stumble across google-drive-ocamlfuse.

My next issue was for sure my lack of ability. Rsync seems really awesome but not for someone like me. (At least at my level of Linux and networking knowledge.) I was really happy to find Kups. It seamlessly integrates bups into KDE's nice 'settings' GUI. Now, with your simple, elegant script I actually prefer this over running 'Google Drive' on Windows.

I actually have learned most of the commands I see there as individual pieces. Someday I hope to be able to piece it all together into a bash script like that....

This has been how all of my migration projects have worked out. They go from frustrating and overwhelming to "wow, this is exactly what I needed all along and I can customize it to do anything!" There is also this incredible community that will take the time to help us noobs. They only time they argue is if you prefer a different package manager or Distro and only get mad if you didn't RTFM! :sweat_smile:

Thanks again!

Thank you!

As an amateur Linux user it has been a hell of a battle to get everything I used to use Windows for up and running.

I was using KIO-Gdrive, it worked but felt like a hacky KDE plug-in. The mount point showed up as some strange file that I could not navigate into from the terminal or from anything that didn't use Dolphin's file dialog. It could have (was most likely) just my lack of understanding. I was so happy to stumble across google-drive-ocamlfuse.

My next issue was for sure my lack of ability. Rsync seems really awesome but not for someone like me. (At least at my level of Linux and networking knowledge.) I was really happy to find Kups. It seamlessly integrates bups into KDE's nice 'settings' GUI. Now, with your simple, elegant script I actually prefer this over running 'Google Drive' on Windows.

I actually have learned most of the commands I see there as individual pieces. Someday I hope to be able to piece it all together into a bash script like that....

This has been how all of my migration projects have worked out. They go from frustrating and overwhelming to "wow, this is exactly what I needed all along and I can customize it to do anything!" There is also this incredible community that will take the time to help us noobs. They only time they argue is if you prefer a different package manager or Distro and only get mad if you didn't RTFM! :sweat_smile:

Thanks again!

EDIT: Just realized what forum I am in. I am running KDE Neon for anyone wandering if this may work in a different Distro.