Problem:
I need to mount a Google Cloud Storage Buckets to file system, and grant access to the web server.
Solution:
Use the Google Cloud Storage FUSE (gcsfuse) tool to mount a Cloud Storage bucket to your Compute Engine instance.
Steps:
Assumption:
- I have a bucket named yctin-bucket
- I want to mount this bucket to /cloud/yctin-bucket/
- I was generated the Google Service Key, and stored into /src/gcloud_service_account.json
Mounting a bucket
1 2 3 4 5 |
# create the directory mkdir -p /cloud/yctin-bucket/ # mount the bucket with 777 permission gcsfuse --key-file=/src/gcloud_service_account.json -o allow_other --dir-mode 777 --file-mode 777 yctin-bucket /cloud/yctin-bucket/ |
To unmount the bucket
1 |
umount /cloud/yctin-bucket/ |
References:
- https://cloud.google.com/compute/docs/disks/gcs-buckets
http://stackoverflow.com/questions/34779921/gcsfuse-gives-a-input-output-error-when-reading-or-writing-to-mounted-directory