Mount a Cloud Storage bucket using Cloud Storage FUSE  |  Google Cloud (2024)

  • Home
  • Cloud Storage
  • Documentation
  • Guides
Stay organized with collections Save and categorize content based on your preferences.

Learn how to mount a Cloud Storage bucket as a local filesystem usingCloud Storage FUSE, so you can interact with your objects using standard filesystem semantics.

In this quickstart, you'll complete the following tasks:

  • Install Cloud Storage FUSE on Debian or Ubuntu

  • Mount the bucket as a folder on the machine

  • Upload an object to the bucket

You'll use the Google Cloud CLI to create and managethe object in your storage bucket, and you'll use thegcsfuse CLI to mount your bucket to your machine.

Before you begin

To set up a project, complete the following steps:

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, click Create project to begin creating a new Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Install the Google Cloud CLI.
  5. To initialize the gcloud CLI, run the following command:

    gcloud init
  6. In the Google Cloud console, on the project selector page, click Create project to begin creating a new Google Cloud project.

    Go to project selector

  7. Make sure that billing is enabled for your Google Cloud project.

  8. Install the Google Cloud CLI.
  9. To initialize the gcloud CLI, run the following command:

    gcloud init
  10. Have a Cloud Storage bucket that you want to mount. If you don't already have one, create a new bucket.

Install Cloud Storage FUSE

To install Cloud Storage FUSE, complete the following instructions using yourlocal shell on Debian or Ubuntu:

  1. Add the Cloud Storage FUSE distribution URL as a package source:

    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
  2. Import the Google Cloud APT repository public key:

    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
  3. Update the list of available packages:

    sudo apt-get update
  4. Install Cloud Storage FUSE and its dependency FUSE:

    sudo apt-get install fuse gcsfuse
  5. When prompted, press Enter to confirm.

  6. Confirm that Cloud Storage FUSE has been installed:

    gcsfuse -v

    If successful, the command returns output similar to the following:

    gcsfuse version 0.41.12 (Go version go1.18.4)

Mount the bucket

To mount the bucket to your local file system, complete the following steps:

  1. Generate Application Default Credentials using thegcloud auth application-default login command:

    gcloud auth application-default login

    Cloud Storage FUSE automatically loads the credentials.

  2. Create a directory to mount the storage bucket to:

    mkdir "$HOME/mount-folder"
  3. Mount your storage bucket using the gcsfuse command:

    gcsfuse BUCKET_NAME "$HOME/mount-folder"

    Replace BUCKET_NAME with the name of the bucket you want to mount.

    If successful, the command returns output which contains text similar to the following:

    File system has been successfully mounted.

Upload an object into the bucket

To download an example object and upload it to the mounted bucket, complete thefollowing steps:

Mount a Cloud Storage bucket using Cloud Storage FUSE | Google Cloud (1)

  1. Right-click the image above and save it somewhere on your computer,such as on the desktop.

    You can also download the image using the cURL commandcurl -O https://cloud.google.com/storage/images/kitten.png.

  2. Copy the image from its saved location to the folder where your bucket ismounted, using the cp command:

    cp kitten.png "$HOME/mount-folder/kitten.png"
  3. Verify that the image was copied to your local file system and uploaded to thebucket successfully by following the steps below:

    1. To check that kitten.png was copied to your local file system, run lson the folder where your bucket is mounted:

      ls "$HOME/mount-folder"

      If the copy operation was successful, kitten.png is returned in theoutput.

    2. To list the contents of your bucket, use the gcloud storage lscommand:

      gcloud storage ls gs://BUCKET_NAME

      Replace BUCKET_NAME with the name of your bucket.

      If the image was successfully uploaded to your bucket, kitten.png isreturned in the output.

Clean up

To avoid incurring charges to your Google Cloud account for the resources usedon this page, delete the resources by completing the following steps:

  1. Unmount the storage bucket from your Linux machine by using the fusermounttool:

    fusermount -u "$HOME/mount-folder"
  2. To delete the bucket and everything inside of it, use thegcloud storage rm command with the --recursive flag:

    gcloud storage rm gs://BUCKET_NAME --recursive

    Replace BUCKET_NAME with the name of your bucket.

    If successful, the command returns output similar to the following:

    Removing gs://my-bucket/kitten.png#1676488739323620... Removing gs://my-bucket/...

What's next

  • Get a detailed overview of Cloud Storage FUSE.
  • Learn how Vertex AI uses Cloud Storage FUSE to mountCloud Storage buckets for custom training jobs.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-06-18 UTC.

Mount a Cloud Storage bucket using Cloud Storage FUSE  |  Google Cloud (2024)

References

Top Articles
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 5809

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.