Dane.Kouttron

[12.11.22]  Linux CNC Google Drive Tutorial

Quick Tutorial: Google Drive on Linuxcnc 2.8.4 without GNOME using google-drive-ocamlfuse



I've previously used Dropbox for transferring files to my LinuxCNC 3xais rig, but ran into issues with Dropbox discontinuing support for Linux. This is, incredibly annoying.
Time to try google drive.

At the time of this writing, I'm running Debian 10 (buster) with XFCE as the desktop environment. This is the standard setup for  LinuxCNC 2.8.4
The easiest way to check which version you're running is by checking the about function in linuxcnc:



Linux CNC purposely chooses a lightweight desktop client and limited extra bundled in software, as its unlikely you're going to be live transcoding HD video footage or gaming while you're operating a CNC. As such the XFCE desktop was chosen over GNOME, its much more lightweight.

There are two options for using google drive:

Option 1:
Install Gnome as your desktop environment and then use the built in 'online accounts' feature. This is probably the easiest route, but its not clear if running GNOME will result in extra latency in LinuxCNC land. Its worth benchmarking given how troublesome sorting out the installation process was here, but I opted for option number two.
Option 2:
Install google-drive-ocamlfuse [link] which is a FUSE filesystem for google drive, that mounts as an external drive in Linux. This does not require changing the desktop environment and seems to have a much lower impact on system memory. As with anything, having network access on a CNC machine does add latency, completely proportional to the network PHY. Terrible RaLink controllers that outsource Ethernet activity to the CPU will really hinder low latency operations, but the on-board Intel PHY on the DELL I'm using appears to add almost indistinguishable results on the latency test between when ethernet is unplugged or plugged in. Doveryay, no proveryay, here's the results:

If you're like me you'd prefer to not significantly modify your working CNC machine, lest ye enter the sea of sharks.

Note this doesn't work and I'm including it as a reference, if you want the working procedure jump down the page [link] :

First up, lets update and install the associated ppa for the github project. By adding a PPA it is telling your machine 'hey you can get updates from here'



After an update, then adding the repository I'm rewarded with:

"Command not found"
Excuse Me? add-apt-repository should  be pretty basic, it looks like its contained in the package 'software-properties-common' so lets install that first, then try installing the ppa



And you get a
there's no release candidate error. This indicates your Linux version isn't directly supported, this seems odd as this is a 2020 OS build of Debian, not some artifact from 1992.


:/


A working install process for XFCE: Installing from Deb File

Lets just find the pre-packaged deb file and install that directly. Here's the repository [
link]

if you're doing this via a remote terminal, you can grab the file and save it using wget. wget is a common tool for grabbing individual files or even copying entire websites.
Comically wget is not installed by default, so lets install it.



 

Lets use wget to grab the installation package and save it locally. Note I am in the /Downloads folder which you can cd to from your home directory. For my particular machine (x64 amd computer) I am grabbing google-drive-ocamlfuse_0.7.27-0ubuntu18.04.1_amd64.deb found here:

Ok, lets grab it




Now we can install from this file, all we need to do is a sudo apt install ./ (file name)





Huzzah! We installed and it didn't throw a pile of errors. Lets go over to the CNC and give it a run for the first time. Note that launching from a remote terminal (for example running from Putty in windows, this is going to want to open a browser and sort out authenticating, which is not possible over just terminal. At your cnc machine just type in:






Its happening! You should get a browser request to login and provide permissions. For the purposes of this project I used a non-primary google account (a development account I use for app-testing). I signed in and allowed google-drive-ocamlfuse access to my google drive. Lets give it a test run to make sure it 'works'. First off lets make a symlink to a location on your machine. I made this simlink on the desktop.This is not a file / folder its just a location. Finally we point google-drive-ocamlfuse to the 'gdrive' symlink



LETS GO! Here's our drive, we can mount it open it save files and copy things back and forth, so long as that terminal is still open.



Ok now how do we tell this to auto-mount on system start. How does it deal with loss of network (does it boot if ethernet is unplugged). This step was way more involved than i thought it would be. My initial plot was to have a 'launcher' on the desktop run 'google-drive-ocamlfuse ~/gdrive/. hahah no that does not work it throws an authentication error. I'm not the only one who ran into this though, we have some help from the ether [link]. Jump to "Mount using fstab with no password required"

We're gonna make a small C program that runs on boot that handles mounting the directory. Yes this is getting ridiculous.

start by making a file called google-drive-ocamlfuse-mounter.c I was in the /Documents folder but this can be anywhere


Paste in the following to that file.


Compile it, and give it permissions



Point it at the directory we made earlier. Note my username is linuxcnc, plug in whatever your username is here



Lets doublecheck our UID and GID.

Type in id and the UID and GID are printed out. They should both be 1000 if they are showing anything different just edit the fstab line below to indicate the difference

Last up we edit /etc/fstab:





Video time! it works even after re-start.





Concluding Remarks:
  • Just use sftp via winscp, this was way too much hoop jumping for file transfers.



(There's photos in the photo gallery)




If you have questions or comments, ask below or send over an email.
Comments:
HTML Comment Box is loading comments...


Dane.Kouttron
Rensselaer Polytechnic Institute 
Electrical & Electrical Power
631.978.1650