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.
- Before invoking gcsfuse, you must have a GCS bucket that you want to mount. If your bucket doesn’t yet exist, create one using my previous article —“Google Cloud: Cloud Storage Bucket — Giving Roles and Permissions to an object”.
- Make sure the Google Cloud Storage JSON API is enabled.
Create an Empty Storage Bucket
- For Demonstration, we have created an Empty Storage bucket -called “rajeevgcp21-bucket”.
Create a Linux Virtual Machine
- In the Navigation menu , click Compute Engine > VM instances.
- Click Create.
3. On the Create an Instance page, for Name, type
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
- SSH to the CentOS 7 VM we have just created.
- Now we need to perform the FUSE installation. Create a repo called gcsfuse.repo like below:
3. The repo should have below contents:
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:
- For linux machines, use umount command to unmount it.
You will see /test is no longer mounted.