How to Mount a S3 Bucket on Linux Instance?

Step 1: Update the system.

If you are using a new Centos or Ubuntu instance, then update the system using the below commands:

a. For CentOS or Red Hat.

yum update all

b. For Ubuntu.

apt-get update

Step 2: Install the dependencies.

a. In CentOS or Red Hat.

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

b. In Ubuntu or Debian.

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

Step 3: Clone s3fs source code from git.

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

Step 4: Install the code.

Now change to source code directory, compile and install the code with the following commands:

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

Step 5: Check the s3fs command and installation.

Use the below command to check where the s3fs command is placed in OS. It will also tell you the installation is ok.

Step 6: Paste the access key and secret key.

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

Step 7: Change the permission of the file.

Step 8: Mount S3 bucket.

Now create a directory or provide the path of an existing directory and mount S3 bucket in it.

You can make an entry in /etc/rc.local to automatically remount after reboot. Find the s3fs binary file by the which command and make the entry before the exit 0 line as below:

Step 9: Check mounted s3 bucket.

or

Last updated

Was this helpful?