
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:
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):
For this tutorial i use the following setup:
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
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=0
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
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
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
gcsfuse [bucket-name] /home/[user]/gcsbucket
change [bucket-name] with your bucket name and [user] with your username
[Optional] If you want to only mount specific folder in the bucket you can use this command
gcsfuse --only-dir [folder-name] [/folder-name] [bucket-name] /home/[user]/gcsbucket
change [folder-name] with folder name in your bucket, [bucket-name] with your bucket name and [user] with your username.
Bucket mounting success, now you can check by cd to /home/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
Quick Links
Legal Stuff