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

Amazon S3 is a cloud based web service interface where we can store and retrieve any amount of data. In order to upload your data, first you need to create an S3 bucket in one of the Amazon regions. In case you want to access this data in Bucket on Linux system you need to Mount S3 Bucket on Linux flavors such as CentOS, RHEL and Ubuntu.

Want to Mount S3 Bucket on Linux?

Use S3FS Solution!!!

In order to mount Mount S3 Bucket on Linux we can use S3FS solution which is FUSE (File System in User Space). Using this we can use commands like cp, mv on the system. In simple word you can mount the s3 bucket on Linux just as another hard disk or Mount point.

Prerequisites:
  1. You must create s3 bucket in AWS console.

    How to Mount s3 bucket on Linux?

    Step 1: Remove Existing Packages

    Login to your Ec2 instance. In case you don’t know how to login Please check this link.
    First of all check whether you have already  installed any existing fuse or S3FS on your server. In case it exists , then remove it to avoid the conflicts on the server.
    For CentOS OR RHEL Users:
    yum remove fuse fuse-s3fs
    For Ubuntu Users:
    sudo apt-get remove fuse

    Step 2: Install dependency Packages.

    Now you must install packages that are required for fuse and s3cmd.
    For CentOS or RHEL users:
    yum install openssl-devel gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel mailcap git automake
    For Ubuntu Users:
    apt-get install build-essential libcurl4-openssl-dev libxml2-dev mime-support

    Step 3: Download and Compile Latest Fuse.

    Change your directory location to /usr/src using cd command then download and compile fuse source code. After compiling, add fuse to kernel. 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

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


Amazon S3 is a cloud based web service interface where we can store and retrieve any amount of data. In order to upload your data, first you need to create an S3 bucket in one of the Amazon regions. In case you want to access this data in Bucket on Linux system you need to Mount S3 Bucket on Linux flavors such as CentOS, RHEL and Ubuntu.


Want to Mount S3 Bucket on Linux?

Use S3FS Solution!!!

In order to mount Mount S3 Bucket on Linux we can use S3FS solution which is FUSE (File System in User Space). Using this we can use commands like cp, mv on the system. In simple word you can mount the s3 bucket on Linux just as another hard disk or Mount point.
Prerequisites:

  1. You must create s3 bucket in AWS console.

How to Mount s3 bucket on Linux?

Step 1: Remove Existing Packages

Login to your Ec2 instance. In case you don’t know how to login Please check this link.
First of all check whether you have already  installed any existing fuse or S3FS on your server. In case it exists , then remove it to avoid the conflicts on the server.

Step 2: Install dependency Packages.

Now you must install packages that are required for fuse and s3cmd.

Step 3: Download and Compile Latest Fuse.

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

Step 4: Download and Compile Latest S3FS

To download the latest version of s3FS change your directory to “/usr/src/” along with below list of commands.

 
#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:Setup Access Key

To configure s3fs you need both access key and secret key of your s3 AWS account .  You can get your security keys Here.
NOTE:Kindly replace the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with your actual key values.
 
# echo AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY > ~/.passwd-s3fs
# chmod 600 ~/.passwd-s3fs

Step 6:Mount S3 Bucket on Linux

The final step would be to mount the s3 bucket on Linux flavors such as CentOS, RHEL and Ubuntu.
For this example, we are using s3 bucket name as “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 your s3 bucket just use normal cd , 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

Be the first to comment

Leave a Reply

Your email address will not be published.


*