
In this tutorial will show you how to mount Google Cloud Storage (GCS) Bucket on Compute Engine or Linux.
We use Google Cloud Storage FUSE tool or gcsfuse, gcsfuse has been tested successfully with the following operating systems:
- Linux (minimum kernel version 3.10)
- OS X (minimum version 10.10.2)
It may or may not work correctly with other operating systems and older versions.
If you are running on Google Compute Engine, it is recommended that you use one of the following images with which it has been tested (preferring the latest version when possible):
- ubuntu-2004-lts, ubuntu-1804-lts, ubuntu-1604-lts, and ubuntu-1404-lts
- debian-8, debian-7
- centos-8, centos-7
- rhel-7
- sles-12
Prerequisites
For this tutorial i use the following setup:
- Compute Engine Instance with Ubuntu 18.04 LTS
- Hetzner VPS with CentOS 7
Install gcsfuse on Ubuntu 18.04 LTS
-
Add gcsfuse repository with the following command
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s` echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
-
Update and install gcsfuse
sudo apt-get update sudo apt-get install gcsfuse
-
Verify that gcsfuse is installed successfully
gcsfuse -v
Install gcsfuse on CentOS 7
-
Add gcsfuse repository with the following command
sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF [gcsfuse] name=gcsfuse (packages.cloud.google.com) baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF
-
Install gcsfuse
sudo yum install gcsfuse
-
Verify that gcsfuse is installed successfully
gcsfuse -v
Add Credentials
We will the simple setting credentials using google account associated with the Google Cloud Storage, For default, Google Cloud SDK (gcloud) is already installed on Compute Engine Instance. Optionally If not, install gcloud using this tutorial https://cloud.google.com/sdk/docs/install and make sure to set the project
Run the following command to set credentials for gcsfuse
gcloud auth application-default login
If there is prompt asking Do you want to continue (Y/n)? type y and hit enter


Mount GCS Bucket
-
First create directory for the mount location, for example we can create directory on user home folder /home/<user>/gcsbucket
cd ~ pwd mkdir gcsbucket
-
Mount gcs bucket using the following command
change <bucket-name> with your bucket name and <user> with your usernamegcsfuse <bucket-name> /home/<user>/gcsbucket
-
[Optional] If you want to only mount specific folder in the bucket you can use this command
gcsfuse --only-dir
<bucket-name> /home/<user>/gcsbucket
Bucket mounting success, now you can check by cd to /home/<user>/gcsbucket. Also try creating directory or creating and copying files, after that verify the folder or files created by going to Google Cloud Storage (GCS) Bucket in Google Cloud Console.

File and Folder created are automatically showing up on Google Cloud Storage (GCS) Bucket in Google Cloud Console

Useful links
Google Cloud Storage Documentation : https://cloud.google.com/storage/docsGoogle Cloud Storage FUSE tool : https://github.com/GoogleCloudPlatform/gcsfuse
Installing Google Cloud SDK : https://cloud.google.com/sdk/docs/install