Wednesday, May 22, 2024

How to mount an OCI Object Storage Bucket as File System on Linux

I am trying to mount OCI Object Storage bucket as a file system in one of my application server. It will helps me a lot to take backups and in automation I can point this OCI bucket as the destination of scripts output. As OCI object storage is S3 compatible, I am here using S3fs-fuse utility to mount the bucket.

OS : Oracle Linux 9

As a pre-request, please make sure that the compartment you are trying to mount the object storage is S3 compatible.

Go to "Governance & Administration --> Tenancy Details --> Edit object storage settings"


Now follow the below steps.

Step 1 : SSH to your application server

Step 2 : dnf update -y

Step 3 : vi /etc/yum.repos.d/oracle-epel-ol9.repo

Step 4 : Update "enabled=0" to "enabled=1" and save the file

Step 5 : yum install s3fs-fuse -y

Step 6 : Login to OCI console and generate your "Access key" and "Secret key" (keep it safe with you)

Step 7 : SSH to application server

Step 8 : vi /home/opc/.passwd-s3fs

Step 9 : Input your Access key id : Secret key id (Both in one line with a colon separated)

Step 10 : chmod 600 /home/opc/.passwd-s3fs

Step 11 : Create bucket in your OCI account (My bucket name is skynet-upload-bucket)

Step 12 : Identify your OCI region identifier (https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm)

Step 13 : Identify your object storage namespace ("Governance & Administration --> Tenancy Details -->Object storage namespace")

Step 14 : Location of your local path folder in application server (mkdir -p /home/opc/mybucket)

Step 15 : sudo s3fs {oci bucket name} {local path folder} -o endpoint={oci region identifier} -o passwd_file=.passwd-s3fs -o url=https://{object storage namespace}.compat.objectstorage.{oci region idnetifier}.oraclecloud.com/ -onomultipart -o use_path_request_style -o allow_other

Step 16 : Check your mount point (mount | grep s3fs), seems all good.

Step 17 : Now we can test. touch /home/opc/mybucket/testfile.txt

Step 18 : Go to OCI buket (skynet-upload-bucket) and check whether you can see it

Step 19 : Remove the mount point # sudo fusermount -u /home/opc/mybucket

Youtube video about this post : https://youtu.be/QJ6GBPo8F2M



No comments:

Post a Comment