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

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.

See also  Using the pkill command in the Linux Terminal

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.

See also  Understanding and using the Tcpdump command on Linux

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.

  1. 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.

  1. 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

See also  Install and secure phpMyAdmin on Apache CentOS 7

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.

Install Rust Programming Language In Linux

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.

  1. 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.

Tuxdrive – A Commandline Google Drive Client For Linux

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.

Source: https://ostechnix.com/how-to-mount-google-drive-locally-as-virtual-file-system-in-linux/

Originally posted 2020-09-14 08:20:34.