GDrive in Linux

This document describes few ways to use GDrive in Linux

ocamlfuse

Installation

Follow the steps in https://linuxhint.com/mount_google_drive_linux_mint↗ ↗ to the dot for using ocamlfuse↗ .

Used PPA of the author to allow easier installation and updates of google-drive-ocamlfuse.

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

Configuration & Usage

Configure Authentication with validity of 30 days to access GDrive

google-drive-ocamlfuse
mkdir LDrive
google-drive-ocamlfuse LDrive

To unmount GDrive:

fusermount -u LDrive

To test listing of GDrive locally:

df -h
Filesystem Size Used Avail Use% Mounted on
google-drive-ocamlfuse 15G 6.6G 8.5G 44% /home/prabu/LDrive

Location of the config file : ~/.gdfuse/default/config. To clear the cache, if config changes are made use google-drive-ocamlfuse with the -cc option.

With ocamlfuse Google Drive can be accessed directly using the file explorer. Biggest advantage of ocamlfuse over rclone is its ability to handle Gdocs files properly. Unlike rclone, ocamlfuse cannot access other cloud providers.

Source:

rclone

The following notes to use rclone with GDrive has been based on official documentation source i.e rclone official site↗

Summary: Due to issues with handling of gdocs, still mount is quite useless. However, rclone’s sync feature is good to use for upload/download etc. The following configuration created somewhere in mid 2020 works without any further change for more than six years now.

Installed originally with sudo apt-get. Realized that the version was quite old. So went to rclone website and downloaded the latest deb package rclone-v1.52.1-linux-amd64.deb and installed using the command:

sudo dpkg -i rclone-v1.52.1-linux-amd64.deb

The software version used during mid'2020:

Configuration

Use Custom OAuth Client ID as explained in the next section.

rclone config

2020/06/16 23:17:57 NOTICE: Config file
"/home/prabu/.config/rclone/rclone.conf" not found - using defaults

No remotes found - make a new one
n) New remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config

n/r/c/s/q> n

name> GDrive
Type of storage to configure.

Choose a number from below, or type in your own value
1 / Amazon Drive
\ "amazon cloud drive"
....
6 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
7 / Google Drive
\ "drive"
...

Storage> 7
Google Application Client Id - leave blank normally.
client_id>
Google Application Client Secret - leave blank normally.
client_secret>

Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine or Y didn't
work

y) Yes
n) No
y/n> y

If your browser doesn't open automatically go to the following link:
http://127.0.0.1:53682/auth

Log in and authorize rclone for access
Waiting for code...
Got code

--------------------

[GDrive]

client_id =
client_secret =
token =
{"access_token":""}

--------------------

y) Yes this is OK
e) Edit this remote
d) Delete this remote

y/e/d> y

Current remotes:

Name Type
==== ====
GDrive drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config

e/n/d/r/c/s/q> q

To list every file in GDrive

rclone ls GDrive:

Custom OAuth Client ID

Rclone’s default public Client ID is heavily rate-limited by Google. To avoid sudden 429 error i.e Too Many Requests or slow transfers, create your own API key:

  • Go to the Google Cloud Console and enable the Google Drive API.
  • Create an OAuth 2.0 Client ID (select Desktop App as the application type).
  • Pass your custom client_id and client_secret into your rclone config setup.

The above change avoids Shared Quota Limits.

GDrive as local folder

This mounting of GDrive as local folder is quite unusable due to issues with Gdocs files.

Start the mount like this to run mount in background (daemon) mode.

rclone mount remote:path/to/files /path/to/local/mount --daemon
rclone mount GDrive: GDrive --vfs-cache-mode full --drive-skip-gdocs
--daemon

When running in background mode the user will have to stop the mount manually (specified below). Stopping the mount manually:

fusermount -u /path/to/local/mount

Flags to be used

–vfs-cache-mode full/writes/minimal/off

To clear Trash on GDrive

rclone cleanup GDrive:
rclone about GDrive:
Total: 15G
Used:2.767G
Free:8.460G
Trashed: 0
Other: 3.773G

To download/export or upload to GDrive

Important: Since this can cause data loss, test first with the –dry-run flag to see exactly what would be copied and deleted.

To download everything from GDrive to local folder.. Note: Default gdocs changes to docx…

To download

rclone sync GDrive: /media/DDrive/prabu/GDrive --drive-export-formats
ods,odt,odp

To upload (rclone will not convert any files by default, since the conversion is a lossy process.)

rclone sync /media/DDrive/prabu/GDrive GDrive:

Document format conversion

When rclone downloads a Google doc it chooses a format to download depending upon the –drive-export-formats setting. By default the export formats are docx,xlsx,pptx,svg which are a sensible default for an editable document.

  • –drive-skip-gdocs (very much needed if mounting)
  • –drive-export-formats pdf (if backup is being taken)
  • –drive-export-formats ods,odt,odp (useful for sync option

Source:


© Prabu Anand K 2020-2026