How to mount Cloud Storage bucket with GCP compute engine

Antrixsh Gupta
2 min readJan 3, 2020

--

Mount Cloud Storage bucket with GCP compute engine

You can use the Google Cloud Storage FUSE tool to mount a Cloud Storage bucket to your Compute Engine instance. The mounted bucket behaves similarly to a persistent disk even though Cloud Storage buckets are object storage.

gcsfuse has been worked successfully with below mentioned 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 (GCE), it is recommended that you use one of the following images with which it has been tested (preferring the latest version when possible):

  • ubuntu-1804-lts, ubuntu-1604-lts, and ubuntu-1404-lts
  • debian-8, debian-7
  • centos-7, centos-6
  • rhel-7, rhel-6
  • sles-12

Linux

If you are running Linux on a 64-bit x86 machine, you need only ensure fuse is installed, then download and install the latest release package. The instructions vary by distribution.

  • Add the gcsfuse distribution URL as a package source and import its public key:
$ export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`$ echo "deb https://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 the list of packages available and install gcsfuse.
$ sudo apt-get update
$ sudo apt-get install gcsfuse
  • Update the list of packages available and install gcsfuse.
  • Create a directory.
$ mkdir /path/to/mount
  • Create the bucket you wish to mount, if it doesn’t already exist, using the Google cloud console.

Use Cloud Storage FUSE to mount the bucket (e.g. example-bucket).

$ gcsfuse example-bucket /path/to/mount
  • Start working with the mounted bucket.
$ ls /path/to/mount 
  • Or you can check the mounted storage bucket as persistent disk by using below command.
$ df -h

Hope, This will help you to connect cloud storage bucket as a mounted persistent disk, but if you reboot your instance in that case storage bucket will not be mounted, so for again mounting the storage bucket you can use $ gcsfuse example-bucket /path/to/mount

--

--

Antrixsh Gupta

Chief Data Scientist and CEO at Danalitic, Certified GCP Architecture, Machine Learning and Cloud Mentor at Google Developers