How to mount Object storage as opc/orcle user in OCI
We frequently encounter the need to mount object storage as a local file system on the server for backup restoration and transferring large files to object storage. By default, when mounting object storage as a file system, it is mounted as the Root user, leading to permission issues when attempting to move files as opc/Oracle or Non-root users. This document provides guidance on mounting object storage as a non-root user to address these permission challenges.
Object storage can be seamlessly mounted to the file system using the s3fs utility. For comprehensive details on the utility and step-by-step installation instructions, please refer to our blog post:
https://blogs.oracle.com/cloud-infrastructure/post/mounting-an-object-storage-bucket-as-file-system-on-oracle-linux
Install s3fs and then invoke below command to mount the object storage as mount point.
s3fs [bucket] [destination directory] -o endpoint=[region] -o passwd_file=${HOME}/.passwd-s3fs -o url=https://[namespace].compat.objectstorage.[region].oraclecloud.com/ -onomultipart -o use_path_request_style
This will mount the object storage as Root user.
Example
[root@linux7 s3fs-fuse]# s3fs S3 /backup -o endpoint=us-ashburn-1 -o passwd_file=/etc/passwd-s3fs -o url=https://<namespace>.compat.objectstorage.us-ashburn-1.oraclecloud.com/ -onomultipart -o use_path_request_style
[root@linux7 s3fs-fuse]# ls -lrt /backup
-rw-r — — -. 1 root root 133843 Mar 17 2023 image (42).png
-rw-r — — -. 1 root root 2998 Nov 16 06:40 restapi.py
To change the ownership of mounted file system add below arguments along with the above command.
s3fs [bucket] [destination directory] -o endpoint=[region] -o passwd_file=${HOME}/.passwd-s3fs -o url=https://[namespace].compat.objectstorage.[region].oraclecloud.com/ -onomultipart -o use_path_request_style -o allow_other -o umask=0007,uid=1000,gid=1000
-o allow_other — Allowing other users to mount the object storage
-o umask — the mask value for the objects stored in the bucket.
-o uid, gid — It specifies the user id and group id of the user to whom we want to assign the ownership.
Example
[root@linux7 s3fs-fuse]# s3fs S3 /backup -o endpoint=us-ashburn-1 -o passwd_file=/etc/passwd-s3fs -o url=https://<namespace>.compat.objectstorage.us-ashburn-1.oraclecloud.com/ -onomultipart -o use_path_request_style -o allow_other -o umask=0007,uid=1000,gid=1000
[root@linux7 s3fs-fuse]# ls -lrt /backup
-rwxrwx — -. 1 opc opc 133843 Mar 17 2023 image (42).png
-rwxrwx — -. 1 opc opc 2998 Nov 16 06:40 restapi.py
No comments:
Post a Comment