in DevOps, linux

Mounting S3 bucket on Linux Filesystem

A S3 bucket can be mounted in a AWS instance as a file system using S3fs. S3fs is a FUSE file-system that allows you to mount an Amazon S3 bucket as a local file-system. It behaves like a network attached drive, as it does not store anything on the Instance, but user can access the data on S3 from the instance.

Filesystem in Userspace (FUSE) is a simple interface for userspace programs to export a virtual file-system to the Linux kernel. It also aims to provide a secure method for non privileged users to create and mount their own file-system implementations.

Step-1:- Install Latest version of S3FS.

On Ubuntu :

sudo apt-get install automake autotools-dev fuse g++ git libcurl4-gnutls-dev libfuse-dev libssl-dev libxml2-dev make pkg-config

On CentOS :

sudo yum install automake fuse fuse-devel gcc-c++ git libcurl-devel libxml2-devel make openssl-devel

Then compile from master via the following commands:

git clone
cd s3fs-fuse
sudo make install

Step-2:- Use below command to check where s3fs command is placed in O.S. It will also tell you the installation is ok.

$ which s3fs

Step-3:- Getting the access key and secret key.

You will need AWS Access key and Secret key with appropriate permissions in order to access your s3 bucket from your EC2 instance. You can easily manage your user permissions from IAM (Identity and Access Management) Service provided by AWS.

Step-4 :- Create a new file in /etc with the name passwd-s3fs and Paste the access key and secret key in the below format .

echo AWSACCESSKEY:AWSSECRETKEY > /etc/passwd-s3fs
chmod 640 /etc/passwd-s3fs

Step-5:- Now create a directory and mount S3bucket in it. Here, Provide your S3 bucket name in place of “mybucket”.