Google Cloud: GCS FUSE — Mounting Cloud Storage buckets as Filesystem on Linux

Share At:

Introduction

Cloud Storage FUSE is an open source FUSEadapter that allows you to mount Cloud Storage buckets as file systems on Linux or macOS systems.

It also provides a way for applications to upload and download Cloud Storage objects using standard file system semantics.

Cloud Storage FUSE can be run anywhere with connectivity to Cloud Storage, including Google Compute Engine VMs or on-premises systems.

Pre-requisites

Create an Empty Storage Bucket

  1. For Demonstration, we have created an Empty Storage bucket -called “rajeevgcp21-bucket”.

Create a Linux Virtual Machine

  1. In the Navigation menu , click Compute Engine > VM instances.
  2. Click Create.

3. On the Create an Instance page, for Name, type my-vm-1

4. For Region and Zone, select the region as us-central1 and Zone as us-central1-a

5. For Machine type, Select F1-Micro.

6. For Boot disk , click Change and select CentOS 7.

7. Leave the defaults for Identity and API access unmodified.

8. For Firewall, click Allow HTTP traffic.

9. Leave all other defaults unmodified.

10. To create and launch the VM, click Create.

Note: The VM can take about two minutes to launch and be fully available for use.

11. Now click on the SSH Icon next to it. You will see a terminal opens up. Run some commands to validate your settings.

So Far so Good!!

Mount Storage Bucket as Linux filesystem

  1. SSH to the CentOS 7 VM we have just created.
  2. Now we need to perform the FUSE installation. Create a repo called gcsfuse.repo like below:

vi /etc/yum.repos.d/gcsfuse.repo

3. The repo should have below contents:

[gcsfuse]
name=gcsfuse (packages.cloud.google.com)
baseurl=https://packages.cloud.google.com/yum/repos/gcsfuse-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0

4. Install the FUSE application using the command:

sudo yum install gcsfuse

5. Upon successful installation you should see something like below:

6. Now change to root user using below command:

7. Now mount the storage bucket we have created as filesystem using below command:

gcsfuse rajeevgcp21-bucket /test

8. Now Go to our storage bucket and upload a file there. in our case we will be uploading a file called — “testfile1.txt”:

9. Now in our VM, change to the mount point — “/test”. Run ls command, you will see our test file listed there.

Unmounting The filesystem

The gcsfuse tool will exit successfully after mounting the file system. Unmount in the usual way for a fuse file system on your operating system:

  1. For linux machines, use umount command to unmount it.

You will see /test is no longer mounted.

Happy Learning !!!


Share At:
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Back To Top

Contact Us