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

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

By sk
13014 Views

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. Read on.

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.

Install Rclone

Rclone can be installed in couple ways.

Install Rclone using installation script:

This is the easiest way to install 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

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 don't have 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

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 (~/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.

Install google-drive-ocamlfuse

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

$ 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

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. The name GCSF has come from the Romanian word "Google Conduce Sistem de Fișiere", which means "Google Drive Filesystem" in English. 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".

Install GCSF

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

$ yay -S gcsf-git

For other distributions, do the following.

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

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.

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.

Suggested read:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

14 comments

Amin July 25, 2018 - 2:54 pm

there is lots of bugs in installing ocaml-base and other stuffs from AUR. So I give it up for now

Reply
kirikopulos October 21, 2018 - 10:03 am

How about rclone, surprised that no one talks about it or compares it with other alternatives.

Reply
sk October 21, 2018 - 11:02 am

Yeah, I forgot to mention it. I will soon add it in this list. Thanks for reminding me.

Reply
Peter April 8, 2019 - 4:47 am

This will never work because you have to be ON the actual linux machine in order to even see the instructions provided after clicking “allow” on the google drive auth page. How can this be done from the TERMINAL ONLY? IE via SSH?

Reply
Doug June 7, 2019 - 2:43 am

google-drive-ocamlfuse: works, but so, so, SOOOOO slow for listing. I was running through strace and saw an average time to stat things in a team drive = 3-5 seconds per item. ouch. It did support team drives though.
gcsf is much better, but still slow compared to an average file system. I could stat about 10 items per second. (pretty poor compared to any other filesystem, but much better than the ocaml version. This does not support team drive mounting.

Reply
l July 11, 2019 - 6:33 am

I would need a way to mount it for free on Windows: it seems impossible to find!

Reply
philnc September 19, 2019 - 11:19 pm

In addition to some pretty severe network latency issues with all these solutions, only one addresses the thorny question of “what to do with Google documents (Google Docs, Sheets, etc)?” As far as I know only only rclone (https://rclone.org/drive/) tries to handle this by converting between a Google and corresponding Microsoft format (although there is an option to specify open formats). Unfortunately my experience has been that the process has imperfections that result in duplicates or errors. The only product I’ve found so far that addresses the problem consistently is Insync (https://help.insynchq.com/en/articles/112840-converting-google-drive-files-for-offline-access). Of course, Insync has just moved from v1.3 to v3.0 of their product, so we’ll have to see if that remains true.

Reply
Nate October 18, 2019 - 4:13 am

Thank you so much for this page! I installed rclone via my repository, and had my google drive mounted virtually within a few minutes, you are a god-send.

Reply
sk October 18, 2019 - 10:57 am

Glad I could help. Keep visiting our blog. Thank you.

Reply
baca manga December 23, 2019 - 5:41 am

after i mount it, can i copy folder that have subfolder and many files on that folder? my plan is, i want to backup lot of file and subfolder automatically to my google drive. please answer me, thanks 🙂

Reply
sk December 23, 2019 - 12:55 pm

Yes, you can.

Reply
James H March 23, 2020 - 7:31 am

rclone instructions reference an item at rclone.org providing instructions for generation and use of one’s own Google “client_id”:
https://rclone.org/drive/#making-your-own-client-id
The instructions must be for an older version of the Google pages accomplishing this setup. Steps 1, 2 and 3 are as described. Step 4 is OK if one looks carefully. Step 5 – setting application type – is not to be found, so step 6, showing client ID and secret never appears.

Anyone make it through this config with current (as of 2020-Mar-22) Google client_id setup?

Reply
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

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. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More