Skip to main content

gdrive-filesys

gdrive-filesys is a Linux or macOS filesystem for Google Drive.

gdrive-filesys is a network filesystem that gives your computer direct access to your files on Google Drive. gdrive-filesys allows you to use files on Google Drive as if they were files on your local computer.

gdrive-filesys has been optimized to allow git repos to be stored on google drive:

gdrive-filesys mount ~/mnt
cd ~/mnt
git clone <repo>

gdrive-filesys by default performs an on-demand download of files when your computer attempts to use them.

Key features

gdrive-filesys has several nice features that make it significantly more useful than other Google Drive clients:

  • The default is to only download files when you use them. The deafult is to only download a file if you (or a program on your computer) uses that file. You don't need to wait hours for a sync client to sync your entire Google Drive account to your local computer.

  • Downloading all files from Google Drive. You can automaticaly download all files to to your local filesystem. This will ensure that all files can be accessed offline when your computer is disconnected from the internet.

  • Bidirectional sync. gdrive-filesys will only download a file when you access a file that has been changed remotely on Google Drive. If you somehow simultaneously modify a file both locally on your computer and also remotely on Google Drive, gdrive-filesys will keep the most recently modified file. The default is to check Google Drive once every minute for any remotely changed files.

  • Can be used offline. Files you've opened previously will be available even if your computer has no access to the internet. While your computer is disconnected from the internet, you can continue to update the local filesystem and when you reconnect to the internet, the locally updated files will be uploaded to google drive.

  • Fast. gdrive-filesys asynchronously performs network requests to Google Drive once every minute. gdrive-filesys caches both filesystem metadata and file contents both in memory and on-disk. Filesytem operations will always be fast unless a large file must be read from Google Drive.

  • gitignore files. Files that match a .gitignore file are only cached locally and are not uploaded to Google Drive. This means that Python virtual environment packages in .venv and nodejs packages in node_modules are only installed locally.

Local Only directories. Directories can be configued to only store files locally in your native filesystem to improve small file performance. The ~/.gdrive-filesys/config.toml file is used to configure local only directories. Thenode_modules directory is configured as a local only directory so node packages are stored locally in your native filesystem, and npm install will run very fast.

This is the default `config.toml' file:

### This is the configuration file.
### It should be placed in $HOME/.gdrive-filesys/config.toml

# Directory names that are only created localy and not synced to Google Drive.
# Files in local only directories are stored in the native filessystem for fast
# updates.  Install directories are good candidates to be stored locally.
local_only = [
   "node_modules",    
]

Quick start

Install FUSE

OSX

On Mac OSX, gdrive-filesys requires osxfuse and pkg-config:

$ brew update; brew install pkg-config; brew tap homebrew/cask; brew install --cask osxfuse

Ubuntu / Debian

On Ubuntu / Debian, gdrive-filesys requires libfuse-dev, libssl-dev and pkg-config:

sudo apt-get install -y fuse3 libfuse-dev libssl-dev pkg-config

Fedora

On Fedora, gdrive-filesys requires gcc, fuse3-devel, and pkg-config:

sudo dnf install -y gcc fuse3-devel pkg-config

Google Drive Authentication

  1. Follow these instuctions to create the required credentials.json file.
  2. Download the credentials.json file and place it in your ~/.gdrive-filesys/ directory.

Install gdrive-filesys:

MacOS

Install pipx:

brew install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install gdrive-filesys

Ubuntu / Debian

sudo apt update
sudo apt install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install gdrive-filesys

Fedora

sudo dnf install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install gdrive-filesys

Mount Filesystem

Create mountpoint directory:

MOUNTPOINT=~/mnt
mkdir $MOUNTPOINT

Mount Filesystem:

gdrive-filesys mount $MOUNTPOINT # add --downloadall to sync all files

Notes:

  • It's recommended to run it as user, not as root. For this to work the mountpoint must be owned by the user.
  • The cache update interval defaults to 1 minutes, and can be set with the --updateinterval option.

Unmount Filesystem

gdrive-filesys unmount $MOUNTPOINT

or

fusermount -u $MOUNTPOINT

Display gdrive-filesys activity:

gdrive-filesys status

Building gdrive-filesys yourself

Create Virtual Environment:

cd gdrive-filesys
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .

Mount filesystem:

$ ./src/gdrive_filesys/cli.py $MOUNTPOINT

Running tests

The best way to test is to clone a repo, and install, build and run the application.

Mount Filesystem:

gdrive-filesys mount $MOUNTPOINT

Build and run web application:

cd $MOUNTPOINT
git clone https://github.com/allproxy/allproxy.git
npm install
npm run build
npm start

Run python application:

cd $MOUNTPOINT
git clone https://github.com/davechri/gdrive-filesys.git
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
./src/gdrive_filesys/cli.py status

Troubleshooting

If the filesystem appears to hang, its possible the fileystem has crashed. To resolve this:

  • Remount: fusermount -u $MOUNTPOINT and remount gdrive-filesys mount $MOUNTPOINT
  • Clear the local cache: fusermount -u $MOUNTPOINT and remount gdrive-filesys mount $MOUNTPOINT --clearcache
  • Restart your computer

Logging

  • Error Log: error logs are logged to ~/.gdrive-filesys/error.log
  • HTTP Log: HTTP errors are logged to ~/.gdrive-filesys/http.log

Debug Logging

For debug logging use the --debug option. The --verbose option will produce more verbose logging.

gdrive-filesys mount $MOUNTPOINT --debug &> ~/path_to_my_log_file

Display gdrive-filesys status

Filesystem statistics are displayed every 10 seconds.

gdrive-filesys status
18:11:12 ONLINE:
	LOCAL_ONLY:   /home/dave/.gdrive-filesys/localonly=969.2 kB
	GITIGNORE:    dirs=0     files=0        links=2    cached=0 Bytes   total=0 Bytes
	GOOGLE_DRIVE: dirs=495   files=3109     links=5    cached=7.3 MB    total=121.1 MB
18:11:24 ONLINE:
	FILESYS OPS:  getattr=424 readdir=32 read=290 flush=249 readlink=4 
	LOCAL_ONLY:   /home/dave/.gdrive-filesys/localonly=969.2 kB
	GITIGNORE:    dirs=0     files=0        links=2    cached=0 Bytes   total=0 Bytes
	GOOGLE_DRIVE: dirs=495   files=3109     links=5    cached=7.3 MB    total=121.1 MB
18:11:36 ONLINE:
	FILESYS OPS:  getattr=311 readdir=18 read=63 flush=63 readlink=644 
	LOCAL_ONLY:   /home/dave/.gdrive-filesys/localonly=969.2 kB
	GITIGNORE:    dirs=0     files=0        links=2    cached=0 Bytes   total=0 Bytes
	GOOGLE_DRIVE: dirs=495   files=3109     links=5    cached=7.3 MB    total=121.1 MB

Dump Internal State

Display metadata:

gdrive-filesys metadata

Display directory entries:

gdrive-filesys directories

Diaplay all unread files:

gdrive-filesys unread

Display the event queue:

gdrive-filesys eventqueue

Metadata

Release files for gdrive-filesys 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gdrive-filesys 0.0.8
File Size Uploaded
gdrive_filesys-0.0.8.tar.gz 57.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gdrive-filesys 0.0.8
File Interpreter ABI Platform
gdrive_filesys-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 130.7 kB

Release files / gdrive_filesys-0.0.8.tar.gz

Download URL gdrive_filesys-0.0.8.tar.gz
Size 57.0 kB
Tags Source
SHA-256 checksum
How to use checksums
eb7324343de1de2eb53c04567533b91cf6871bde263a235295f0cfa5b1160920
BLAKE2b-256 checksum
How to use checksums
a2e71d1f52663f41e2d124271e8099997dcd25b85673d80f9f001b6c551af1ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / gdrive_filesys-0.0.8-py3-none-any.whl

Download URL gdrive_filesys-0.0.8-py3-none-any.whl
Size 73.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb8fb804c8bc7fed12c383859722b34e5724ac83322c0a372710554e44443a22
BLAKE2b-256 checksum
How to use checksums
4a589766abe1a5d583083c84ec554c293d9bc767d745a129a0f68f9f33558c18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page