How to mount Google Cloud Storage inside a Linux machine
Jump to navigation
Jump to search
Create credentials file
- Login to the GCP console:
- From the upper pane, select the target GCP project
- Login to the link below to create a new service account key:
- Service account -> select New service account:
- Service account name: Specify an informative name for the new service account
- Role: Select Storage -> Storage object admin
- Key type: JSON
- Click on Create
- Save the newly created JSON file in a secured location
- Click on Close
GCFuse installation
- Login using SSH to the target Linux machine using privileged account.
- Follow the instructions below to install the Cloud storage Fuse adapter:
- Copy the JSON file created above into ~/
- Rename the JSON file:
- mv ~/Myfile.json ~/key.json
- Note: Replace Myfile.json with the actual JSON file
Mount phase
- Run the commands below to mount the Google Cloud Storage:
- sudo mkdir /dev/cloudstorage
- sudo chown MyUser:MyUser /dev/cloudstorage/
- sudo chmod 777 /dev/cloudstorage/
- gcsfuse --implicit-dirs --key-file ~/key.json StorageName /dev/cloudstorage
- Note 1: Replace MyUser with the username you have logged into the Linux machine
- Note 2: Replace StorageName with the target Google storage bucket name
- To view the content of the Google cloud storage bucket, switch to the new mount point:
- cd /dev/cloudstorage
Unmount phase
- When completing the work on the bucket, from the Linux SSH console, and run the commands below to unmount the Google Cloud Storage:
- cd ~
- sudo fusermount -u /dev/cloudstorage
- Logoff the Linux machine