Scopri come montare un bucket Cloud Storage come file system locale utilizzando Cloud Storage FUSE, in modo da poter interagire con gli oggetti utilizzando la semantica standard del file system.
In questa guida rapida completerai le seguenti attività:
Installare Cloud Storage FUSE su Debian o Ubuntu
Montare il bucket come cartella sul computer
Caricare un oggetto nel bucket
Utilizzerai Google Cloud CLI per creare e gestire l'oggetto nel bucket di archiviazione e utilizzerai Cloud Storage FUSE CLI per montare il bucket sul computer.
Prima di iniziare
Per configurare un progetto, completa i seguenti passaggi:
- Accedi al tuo Google Cloud account. Se non conosci Google Cloud, crea un account per valutare le prestazioni dei nostri prodotti in scenari reali. I nuovi clienti ricevono anche 300 $di crediti senza costi per l'esecuzione, il test e il deployment dei workload.
-
In the Google Cloud console, on the project selector page, click Create project to begin creating a new Google Cloud 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 Google 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 Google 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 Google Cloud 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 email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Installa Google Cloud CLI.
-
Se utilizzi un provider di identità (IdP) esterno, devi prima accedere a gcloud CLI con la tua identità federata.
-
Per inizializzare gcloud CLI, esegui questo comando:
gcloud init -
In the Google Cloud console, on the project selector page, click Create project to begin creating a new Google Cloud 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 Google 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 Google 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 Google Cloud 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 email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Installa Google Cloud CLI.
-
Se utilizzi un provider di identità (IdP) esterno, devi prima accedere a gcloud CLI con la tua identità federata.
-
Per inizializzare gcloud CLI, esegui questo comando:
gcloud init - Avere un bucket Cloud Storage che vuoi montare. Se non ne hai già uno, crea un nuovo bucket.
Installare Cloud Storage FUSE
Per installare Cloud Storage FUSE, segui le istruzioni riportate in Installare Cloud Storage FUSE.
Montare 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.
Se l'operazione va a buon fine, il comando restituisce un output contenente testo simile al seguente:
File system has been successfully mounted.
Caricare 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 è stata salvata nella cartella in cui è montato il bucket utilizzando il comando
cp:cp kitten.png "$HOME/mount-folder/kitten.png"
Verifica che l'immagine sia stata copiata nel file system locale e caricata correttamente nel bucket seguendo questi passaggi:
Per verificare che
kitten.pngsia stato copiato nel file system locale, eseguilsnella cartella in cui è montato il bucket:ls "$HOME/mount-folder"
Se l'operazione di copia è andata a buon fine,
kitten.pngviene restituito nell'output.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 bucket.
Se l'immagine è stata caricata correttamente nel bucket,
kitten.pngviene restituito nell'output.
Libera spazio
Per evitare che al tuo Google Cloud account vengano addebitati costi relativi alle risorse utilizzate in questa pagina, elimina le risorse completando i seguenti passaggi:
Smonta il bucket di archiviazione dal computer Linux utilizzando lo strumento
fusermount:fusermount -u "$HOME/mount-folder"
Per eliminare il bucket e tutto ciò che contiene, utilizza il comando
gcloud storage rmcon il flag--recursive:gcloud storage rm gs://BUCKET_NAME --recursive
Sostituisci BUCKET_NAME con il nome del bucket.
Se l'operazione va a buon fine, 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 Vertex AI utilizza Cloud Storage FUSE per montare i bucket Cloud Storage per i job di addestramento personalizzati.