Cloud Storage FUSE ti consente di montare un bucket Cloud Storage come file system locale, in modo da poter interagire con i tuoi oggetti utilizzando la semantica del file system standard. In questa guida rapida, installerai Cloud Storage FUSE su Debian o Ubuntu, monterai un bucket come cartella sulla tua macchina e caricherai un oggetto nel bucket.
Utilizzerai Google Cloud CLI per creare e gestire l'oggetto nel bucket di archiviazione e l'interfaccia a riga di comando di Cloud Storage FUSE per montare il bucket sulla tua macchina.
Prima di iniziare
Per configurare un progetto, completa i seguenti passaggi:
-
In the Cloud de Confiance console, on the project selector page, click Create project to begin creating a new Cloud de Confiance project.
Roles required to create a project
To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles. -
Verify that billing is enabled for your Cloud de Confiance 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 Cloud de Confiance 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 Cloud de Confiance console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the identifier for a user in a workforce identity pool. For details, see Represent workforce pool users in IAM policies, or contact your administrator.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - Avere un bucket Cloud Storage da montare. Se non ne hai già uno, crea un nuovo bucket.
Installa Cloud Storage FUSE
Per installare Cloud Storage FUSE, segui le istruzioni riportate in Installa Cloud Storage FUSE.
Monta il bucket
Per montare il bucket sul file system locale, completa i seguenti passaggi:
Genera le Credenziali predefinite dell'applicazione utilizzando il comando
gcloud auth application-default login:gcloud auth application-default login
Cloud Storage FUSE carica automaticamente le credenziali.
Crea una directory in cui montare il bucket di archiviazione:
mkdir "$HOME/mount-folder"
Monta il bucket di archiviazione utilizzando il comando
gcsfuse:gcsfuse BUCKET_NAME "$HOME/mount-folder"
Sostituisci BUCKET_NAME con il nome del bucket che vuoi montare.
In caso di esito positivo, il comando restituisce un output che contiene un testo simile al seguente:
File system has been successfully mounted.
Carica un oggetto nel bucket
Per scaricare un oggetto di esempio e caricarlo nel bucket montato, completa i seguenti passaggi:

Fai clic con il tasto destro del mouse sull'immagine e salvala in un punto qualsiasi del computer, ad esempio sul desktop.
Puoi anche scaricare l'immagine utilizzando il comando cURL
curl -O https://cloud.google.com/storage/images/kitten.png.Copia l'immagine dalla posizione in cui è salvata alla cartella in cui è montato il bucket, utilizzando il comando
cp:cp kitten.png "$HOME/mount-folder/kitten.png"
Per verificare che l'immagine sia stata copiata nel file system locale e caricata correttamente nel bucket, segui questi passaggi:
Per verificare che
kitten.pngsia stato copiato nel file system locale, eseguilssulla cartella in cui è montato il bucket:ls "$HOME/mount-folder"
Se l'operazione di copia è andata a buon fine, nell'output viene restituito
kitten.png.Per elencare i contenuti del bucket, utilizza il comando
gcloud storage ls:gcloud storage ls gs://BUCKET_NAME
Sostituisci BUCKET_NAME con il nome del tuo bucket.
Se l'immagine è stata caricata correttamente nel bucket, l'output restituisce
kitten.png.
Esegui la pulizia
Per evitare che al tuo account Cloud de Confiance by S3NS vengano addebitati costi relativi alle risorse utilizzate in questa pagina, elimina le risorse completando i seguenti passaggi:
Smonta il bucket di archiviazione dalla macchina Linux utilizzando lo strumento
fusermount:fusermount -u "$HOME/mount-folder"
Per eliminare il bucket e tutto ciò che contiene al suo interno, utilizza il comando
gcloud storage rmcon il flag--recursive:gcloud storage rm gs://BUCKET_NAME --recursive
Sostituisci BUCKET_NAME con il nome del tuo bucket.
In caso di esito positivo, il comando restituisce un output simile al seguente:
Removing gs://my-bucket/kitten.png#1676488739323620... Removing gs://my-bucket/...
Passaggi successivi
Visualizza una panoramica dettagliata di Cloud Storage FUSE.
Scopri i modi per montare i bucket per diversi casi d'uso.
Scopri come utilizzare le skill dell'agente Cloud Storage per automatizzare la configurazione del montaggio e della cache con gli assistenti di coding AI.