[How-to] Mount Google Cloud Storage Bucket to (FreePBX) Instance as a File System

 

Filesystem in Userspace (FUSE), is an open source adoption functionality provided by Google Cloud Storage (GCS). It allows users to access and operate GCS buckets (for backup, extra storage, ...etc) from their Linux or OS X machines.

Step-by-step guide

Prerequisites

  1. The next two steps (2&3) are not needed if you are running your machine on GCE.

  2. Install the Cloud SDK: 'yum install google-cloud-sdk'.

  3. Run gcloud init to get started: 'gcloud init'.

  4. Before invoking gcsfuse, you must have a GCS bucket that you want to mount. If your bucket doesn't yet exist, create one using the Google Developers Console.

  5. Make sure the Google Cloud Storage JSON API is enabled.

  6. GCS credentials are automatically loaded using Google application default credentials, or a JSON key file can be specified explicitly using --key-file. If you haven't already done so, the easiest way to set up your credentials for testing is to run the gcloud tool: 'gcloud auth login'.

  7. Stop your VM in GCE console, once it’s stopped edit the VM and scroll to the bottom the Cloud API access scopes section. Change the storage API to full access. (stopping the VM is important, you need to reboot for the fstab config to take affect and properly mount, also you must allow full access to the storage api).

  8. Start the VM.

Installing Cloud Storage FUSE and its dependencies

The following instructions set up  yum  to see updates to gcsfuse.

  • Configure the gcsfuse repo:

sudo tee /etc/yum.repos.d/gcsfuse.repo > /dev/null <<EOF

[gcsfuse]

enabled=1

gpgcheck=1

repo_gpgcheck=1

EOF

  • Make the system aware of the new repo:
    'sudo yum update'

Be sure to answer "yes" to any questions about adding the GPG signing key.

  • Install gcsfuse:
    'sudo yum install gcsfuse'

Be sure to answer "yes" to any questions about adding the GPG signing key.

Future updates to gcsfuse will automatically show up when updating with  yum .

Using Cloud Storage FUSE

  • Create a directory.

'mkdir /path/to/mount'

  • Create the bucket you wish to mount, if it doesn't already exist, using the Google Cloud Console.

  • Use Cloud Storage FUSE to mount the bucket (e.g. example-bucket). Important: You should run gcsfuse as the user who will be using the file system, not as root. Do not use sudo.

'gcsfuse example-bucket /path/to/mount'

  • Start working with the mounted bucket.

'ls /path/to/mount'

  • Edit /etc/fstab for automount (this step is important).

'nano /etc/fstab'

'example-bucket /var/spool/asterisk/cloud gcsfuse rw,allow_other,file_mode=777,dir_mode=777'

  • 'mount -a' will mount all filesystems in /etc/fstab.

  • Reboot.

  • Lets test (optional):

'cd /path/to/mount'

'mkdir test'

'touch testfile'

 

[Tip] Change Call Recording Location:

Settings >> Advanced Settings

  • Display Readonly Settings >> Yes.

  • Override Call Recording Location.

 

References

  1. Gcsfuse & freepbx (FreePBX is unable to write to folder mounted with gcsfuse and the sync stops)

  2. Cloud Storage FUSE  |  Google Cloud

  3. GitHub - GoogleCloudPlatform/gcsfuse: A user-space file system for interacting with Google Cloud Storage

Page: [How-to] Install & Secure FreePBX Distro (with commercial modules) on Google Compute Engine

Page: [How-to] Mount Google Cloud Storage Bucket to (FreePBX) Instance as a File System

 

 

Return to Documentation Home I Return to Sangoma Support