How to install S3 Bucket on Linux CentOS, RHEL and Ubuntu using S3FS

Amazon S3 is a web service-based cloud front-end where you can store and retrieve any amount of data. In order to upload your data, you first need to create an S3 bucket. In case you want to access this bucket information on Linux system, you need to mount S3 bucket on Linux versions such as CentOS, RHEL and Ubuntu.

Want to install S3 Bucket on Linux?

Use S3FS solution !!!

In order to mount the S3 bucket on Linux, we can use the S3FS solution, which is FUSE (File System in User Space). With this we can use commands like cp, mv on the system. You can install the s3 bucket on Linux just like another hard drive or mount point.

Prerequisites:

  1. You must create an s3 bucket in the AWS console.

How to install s3 bucket on Linux?

Step 1: Remove existing packages

Log in to your EC2 instance. In case you don’t know how to login, check this link.

First of all check if you have fuse or S3FS installed on the server. If it exists, then delete it to avoid conflicts on the server.

Для пользователей CentOS или RHEL:
# yum remove fuse fuse-s3fs
 
Для пользователей Ubuntu:
$ sudo apt-get remove fuse

Step 2: Install packages with dependencies.

You should now install the packages that fuse and s3cmd require.

Для пользователей CentOS или RHEL:
 
#  yum install openssl-devel gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel mailcap git automake
 
Для пользователей Ubuntu:
 
# apt-get install build-essential libcurl4-openssl-dev libxml2-dev mime-support

Step 3: Download and compile the latest Fuse.

Change the directory location to / usr / src using the cd command, then download and compile the fuse source. After compiling, add the fuse kernel source. In our demo, we are using fuse version 3.0.1.

#cd /usr/src/
#wget https://github.com/libfuse/libfuse/releases/download/fuse-3.0.1/fuse-3.0.1.tar.gz
#tar xzf fuse-3.0.1.tar.gz
#cd fuse-3.0.1
#./configure --prefix=/usr/local
#make && make install
#export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
#ldconfig
#modprobe fuse

Step 4: Download and compile the latest S3FS

In order to download the latest version of S3FS, change your directory to “/ usr / src /” using the list of commands below.

#cd /usr/src/
#wget https://github.com/s3fs-fuse/s3fs-fuse/archive/v1.82.tar.gz
#tar xzf  v1.82.tar.gz
#cd s3fs-fuse-1.82
#./autogen.sh
#./configure --prefix=/usr --with-openssl
#make
#make install

Step 5: Configuring Access Keys

To set up S3FS, you need an access key and private key from your S3 AWS dashboard. You can get security keys here

Note: Please replace AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with your real key values.

# echo AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY > ~/.passwd-s3fs
# chmod 600 ~/.passwd-s3fs

Step 6: Installing S3 Bucket on Linux

The last step will be to mount the s3 bucket on Linux versions such as CentOS, RHEL and Ubuntu.

For this example, we use the s3 bucket name like “1bu“ and mount point as / s3mnt_pt

# mkdir /tmp/cache
# mkdir /s3mnt_pt
# chmod 777 /tmp/cache /s3mnt_pt
# s3fs -o use_cache=/tmp/cache 1bu /s3mnt_pt

In case you want to access s3 Bucket, just use a regular CD and ls command.

# cd /s3mnt_pt
# ll
total 1
d---------. 1 root root 0 Jun 12 10:37 myfolder
# cd myfolder
# ll
total 1
----------. 1 root root 268 Jun 12 10:39 bucket.rtf
# pwd
/s3mnt_pt/myfolder

Conclusion:

So so, we can use the S3FS solution to mount S3 Bucket on Linux versions such as CentOS, RHEL and Ubuntu.

Sidebar