how to mount s3 bucket in linux2 min read

Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

Hi Readers, this document deals with how to mount s3 bucket in linux.
FUSE (Filesystem in Userspace) allows the user to mount the filesystem without changing the kernel code. s3fs is a FUSE filesystem allows the user to mount the s3 bucket in his system. The s3fs code is written in python. It allows non-root users to mount his own bucket in the system. s3 bucket gets mounted in the system like a normal NFS shared folder.

Now let’s see how to achieve this,

Prerequisites
  •  S3 bucket with proper permissions
  •  Access and Secret key.

Install all the dependecy packages,

sudo yum install automake fuse fuse-devel gcc-c++ git libcurl-devel libxml2-devel make openssl-devel // Centos/Redhat
sudo apt-get install automake autotools-dev fuse g++ git libcurl4-gnutls-dev libfuse-dev libssl-dev libxml2-dev make pkg-config //Debian/Ubuntu

Now download the s3fs source code

git clone https://github.com/s3fs-fuse/s3fs-fuse.git

Install s3fs from the source code.

cd s3fs-fuse
./autogen.sh
./configure --prefix=/usr --with-openssl
make
sudo make install

Create access and secret key file

touch /etc/passwd-s3fs

Enter your Access and Secret key in the following format.

vim /etc/passwd-s3fs

accesskey:secretkey

Change permission for the password file.

sudo chmod 640 /etc/passwd-s3fs

Create a mounting folder

mkdir /techrunnr

 

s3fs bucketname /data

Here is the screenshot of after mounting the bucket in the filesystem.


Enter the following in fstab for automounting the s3bucket even after the system reboots.

 

s3fs bucketname /path/to/mountpoint fuse _netdev,allow_other 0 0

If you are getting an error while mounting enable debug to understand the issue.


-o dbglevel=info -f -o curldbg

check this link to how to provide folder wise permission for a IAM user.

 

© 2018, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Related posts

Leave a Reply