Einige oder alle Informationen auf dieser Seite gelten möglicherweise nicht für Trusted Cloud von S3NS.
Cloud Storage-Bucket mit Cloud Storage FUSE bereitstellen
Informationen dazu, wie Sie einen Cloud Storage-Bucket als lokales Dateisystem mit Cloud Storage FUSE bereitstellen, damit Sie mit der Standardsemantik des Dateisystems mit Ihren Objekten interagieren können.
In dieser Kurzanleitung führen Sie die folgenden Aufgaben aus:
Cloud Storage FUSE unter Debian oder Ubuntu installieren
Bucket als Ordner auf dem Computer bereitstellen
Objekt in den Bucket hochladen
Sie verwenden die Google Cloud CLI, um das Objekt in Ihrem Storage-Bucket zu erstellen und zu verwalten, und Sie verwenden die gcsfuse CLI, um Ihren Bucket auf Ihrem Computer bereitzustellen.
Hinweis
So richten Sie ein Projekt ein:
-
In the Trusted Cloud console, on the project selector page,
click Create project to begin creating a new
Trusted Cloud project.
Go to project selector
-
Verify that billing is enabled for your Trusted Cloud project.
-
Make sure that you have the following role or roles on the project:
Storage Admin (roles/storage.admin
), Storage Bucket Viewer (roles/storage.bucketViewer
)
Check for the roles
-
In the Trusted Cloud console, go to the IAM page.
Go to IAM
-
Select the project.
-
In the Principal column, find all rows that identify you or a group that
you're included in. To learn which groups you're included in, contact your
administrator.
-
For all rows that specify or include you, check the Role column to see whether
the list of roles includes the required roles.
Grant the roles
-
In the Trusted Cloud console, go to the IAM page.
Zu IAM
-
Wählen Sie das Projekt aus.
-
Klicken Sie auf person_add Zugriff erlauben.
-
Geben Sie im Feld Neue Hauptkonten Ihre Nutzer-ID ein.
Dies ist in der Regel die Kennung eines Nutzers in einem Workforce Identity-Pool. Weitere Informationen finden Sie unter
Workforce-Pool-Nutzer in IAM-Richtlinien darstellen oder Ihren Administrator.
-
Wählen Sie in der Liste Rolle auswählen eine Rolle aus.
-
Wenn Sie weitere Rollen hinzufügen möchten, klicken Sie auf add Weitere Rolle hinzufügen und fügen Sie weitere Rollen hinzu.
-
Klicken Sie auf Speichern.
-
Install the Google Cloud CLI.
-
Konfigurieren Sie die gcloud CLI für die Verwendung Ihrer föderierten Identität.
Weitere Informationen finden Sie unter
Mit Ihrer föderierten Identität in der gcloud CLI anmelden.
-
Führen Sie folgenden Befehl aus, um die gcloud CLI zu initialisieren:
gcloud init
- Sie benötigen einen Cloud Storage-Bucket, den Sie bereitstellen möchten. Wenn noch nicht geschehen, erstellen Sie einen neuen Bucket.
Cloud Storage FUSE installieren
Folgen Sie der Anleitung unter Cloud Storage FUSE installieren, um Cloud Storage FUSE zu installieren.
Bucket bereitstellen
Führen Sie die folgenden Schritte aus, um den Bucket in Ihrem lokalen Dateisystem bereitzustellen:
Generieren Sie Standardanmeldedaten für Anwendungen mit dem Befehl gcloud auth application-default login
:
gcloud auth application-default login
Cloud Storage FUSE lädt die Anmeldedaten automatisch.
Erstellen Sie ein Verzeichnis, in dem der Storage-Bucket bereitgestellt werden soll:
mkdir "$HOME/mount-folder"
Stellen Sie Ihren Storage-Bucket mit dem Befehl gcsfuse
bereit:
gcsfuse BUCKET_NAME "$HOME/mount-folder"
Ersetzen Sie BUCKET_NAME durch den Namen des Buckets, den Sie bereitstellen möchten.
Wenn der Vorgang erfolgreich war, sollte die Ausgabe in etwa so aussehen:
File system has been successfully mounted.
Objekt in den Bucket hochladen
Führen Sie die folgenden Schritte aus, um ein Beispielobjekt herunterzuladen und in den bereitgestellten Bucket hochzuladen:

Klicken Sie mit der rechten Maustaste auf das Bild und speichern Sie es auf Ihrem Computer, z. B. auf dem Desktop.
Sie können das Bild auch mit dem cURL-Befehl curl -O https://cloud.google.com/storage/images/kitten.png
herunterladen.
Kopieren Sie das Bild aus seinem gespeicherten Speicherort in den Ordner, in dem der Bucket bereitgestellt wird. Verwenden Sie dazu den Befehl cp
:
cp kitten.png "$HOME/mount-folder/kitten.png"
Prüfen Sie anhand der folgenden Schritte, ob das Bild in Ihr lokales Dateisystem kopiert und erfolgreich in den Bucket hochgeladen wurde:
Führen Sie ls
für den Ordner aus, in dem Ihr Bucket bereitgestellt ist, um zu prüfen, ob kitten.png
in Ihr lokales Dateisystem kopiert wurde:
ls "$HOME/mount-folder"
Wenn der Kopiervorgang erfolgreich war, wird kitten.png
in der Ausgabe zurückgegeben.
Verwenden Sie den Befehl gcloud storage ls
, um den Inhalt Ihres Buckets aufzulisten:
gcloud storage ls gs://BUCKET_NAME
Ersetzen Sie BUCKET_NAME durch den Namen Ihres Buckets:
Wenn das Image erfolgreich in Ihren Bucket hochgeladen wurde, wird kitten.png
in der Ausgabe zurückgegeben.
Bereinigen
Mit den folgenden Schritten vermeiden Sie, dass Ihrem Trusted Cloud by S3NS -Konto die auf dieser Seite verwendeten Ressourcen in Rechnung gestellt werden:
Heben Sie die Bereitstellung des Storage-Buckets auf Ihrem Linux-Computer mit dem Tool fusermount
auf:
fusermount -u "$HOME/mount-folder"
Verwenden Sie zum Löschen des Buckets und seines Inhalts den Befehl gcloud storage rm
mit dem Flag --recursive
:
gcloud storage rm gs://BUCKET_NAME --recursive
Ersetzen Sie BUCKET_NAME durch den Namen Ihres Buckets:
Wenn der Prozess erfolgreich war, sollte die Ausgabe in etwa so aussehen:
Removing gs://my-bucket/kitten.png#1676488739323620...
Removing gs://my-bucket/...
Nächste Schritte
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-25 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-25 (UTC)."],[],[],null,["# Mount a Cloud Storage bucket using Cloud Storage FUSE\n\nLearn how to mount a Cloud Storage bucket as a local filesystem using\n[Cloud Storage FUSE](/storage/docs/gcs-fuse), so you can interact with your objects using standard file\nsystem semantics.\n\nIn this quickstart, you'll complete the following tasks:\n\n- Install Cloud Storage FUSE on Debian or Ubuntu\n\n- Mount the bucket as a folder on the machine\n\n- Upload an object to the bucket\n\nYou'll use the [Google Cloud CLI](/sdk/gcloud) to create and manage\nthe object in your storage bucket, and you'll use the\n[gcsfuse CLI](https://github.com/GoogleCloudPlatform/gcsfuse) to mount your bucket to your machine.\n\nBefore you begin\n----------------\n\nTo set up a project, complete the following steps:\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n click **Create project** to begin creating a new\n Google Cloud project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n Make sure that you have the following role or roles on the project:\n\n Storage Admin (`roles/storage.admin`), Storage Bucket Viewer (`roles/storage.bucketViewer`)\n\n #### Check for the roles\n\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3.\n In the **Principal** column, find all rows that identify you or a group that\n you're included in. To learn which groups you're included in, contact your\n administrator.\n\n 4. For all rows that specify or include you, check the **Role** column to see whether the list of roles includes the required roles.\n\n #### Grant the roles\n\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3. Click person_add **Grant access**.\n 4.\n In the **New principals** field, enter your user identifier.\n\n This is typically the email address for a Google Account.\n\n 5. In the **Select a role** list, select a role.\n 6. To grant additional roles, click add **Add\n another role** and add each additional role.\n 7. Click **Save**.\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n- In the Google Cloud console, on the project selector page,\n click **Create project** to begin creating a new\n Google Cloud project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n Make sure that you have the following role or roles on the project:\n\n Storage Admin (`roles/storage.admin`), Storage Bucket Viewer (`roles/storage.bucketViewer`)\n\n #### Check for the roles\n\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3.\n In the **Principal** column, find all rows that identify you or a group that\n you're included in. To learn which groups you're included in, contact your\n administrator.\n\n 4. For all rows that specify or include you, check the **Role** column to see whether the list of roles includes the required roles.\n\n #### Grant the roles\n\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3. Click person_add **Grant access**.\n 4.\n In the **New principals** field, enter your user identifier.\n\n This is typically the email address for a Google Account.\n\n 5. In the **Select a role** list, select a role.\n 6. To grant additional roles, click add **Add\n another role** and add each additional role.\n 7. Click **Save**.\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n1. Have a Cloud Storage bucket that you want to mount. If you don't already have one, [create a new\n bucket](/storage/docs/creating-buckets).\n\n\u003cbr /\u003e\n\nInstall Cloud Storage FUSE\n--------------------------\n\nTo install Cloud Storage FUSE, follow the instructions in [Install Cloud Storage FUSE](/storage/docs/cloud-storage-fuse/install).\n\nMount the bucket\n----------------\n\nTo mount the bucket to your local file system, complete the following steps:\n\n1. Generate Application Default Credentials using the\n `gcloud auth application-default login` command:\n\n ```\n gcloud auth application-default login\n ```\n\n Cloud Storage FUSE automatically loads the credentials.\n2. Create a directory to mount the storage bucket to:\n\n ```\n mkdir \"$HOME/mount-folder\"\n ```\n3. Mount your storage bucket using the `gcsfuse` command:\n\n ```\n gcsfuse BUCKET_NAME \"$HOME/mount-folder\"\n ```\n\n Replace \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e with the name of the bucket you want to mount.\n\n If successful, the command returns output which contains text similar to the following: \n\n ```\n File system has been successfully mounted.\n ```\n\nUpload an object into the bucket\n--------------------------------\n\nTo download an example object and upload it to the mounted bucket, complete the\nfollowing steps:\n\n1. Right-click the image and save it somewhere on your computer,\n such as on the desktop.\n\n You can also download the image using the cURL command\n `curl -O https://cloud.google.com/storage/images/kitten.png`.\n2. Copy the image from its saved location to the folder where your bucket is\n mounted, using the `cp` command:\n\n ```\n cp kitten.png \"$HOME/mount-folder/kitten.png\"\n ```\n3. Verify that the image was copied to your local file system and uploaded to the\n bucket successfully by following the steps:\n\n 1. To check that `kitten.png` was copied to your local file system, run `ls`\n on the folder where your bucket is mounted:\n\n ```\n ls \"$HOME/mount-folder\"\n ```\n\n If the copy operation was successful, `kitten.png` is returned in the\n output.\n 2. To list the contents of your bucket, use the `gcloud storage ls`\n command:\n\n ```\n gcloud storage ls gs://BUCKET_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e with the name of your bucket.\n\n If the image was successfully uploaded to your bucket, `kitten.png` is\n returned in the output.\n\nClean up\n--------\n\nTo avoid incurring charges to your Google Cloud account for the resources used\non this page, delete the resources by completing the following steps:\n\n1. Unmount the storage bucket from your Linux machine by using the `fusermount`\n tool:\n\n ```\n fusermount -u \"$HOME/mount-folder\"\n ```\n2. To delete the bucket and everything inside of it, use the\n `gcloud storage rm` command with the `--recursive` flag:\n\n ```\n gcloud storage rm gs://BUCKET_NAME --recursive\n ```\n\n Replace \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e with the name of your bucket.\n\n If successful, the command returns output similar to the following:\n\n \u003cbr /\u003e\n\n ```\n Removing gs://my-bucket/kitten.png#1676488739323620...\n Removing gs://my-bucket/...\n ```\n\n \u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Get a [detailed overview of Cloud Storage FUSE](/storage/docs/gcs-fuse).\n\n- Read about ways to [mount buckets for different use cases](/storage/docs/cloud-storage-fuse/mount-bucket#examples).\n\n\u003c!-- --\u003e\n\n- Learn how [Vertex AI uses Cloud Storage FUSE](/vertex-ai/docs/training/code-requirements#fuse) to mount Cloud Storage buckets for custom training jobs."]]