1. Overview

Google Drive syncs files from our mobile devices and workstations to the same remote location. Its cross-platform web access works in any browser, but no official client integrates Google Drive with Linux file managers and applications.

In this tutorial, we’ll look at some third-party open-source projects that expose our remote Google Drive directory as a locally mounted folder.

Unless otherwise noted, we’ve tested these clients in Linux Mint 21.1 Cinnamon Edition.

2. CLI Clients

Although the CLI clients are designed to be used from a terminal, a browser is required for the initial Google Drive login and client authorization. Headless authentication – without a GUI and, therefore, without a browser – is possible, but it’s an advanced topic beyond the scope of this tutorial.

2.1. google-drive-ocamlfuse

google-drive-ocamlfuse makes Google Drive accessible to any Linux CLI or GUI software via a FUSE filesystem. Its PPA repository makes it easy to install on Ubuntu-based distributions:

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

In all other cases, we can refer to the official installation instructions or to third-party repositories, as in the case of Fedora.

After installation, the first step is to authorize google-drive-ocamlfuse to use our Google Drive account. Let’s run it with no parameters:

$ google-drive-ocamlfuse

This causes a browser to ask us for authorization:

gdfuse authorization browser windowAfter that, google-drive-ocamlfuse continues to run in the background until we see the message that an access token is obtained:

$ google-drive-ocamlfuse
[...]
Access token retrieved correctly.

Now, we can mount our remote Google Drive directory to a local folder:

$ mkdir googleDriveRemoteDir
$ google-drive-ocamlfuse ./googleDriveRemoteDir/
$ ls -l ./googleDriveRemoteDir/
[...]
-rw-rw-r-- 1 francesco francesco 8399 apr 21  2023 'Test Document.odt'

If we’re using a free Google Drive account, the expected file system size is 15GiB (16.1GB):

$ df -h
Filesystem              Size  Used Avail Use% Mounted on
[...]
google-drive-ocamlfuse   15G   36K   15G   1% /home/francesco/googleDriveRemoteDir

The speed of opening and saving files depends on our Internet connection.

More advanced topics, such as headless authentication in server environments and automount on system reboot, are covered in the official wiki.

2.2. rclone

rclone has several purposes:

  • Synchronize, copy, or move files between different cloud storage services or local folders
  • Migrate files between cloud storage services
  • Serve files from cloud storage services via HTTP, FTP, SFTP, WebDAV, or DLNA
  • Encrypt or decrypt files on cloud storage services
  • Serve an experimental web-based GUI
  • Mount one or more cloud storage services together in a local directory

We’ll only discuss the last case, configuring a single Google Drive account.

Let’s start by installing rclone using the official script:

$ sudo -v ; curl https://rclone.org/install.sh | sudo bash
[...]
rclone v1.62.2 has successfully installed.
Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.

We prepared a reference guide to rclone config, as its output is too verbose:

  • Select n for a new remote, which is a named remote storage system
  • Enter a name for our remote, like gdrive
  • Enter the number for Google Drive, which is 18 in rclone 1.62.2
  • Leave client_id and client_secret empty unless we have our own Google API credentials
  • Choose 1 for full access
  • Leave the service_account_file empty
  • Avoid advanced configuration with n
  • Choose y to authenticate rclone with a browser
  • Avoid configuring a shared drive with n
  • Select y to confirm the configuration
  • Choose q to finish the configuration

If everything is correct, we can list the files and directories in our Google Drive account:

$ rclone ls gdrive:
     9623 Test Document.odt

Finally, we can mount Google Drive to a local folder. In the following commands, we need to replace gdrive with the name of our remote, if different:

$ mkdir mylocalfolder
$ rclone mount --daemon --vfs-cache-mode full gdrive:/ ./mylocalfolder/

In this way, the integration of Google Drive into the local file system is seamless both with the file manager – Nemo, in our case – and with any other application, such as LibreOffice. This is mainly due to the –vfs-cache-mode full option.

3. GUI Clients

The GNOME and KDE desktop environments come with well-integrated and out-of-the-box Google Drive clients. Configuration is easy and doesn’t require the terminal. On the other hand, these solutions have some usage limitations, as we’ll see.

3.1. GNOME Online Accounts

GNOME Online Accounts is part of the GNOME desktop environment. It’s also well-integrated and included by default in Linux Mint Cinnamon Edition, which offers this and other GNOME features. It provides a convenient way to access a variety of online services, including Google Drive, which is nicely supported in GNOME Files and, in the case of Cinnamon, Nemo.

To see it in action, let’s open the Settings application on our GNOME or Cinnamon desktop and click Online Accounts. Then, let’s select Google from the list of available providers and authenticate:

GnomeOnlineAccounts1 - LoginGNOME Online Accounts allows us to choose which Google services we want to integrate into the desktop. We need to make sure we’ve enabled Files, which corresponds to Google Drive:

GNOME Online Account - Google Drive FilesFrom now on, we’ll find an extra entry in the file manager that corresponds to our Google Drive account:

Nemo file manager with Google DriveThe problem with this approach is that it seems great only for GUI applications. Using the terminal is far from intuitive, both because of the non-trivial path of the Google Drive folder and because of the encoding of file names.

For example, to access our Test Documents.odt file shown in the screenshot above, we need to replace myemail with our email account without @gmail.com, and 1000 with our user id, as returned by id -u:

$ cd '/run/user/1000/gvfs/google-drive:host=gmail.com,user=myemail'
$ ls -l
total 0
drwx------ 1 francesco francesco 0 Jan  1  1970 0ABL_QtLrcLmOUk9PVA
dr-x------ 1 francesco francesco 0 Jan  1  1970 GVfsSharedWithMe
$ cd 0ABL_QtLrcLmOUk9PVA
$ ls
11lfzX-8dH_eWtf2JWa3caRtodOnlXDbN
$ file 11lfzX-8dH_eWtf2JWa3caRtodOnlXDbN 
11lfzX-8dH_eWtf2JWa3caRtodOnlXDbN: OpenDocument Text

In this case, 11lfzX-8dH_eWtf2JWa3caRtodOnlXDbN is Test Documents.odt. These file and directory names represent the internal encoding used by GVfs and aren’t meant to be human-readable.

3.2. KIO GDrive

KIO GDrive allows us to access our Google Drive files and folders on any KDE-based distribution. It integrates with Dolphin and any other KIO-aware software. On the other hand, applications from outside the KDE world may not work well with KIO or may require additional packages to do so.

Usually, we need to install KIO GDrive from the distribution’s package manager. We’ll take KUbuntu 22.04 as an example:

$ sudo apt install kio-gdrive

To make LibreOffice compatible with KIO, we also need an additional package:

$ sudo apt install libreoffice-kde

After the installation, we can easily add our Google account in Dolphin. We’ll follow the usual steps to authorize the application:

"KDE Google Drive and YouTube are the two Google services that Dolphin supports:

"KDEFinally, we can access our files:

"KDEKIO GDrive is only convenient for KDE-native applications. In all other cases, we need to check what kind of support and what workarounds, if any, are available.

4. Conclusion

In this article, we’ve seen some CLI and GUI tools to integrate Google Drive with our Linux system.

However, it’s important to remember that there are always security risks associated with storing our files in the cloud. In particular, we shouldn’t store sensitive or confidential information, such as personal, financial, or health records. In such cases, we should ensure that our remote backups are encrypted and protected by a strong password.

Comments are closed on this article!