Skip to content

Using Google Drive by Rclone in Ubuntu

Rclone is a command-line program to manage files on cloud storage. It is a feature-rich alternative to cloud vendors’ web storage interfaces. Over 70 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.

It has the following common functions:

  • 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.65.1 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:
     text.txt

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 ~/GoogleDive
$ rclone mount --daemon --vfs-cache-mode full --write-back-cache --vfs-write-back 10s --vfs-cache-max-age 300s --vfs-cache-max-size 5000M --vfs-cache-poll-interval 60s --cache-dir /tmp  gdrive:/ ~/GoogleDrive/

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.

If you don’t use the google drive anymore, you can unmout it by following command:

fusermount -u ~/GoogleDrive
Leave a Reply