Home Google Drive How To Mount Google Drive Locally As Virtual File System In Linux

How To Mount Google Drive Locally As Virtual File System In Linux

By sk
Published: Last Updated on 149.6K views

This guide explains how to mount Google drive locally as a virtual file system and access your Google drive files from the file manager in Linux.

Introduction

Google Drive is the one of the popular cloud storage provider on the planet. As of 2017, over 800 million users are actively using this service worldwide.

Even though the number of users have dramatically increased, Google haven't released a Google drive client for Linux yet. But it didn't stop the Linux community.

Every now and then, some developers have released a few google drive clients for Linux operating system. In this guide, we will see four unofficial google drive clients for Linux.

Using these clients, you can mount Google drive locally as a virtual file system and access your drive files in your Linux box.

1. Rclone

Rclone is my favorite command line tool to sync files and directories to and from local and remote cloud storage providers. It can also serve local or remote files over HTTP/WebDav/FTP/SFTP/dlna. Rclone is a free and open source application written using GO programming language.

It is not just for Google drive, Rclone will support a lot of other cloud storage providers as listed below.

  • Alibaba Cloud (Aliyun) Object Storage System (OSS),
  • Amazon Drive,
  • Amazon S3,
  • Backblaze B2,
  • Box,
  • Ceph,
  • DigitalOcean Spaces,
  • Dreamhost,
  • Dropbox,
  • Google Cloud Storage,
  • Hubic,
  • Jottacloud,
  • IBM COS S3,
  • Koofr,
  • Memset Memstore,
  • Mega,
  • Microsoft Azure Blob Storage,
  • Microsoft OneDrive,
  • Minio,
  • Nextcloud,
  • OVH,
  • OpenDrive,
  • Openstack Swift,
  • Oracle Cloud Storage,
  • ownCloud,
  • pCloud,
  • put.io,
  • QingStor,
  • Rackspace Cloud Files,
  • rsync.net,
  • Scaleway,
  • Wasabi,
  • Yandex Disk.

1.1. Install Rclone in Linux

Rclone can be installed in couple ways.

Install Rclone using installation script:

This is the easiest way to install rclone on Linux Mac OS and BSD systems.

All you you have to run the following one-liner command from the Terminal:

$ curl https://rclone.org/install.sh | sudo bash

For beta installation, run:

$ curl https://rclone.org/install.sh | sudo bash -s beta

Some of you don't like to directly pipe some script into your Bash using curl command. If so, skip this and follow other installation methods given below.

Install Rclone using default package manager:

Rclone is available in the default repositories of some Linux distributions.

On Arch Linux and its variants, enable [Community] repository and install Rclone using pacman like below.

$ sudo pacman -S rclone

On Debian, Ubuntu, Linux Mint and other Deb-based systems:

$ sudo apt install rclone

On Fedora:

$ sudo dnf install rclone

Install Rclone from precompiled binaries:

If Rclone is not available in default repositories or if it is outdated, you can install the most recent Rclone version as shown below.

Download and extract the latest precompiled binary:

$ curl -O http://downloads.rclone.org/rclone-current-linux-amd64.zip
$ unzip rclone-current-linux-amd64.zip
$ cd rclone-*-linux-amd64

Copy binary file to your $PATH:

$ sudo cp rclone /usr/bin/

Set proper permissions:

$ sudo chown root:root /usr/bin/rclone
$ sudo chmod 755 /usr/bin/rclone

Finally install Rclone manpage:

$ sudo mkdir -p /usr/local/share/man/man1
$ sudo cp rclone.1 /usr/local/share/man/man1/
$ sudo mandb

Install Rclone using snap

Rclone is also available as Snap. You can install it using command:

$ sudo snap install rclone --classic

1.2. Configure Rclone to access Google drive

Once installed, run the following command to give permission to Rclone to access your Google drive:

$ rclone config

This will guide you through a series of interactive setup process. First, it will search for list of available remotes. We haven't created any remotes yet, so let us create one.

To do so, simply type "n" and hit ENTER. Then type the name of the remote. I am going to name it as "mygoogledrive".

2019/07/16 16:27:20 NOTICE: Config file "/home/sk/.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> mygoogledrive

Next choose the cloud provider. In our case. it is Google drive, so I entered number 7.

Type of storage to configure.
Choose a number from below, or type in your own value
1 / Amazon Drive
\ "amazon cloud drive"
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
\ "s3"
3 / Backblaze B2
\ "b2"
4 / Dropbox
\ "dropbox"
5 / Encrypt/Decrypt a remote
\ "crypt"
6 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
7 / Google Drive
\ "drive"
8 / Hubic
\ "hubic"
9 / Local Disk
\ "local"
10 / Microsoft OneDrive
\ "onedrive"
11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
12 / SSH/SFTP Connection
\ "sftp"
13 / Yandex Disk
\ "yandex"
Storage> 7

Next press ENTER to leave blank values for Google application client id and client secret:

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

Type "y" to use auto config:

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

Now your web browser will open and Rclone will then ask your permission to access your Google drive. Click "Allow" button to authorize it.

Authorize Rclone to access google drive
Authorize Rclone to access google drive

Once you clicked the "Allow" button, you will see a success message in the browser. Just close the browser window and go back to the Terminal.

The verification code is automatically copied to your Terminal. If this is OK to you, simply type "y" and press ENTER to continue creating the remote:

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

Done! A remote named "mygoogledrive" has just been created.

If you wish to create a new one, click "n" and follow the same procedure given above. Or else, quit the rclone config wizard by pressing "q".

Current remotes:

Name Type
==== ====
mygoogledrive 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

You can view the list of configured remotes at any time by using the following command:

$ rclone listremotes

1.3. Mount Google Drive Locally As Virtual File System Using Rclone

Create a mount point to mount your google drive files:

$ mkdir ~/drive

Then, mount the Google drive using command:

$ rclone mount mygoogledrive: ~/drive/

You can mount a specific directory/file from the google drive like below.

$ rclone mount remote:path/to/files /path/to/local/mount

To unmount, simply press "CTRL+c" to stop the mount.

In my case, I mounted my Google drive in a mount point directory named "~/drive". Replace remote name (i.e mygoogledrive) and mount point name (i.e ~/drive) with your own values.

Open your file manager and you will see the drive folder in the left side. Click on it to access your Google drive.

Mount Google Drive Locally As Virtual File System Using Rclone
Mount Google Drive Locally As Virtual File System Using Rclone

From now on, you can create, copy, move, rename and delete files/folders as the way you do in your local file system. Anything you put in the local mount folder (i.e. ~/drive folder) will be uploaded to your Google drive.

You can also list and copy files/directories from command line like below.

To view all files in your Google drive, run:

$ rclone ls mygoogledrive:

Replace "mygoogledrive" using your own remote name.

To list all directories in the top level, run:

$ rclone lsd mygoogledrive:

Copy a directory from your local system, say "/home/sk/senthil", to your Google drive directory called "ostechnix", use this command:

$ rclone copy /home/sk/senthil mygoogledrive:ostechnix

Rclone has many other command line options, but this is not the scope this guide. We will cover them in a separate guide later.

The umount operation may fail, for example when the mount point is busy. When that happens, you can stop the mount manually using command:

$ fusermount -u ~/drive

For more details, refer Rclone website.

If you're not happy with Rclone, you can try the following tools which are specifically designed for Google drive only.

Please note that these following tools won't help you to mount other cloud storages, for example Dropbox, in your local system.

2. Google-drive-ocamlfuse

The google-drive-ocamlfuse is a FUSE filesystem for Google Drive, written in OCaml.

For those wondering, FUSE, stands for Filesystem in Userspace, is a project that allows the users to create virtual file systems in user level.

google-drive-ocamlfuse allows you to mount your Google Drive on Linux system.

It features read/write access to ordinary files and folders, read-only access to Google docks, sheets, and slides, support for multiple google drive accounts, duplicate file handling, access to your drive trash directory, and more.

2.1. Install google-drive-ocamlfuse in Linux

The google-drive-ocamlfuse is available in the AUR, so you can install it using any AUR helper programs, for example Paru or Yay.

$ paru -S google-drive-ocamlfuse

Or,

$ yay -S google-drive-ocamlfuse

On Ubuntu:

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

To install latest beta version, do:

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

2.2. Mount Google Drive Locally As Virtual File System Using google-drive-ocamlfuse

Once installed, run the following command to launch google-drive-ocamlfuse utility from your Terminal:

$ google-drive-ocamlfuse

When you run this first time, the utility will open your web browser and ask your permission to authorize your google drive.

Once you gave authorization, all necessary config files and folders it needs to mount your google drive will be automatically created.

Authorize google drive
Authorize google drive

After successful authentication, you will see the following message in your Terminal.

Access token retrieved correctly.

You're good to go now. Close the web browser and then create a mount point to mount your google drive files.

$ mkdir ~/mygoogledrive

Finally, mount your google drive using command:

$ google-drive-ocamlfuse ~/mygoogledrive

Congratulations! You can access access your files either from Terminal or file manager.

From Terminal:

$ ls ~/mygoogledrive

From File manager:

Mount Google Drive Locally As Virtual File System Using google-drive-ocamlfuse
Mount Google Drive Locally As Virtual File System Using google-drive-ocamlfuse

If you have more than one account, use label option to distinguish different accounts like below.

$ google-drive-ocamlfuse -label label [mountpoint]

Once you're done, unmount the FUSE flesystem using command:

$ fusermount -u ~/mygoogledrive

For more details, refer man pages.

$ google-drive-ocamlfuse --help

Also, do check the official wiki and the project GitHub repository for more details.

3. GCSF

GCSF is a FUSE filesystem based on Google Drive, written using Rust programming language.

Using GCSF, you can mount your Google drive as a local virtual file system and access the contents from the Terminal or file manager.

You might wonder how it differ from other Google Drive FUSE projects, for example google-drive-ocamlfuse.

The developer of GCSF replied to a similar comment on Reddit "GCSF tends to be faster in several cases (listing files recursively, reading large files from Drive).

The caching strategy it uses also leads to very fast reads (x4-7 improvement compared to google-drive-ocamlfuse) for files that have been cached, at the cost of using more RAM".

The name GCSF has come from the Romanian word "Google Conduce Sistem de Fișiere", which means "Google Drive Filesystem" in English.

3.1. Install GCSF in Linux

GCSF is available in the AUR, so the Arch Linux users can install it using any AUR helper, for example Paru or Yay.

$ paru -S gcsf-git

Or,

$ yay -S gcsf-git

On other Linux distributions, you can install GCSF using cargo package manager..

Make sure you have installed Rust on your system.

Make sure pkg-config and the fuse packages are installed. They are available in the default repositories of most Linux distributions.

For example, on Ubuntu and derivatives, you can install them using command:

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

Once all dependencies installed, run the following command to install GCSF:

$ cargo install gcsf

3.2. Mount Google Drive Locally As Virtual File System Using GCSF

First, we need to authorize our google drive. To do so, simply run:

$ gcsf login ostechnix

You must specify a session name. Replace ostechnix with your own session name. You will see an output something like below with an URL to authorize your google drive account.

Authorize google drive
Authorize google drive

Just copy and navigate to the above URL from your browser and click allow to give permission to access your google drive contents. Once you gave the authentication you will see an output like below.

Successfully logged in. Credentials saved to "/home/sk/.config/gcsf/ostechnix".

GCSF will create a configuration file in $XDG_CONFIG_HOME/gcsf/gcsf.toml, which is usually defined as $HOME/.config/gcsf/gcsf.toml. Credentials are stored in the same directory.

Next, create a directory to mount your google drive contents.

$ mkdir ~/mygoogledrive

Then, edit /etc/fuse.conf file:

$ sudo vi /etc/fuse.conf

Uncomment the following line to allow non-root users to specify the allow_other or allow_root mount options.

user_allow_other

Save and close the file.

Finally, mount your google drive using command:

$ gcsf mount ~/mygoogledrive -s ostechnix

Sample output:

INFO gcsf > Creating and populating file system...
INFO gcsf > File sytem created.
INFO gcsf > Mounting to /home/sk/mygoogledrive
INFO gcsf > Mounted to /home/sk/mygoogledrive
INFO gcsf::gcsf::file_manager > Checking for changes and possibly applying them.
INFO gcsf::gcsf::file_manager > Checking for changes and possibly applying them.

Again, replace ostechnix with your session name. You can view the existing sessions using command:

$ gcsf list
Sessions:
- ostechnix

You can now access your google drive contents either from the Terminal or from File manager.

From Terminal:

$ ls ~/mygoogledrive

From File manager:

Mount Google Drive Locally As Virtual File System Using GCSF
Mount Google Drive Locally As Virtual File System Using GCSF

If you don't know where your Google drive is mounted, use df or mount command as shown below.

$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 968M 0 968M 0% /dev
tmpfs 200M 1.6M 198M 1% /run
/dev/sda1 20G 7.5G 12G 41% /
tmpfs 997M 0 997M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 997M 0 997M 0% /sys/fs/cgroup
tmpfs 200M 40K 200M 1% /run/user/1000
GCSF 15G 857M 15G 6% /home/sk/mygoogledrive
$ mount | grep GCSF
GCSF on /home/sk/mygoogledrive type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,allow_other)

Once done, unmount the google drive using command:

$ fusermount -u ~/mygoogledrive

Check the GCSF GitHub repository for more details.

4. Tuxdrive

Tuxdrive is yet another unofficial google drive client for Linux. We have written a detailed guide about Tuxdrive a while ago. Please check the following link.

Conclusion

In this guide, we have discussed about four unofficial Google drive client applications to mount Google drive locally as a virtual file system and access the Google drive contents from the file manager in Linux system.

Of course, there were few other unofficial google drive clients available in the past, such as Grive2, Syncdrive. But it seems that they are discontinued now. I will keep updating this list when I come across any active google drive clients.

You May Also Like

22 comments

Gotit July 8, 2020 - 11:45 pm

For rclone, I had to explicitly set the –vfs-cache-mode flag to writes so I could open and work with files on Google Drive. So my mount line looks like this:
$ rclone mount mygoogledrive: ~/drive/ –vfs-cache-mode writes

note: that’s 2 dashes without a space before the vfs. This site converts it to a long dash.

Reply
Henry July 15, 2020 - 11:25 am

Very comprehensive approach, even for me that I’m new to command line stuff and I just find it useful. Please just make it clear that this process do/do not take disc space. Thank you very much, helped a lot!! Most of the linux tutorials over there are just scaring to understand and to follow.

Reply
Daniel October 27, 2020 - 6:07 am

Extremely useful! I thank you and your team for this guide.

Reply
bin November 8, 2020 - 12:48 pm

@James H hello, its work fine

Reply
Matheus Kramer February 14, 2021 - 8:59 pm

What about the most important function, to move things to the drive and free space? That is slow using browsers and should be the default. Just sync is barely useless.

Reply
Daniel September 15, 2021 - 2:32 pm

Thx for this tutorial.

I have another question related to this topic, after mounting my Google Drive in Linux, I would like to integrate this folder in Nextcloud (via external storage > local) but for some reason I can’t integrate my Google Drive folder. Every other folder works, just this not. Furthermore, I tried these comments:

sudo chown -R www-data:www-data /path/to/localdir
sudo chmod -R 0750 /path/to/localdir

But I just get an error message “Permission denied”

Any idea how to integrate my Google Drive folder in Nextcloud?

Reply
sk September 15, 2021 - 3:59 pm

Never tried integrating Google drive in NextCloud. My apologies, I couldn’t help you at the moment. Please post your question in NextCloud forums. Someone might help.

Reply
James May 22, 2022 - 4:32 am

I give up. I’ve been at this for hours and can’t get it working.
xucaen@Cerritos:~$ rclone mount mygoogledrive ~/gdrive/
2022/05/21 19:00:22 ERROR : Local file system at /home/xucaen/mygoogledrive: Statfs failed: directory not found
^Cxucaen@Cerritos:~$
xucaen@Cerritos:~$

Reply
sk May 22, 2022 - 7:09 pm

Make sure you’ve created a new remote (i.e. mygoogledrive) and mount folder (i.e. ~/drive) and then try again. It should work.

Reply
1 2

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More