X
  • July 11, 2019

Mounting an Object Storage Bucket as File System on Oracle Linux

Marcin Zablocki
Solutions Architect

Recently, I found that I need to move a lot of automatically generated report files to Object Storage for easy delivery. I could do this in one of several ways: by writing a Python script using Oracle Cloud Infrastructure SDKs, using pre-authenticated requests, writing curl and bash scripts. But I thought it would be nice to access Object Storage content directly using a file system without having to change any of my existing automation scripts.

Thanks to the s3fs-fuse project and Oracle Cloud Infrastructure's S3 compatible API, this is possible and pretty easy to do.

For this tutorial, you need an Oracle Cloud Infrastructure account, an Oracle Linux 7 compute instance, SSH, and about 10 minutes. Let's start!

Step 1: Install s3fs-fuse

You can install s3fs-fuse either from source or by using a prebuilt package from EPEL. In this post, I'm using the binary RPM.

yum install https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/s/s3fs-fuse-1.85-1.el7.x86_64.rpm

Step 2: Configure Credentials

In the Oracle Cloud Infrastructure Console, click the Profile icon in the top-right corner, and select User Settings.

Click Customer Secret Keys, and then click Generate Secret Key.

Give the key a meaningful name (for example, s3fs-access), and then click Generate Secret Key

Copy and save the secret key because it won't be shown again.

The S3 credentials are created by using an access key and the secret key. The access key is displayed in the Customer Secret Keys area of the Console.

Enter your credentials in a ${HOME}/.passwd-s3fs file and set owner-only permissions:

echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ${HOME}/.passwd-s3fs chmod 600 ${HOME}/.passwd-s3fs

Step 3: Mount the File System

Run the mount by using the following command:

s3fs [bucket] [destination directory] -o passwd_file=${HOME}/.passwd-s3fs -o url=https://[tenancy].compat.objectstorage.[region].oraclecloud.com/ -onomultipart -o use_path_request_style

As shown, S3-compatible endpoints are built in the following format:

mynamespace.compat.objectstorage.aa-region-1.oraclecloud.com

If you are using the opc user, you will see the following error:

fuse: failed to exec fusermount: Permission denied

Run the following command, and then try again:

sudo chmod +x /usr/bin/fusermount

Now you can use the Object Storage bucket as a mostly POSIX-compliant file system.

Free Trial

If you don't have an Oracle Cloud Infrastructure account, you can sign up for a free trial and get US$300 in free credits.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.