Il est possible qu'une partie ou l'ensemble des informations de cette page ne s'appliquent pas au Cloud de confiance S3NS.
Installer un bucket Cloud Storage à l'aide de Cloud Storage FUSE
Découvrez comment installer un bucket Cloud Storage en tant que système de fichiers local à l'aide de Cloud Storage FUSE afin de pouvoir interagir avec vos objets avec une sémantique de système de fichiers standard.
Dans ce guide de démarrage rapide, vous allez effectuer les tâches suivantes :
Installer Cloud Storage FUSE sur Debian ou Ubuntu
Installer le bucket en tant que dossier sur la machine
Importer un objet dans le bucket
Vous allez utiliser Google Cloud CLI pour créer et gérer l'objet dans votre bucket de stockage. Vous utiliserez la CLI gcsfuse pour installer votre bucket sur votre ordinateur.
Avant de commencer
Pour configurer un projet, procédez comme suit:
-
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.
Accéder à IAM
-
Sélectionnez le projet.
-
Cliquez sur person_add Accorder l'accès.
-
Dans le champ Nouveaux comptes principaux, saisissez votre identifiant utilisateur.
Il s'agit généralement de l'identifiant d'un utilisateur dans un pool d'identités de personnel. Pour en savoir plus, consultez la section Représenter les utilisateurs de pools de personnel dans les stratégies IAM ou contactez votre administrateur.
-
Dans la liste Sélectionner un rôle, sélectionnez un rôle.
-
Pour attribuer des rôles supplémentaires, cliquez sur add Ajouter un autre rôle et ajoutez chaque rôle supplémentaire.
-
Cliquez sur Enregistrer.
-
Install the Google Cloud CLI.
-
Configurez la gcloud CLI pour utiliser votre identité fédérée.
Pour en savoir plus, consultez
Se connecter à gcloud CLI avec votre identité fédérée.
-
Pour initialiser gcloudCLI, exécutez la commande suivante :
gcloud init
- Disposer d'un bucket Cloud Storage que vous souhaitez installer. Si vous n'en avez pas déjà un, créez un bucket.
Installer Cloud Storage FUSE
Pour installer Cloud Storage FUSE, suivez les instructions de la section Installer Cloud Storage FUSE.
Installer le bucket
Pour installer le bucket sur votre système de fichiers local, procédez comme suit:
Générez les Identifiants par défaut de l'application à l'aide de la commande gcloud auth application-default login
:
gcloud auth application-default login
Cloud Storage FUSE charge automatiquement les identifiants.
Créez un répertoire dans lequel installer le bucket de stockage :
mkdir "$HOME/mount-folder"
Installez votre bucket de stockage à l'aide de la commande gcsfuse
:
gcsfuse BUCKET_NAME "$HOME/mount-folder"
Remplacez BUCKET_NAME par le nom du bucket que vous souhaitez installer.
Si l'opération réussit, la commande renvoie un résultat contenant du texte semblable à ce qui suit :
File system has been successfully mounted.
Importer un objet dans le bucket
Pour télécharger un exemple d'objet et l'importer dans le bucket installé, procédez comme suit :

Effectuez un clic droit sur l'image et enregistrez-la sur votre ordinateur, par exemple sur le bureau.
Vous pouvez également télécharger l'image à l'aide de la commande cURL curl -O https://cloud.google.com/storage/images/kitten.png
.
Copiez l'image à partir de son emplacement enregistré dans le dossier où votre bucket est installé, à l'aide de la commande cp
:
cp kitten.png "$HOME/mount-folder/kitten.png"
Vérifiez que l'image a bien été copiée dans votre système de fichiers local et importée dans le bucket en procédant comme suit :
Pour vérifier que kitten.png
a bien été copié sur votre système de fichiers local, exécutez ls
dans le dossier dans lequel votre bucket est installé :
ls "$HOME/mount-folder"
Si l'opération de copie a abouti, le code kitten.png
est renvoyé dans le résultat.
Pour répertorier le contenu de votre bucket, utilisez la commande gcloud storage ls
:
gcloud storage ls gs://BUCKET_NAME
Remplacez BUCKET_NAME par le nom de votre bucket :
Si l'image a bien été importée dans votre bucket, kitten.png
est renvoyé dans la sortie.
Effectuer un nettoyage
Pour éviter que les ressources utilisées sur cette page ne soient facturées sur votre compte Trusted Cloud by S3NS , supprimez-les en procédant comme suit :
Désinstallez le bucket de stockage de votre machine Linux à l'aide de l'outil fusermount
:
fusermount -u "$HOME/mount-folder"
Pour supprimer le bucket et tous les éléments qu'il contient, exécutez la commande gcloud storage rm
avec l'option --recursive
:
gcloud storage rm gs://BUCKET_NAME --recursive
Remplacez BUCKET_NAME par le nom de votre bucket :
Si l'opération réussit, la commande renvoie un résultat semblable à celui-ci :
Removing gs://my-bucket/kitten.png#1676488739323620...
Removing gs://my-bucket/...
Étapes suivantes
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/25 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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."]]