This will be a blog post mostly for me on how to mount an Oracle Object Storage on an OCI VM (Virtual Machine) System, as I want to have the steps at my hand.
So the first thing to do is create the Object Storage, you can do this by going to the Hamburger Menu –> Storage–>Object Storage and Archive Storage. Once in that location, select the compartment and click on Create Bucket
When you get to the create page, select a name, which in my case is bucket-rene-ace. I have also selected Auto Tiering to bring down the costs of my bucket for OCI to move infrequently used objects to lower-tiered storage.
Now that the bucket is created, be sure to copy the namespace as you will be needing it when mounting the storage bucket.
After I created the Object Storage Bucket, I need to install the package s3fs-fuse in my VM.
[opc@instance-20230321-1244 ~]$ sudo yum install automake fuse fuse-devel gcc-c++ git libcurl-devel libxml2-devel make openssl-devel -y
Ksplice for Oracle Linux 8 (x86_64) 8.4 MB/s | 2.0 MB 00:00
MySQL 8.0 for Oracle Linux 8 (x86_64) 12 MB/s | 2.8 MB 00:00
...
Complete!
Once I have installed the packages above, I will download s3fs-fuse from git and install it.
[opc@instance-20230321-1244 ~]$ git clone https://github.com/s3fs-fuse/s3fs-fuse.git
Cloning into 's3fs-fuse'...
remote: Enumerating objects: 8950, done.
remote: Counting objects: 100% (206/206), done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 8950 (delta 117), reused 141 (delta 77), pack-reused 8744
Receiving objects: 100% (8950/8950), 5.38 MiB | 6.97 MiB/s, done.
Resolving deltas: 100% (6360/6360), done.
[opc@instance-20230321-1244 ~]$ cd s3fs-fuse
[opc@instance-20230321-1244 s3fs-fuse]$ ./autogen.sh
--- Make commit hash file -------
...
[opc@instance-20230321-1244 s3fs-fuse]$ ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
...
[opc@instance-20230321-1244 s3fs-fuse]$ make
make all-recursive
make[1]: Entering directory '/home/opc/s3fs-fuse'
Making all in src
...
[opc@instance-20230321-1244 s3fs-fuse]$ sudo make install
...
Making install in src
make[1]: Entering directory '/home/opc/s3fs-fuse/src'
make[2]: Entering directory '/home/opc/s3fs-fuse/src'
[opc@instance-20230321-1244 s3fs-fuse]# ls /usr/local/bin/s3fs
/usr/local/bin/s3fs
After installing s3fs, I need to create the customer secret key that will be utilized for accessing the Object Storage. For that, I need to go to my profile
I will click on Customer Secret Keys and then Generate Secret Key
I give it the name of reneace-bucket, and it will generate a Key, make sure to copy that key off to the side.
When the secret is generated, copy the Access Key off to the side as well.
Back to the VM, I create a password file called passwd-reneace-s3fs that will have the Access Key and the Secret Key generated above, separated by a semicolon.
e.g.
<Access Key>: <Secret Key>
[opc@instance-20230321-1244 ~]$ vi .passwd-reneace-s3fs
[opc@instance-20230321-1244 ~]$ chmod 600 .passwd-reneace-s3fs
[opc@instance-20230321-1244 ~]$ cat .passwd-reneace-s3fs
393**************************:zuLey1******************P4
I now have everything in place to mount my object storage in my Virtual Machine, you need to use the following nomenclature to be able to mount your Object Storage. I also added the entry in fstab, so that it is mounted when the VM is rebooted
sudo s3fs <bucket_name> <local_path> -o endpoint=<oci_region_name> -o passwd_file=.passwd-s3fs -o url=https://<object_storage_namespace>.compat.objectstorage.<oci_region_name>.oraclecloud.com/ -onomultipart -o use_path_request_style.
You can use this link to get the OCI_REGION_NAME
[opc@instance-20230321-1244 ~]$ sudo /usr/local/bin/s3fs bucket-rene-ace /home/opc/reneace_bucket/ -o endpoint=ca-toronto-1 -o passwd_file=.passwd-reneace-s3fs -o url=https://yz2****.compat.objectstorage.ca-toronto-1.oraclecloud.com/ -onomultipart -o use_path_request_style -o allow_other
[opc@instance-20230321-1244 ~]$ cd reneace_bucket
[opc@instance-20230321-1244 reneace_bucket]$ ls
[opc@instance-20230321-1244 reneace_bucket]$ echo "Hello Bucket" > hello.txt
[opc@instance-20230321-1244 reneace_bucket]$ cat hello.txt
Hello Bucket
[opc@instance-20230321-1244 ~]$ cat /etc/fstab | grep bucket
s3fs#bucket-rene-ace /home/opc/reneace_bucket fuse _netdev,allow_other,nomultipart,use_path_request_style,passwd_file=/home/opc/.passwd-reneace-s3fs,url=https://yz2*******.compat.objectstorage.ca-toronto-1.oraclecloud.com/ 0 0
And as you can see, now I have the file I created above in my Object Storage Bucket.
The steps are not complex, but I just wanted to have them in one place. I hope they help you if you ever run into this post.