Cloud Storage FUSE 


Cloud Storage FUSE uses FUSE and Cloud Storage APIs to transparently expose buckets as locally mounted folders on your file system. Cloud Storage FUSE can be run from anywhere with connectivity to Cloud Storage, including Google Kubernetes Engine, Compute Engine VMs, or on-premises systems.

Install FUSE Installer info (Ubuntu/Debian latest releases):

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 -

Install gcsfuse:

sudo apt-get update
sudo apt-get install gcsfuse

Check the current gcloud credentials to see what gcsfuse will use:

gcloud auth list

Create a mount point and mount:

BUCKET_NAME=my-bucket-4312

mkdir $BUCKET_NAME
gcsfuse --implicit-dirs $BUCKET_NAME $BUCKET_NAME

Add a file and test that it’s indeed on GCS:

cd $BUCKET_NAME
echo "gcs fuse is cool!" > file.txt

cd
gsutil cat gs://$BUCKET_NAME/file.txt

Double-check your user’s ID and GID so you can mount on non-root (and note these for the following step):

id

Add an entry to /etc/fstab to mount every time automatically when the VM boots using your UID and GID as well as bucket name:

sudo vim /etc/fstab

# insert:
my-bucket-4312 /home/dhodun/my-bucket-4312 gcsfuse rw,implicit_dirs,_netdev,allow_other,uid=1002,gid=1003

Restart the VM and test to ensure that the bucket is always mounted at bootup:

sudo shutdown -r now

# on restart
ls my-bucket-4312

Gcsfuse is a great convenience tool for mounting and accessing GCS blobs. It is not a production replacement for a traditional file store—for that, consider Filestore—and lacks many features of a true POSIX filesystem as well as some GCS features such as metadata. You might use it to save on cost (Filestore is about 10x the price per gigabyte) or because you are trying to access data that is largely used and generated by systems compatible with GCS and you need a one-off workaround.