How to Install S3fs and Mount S3 Bucket on Ubuntu 20.04

February 10, 2023 | By Gerald | Filed in: AWS Administration, AWS Deployment, AWS Operations, AWS Resource Deployment.
Install S3fs and Mount S3 Bucket on Ubuntu 20.04

In this blog, you will learn how to install S3fs and mount an S3 bucket on Ubuntu 20.04 in step-by-step procedure. If you are using Ubuntu 18.04, please refer to the guide available here.

What is S3fs?

S3fs is a FUSE (Filesystem in Userspace) plugin for Amazon S3, which allows you to mount an Amazon S3 bucket as a local file system. It provides a simple way to access S3 storage directly from your file system, making it easy to use S3 as a centralized repository for backups, archives, and data that needs to be accessed from multiple systems.

Use Case

The use case for S3fs is for anyone who needs to access Amazon S3 storage in a more traditional file system interface. This can be especially useful for backing up data, archiving files, or sharing data between different systems. With S3fs, you can interact with S3 as if it were a local file system, making it much easier to automate data transfer and retrieval processes. S3fs is also useful for organizations that use Amazon S3 as their primary storage solution, as it provides a more seamless way to access and manage the data stored there.

Requirements:

  1. AWS Account
  2. S3 bucket (Private)
  3. EC2 Instance (Ubuntu 20.04)
  4. IAM User

Step-by-Step Guide:

Step 1: Install dependencies:

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

Step 2. Clone the s3fs-fuse repository:

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

Step 3. Change to the s3fs-fuse directory:

cd s3fs-fuse

Step 4. Compile and install s3fs:

./autogen.sh
./configure
make
sudo make install

Step 5. Create a directory to mount the S3 bucket:

sudo mkdir /mnt/s3

Step 6. Create an access key and secret key for your AWS IAM user with permission access to AmazonS3FullAccess.

Step 7. Add the access key and secret key to the /etc/passwd-s3fs file:

sudo nano /etc/passwd-s3fs

Add the following lines, replacing <access key> and <secret key> with your own values:

access_key:secret_key

Step 8. Change the file permissions to secure the access keys:

sudo chmod 600 /etc/passwd-s3fs

Step 9. Mount the S3 bucket to the directory:

sudo s3fs <bucket name> /mnt/s3 -o passwd_file=/etc/passwd-s3fs

Step 10. Verify that the S3 bucket is mounted:

ls /mnt/s3

The S3 bucket is now mounted and accessible at /mnt/s3. To make the mount permanent, add the following line to the /etc/fstab file:

s3fs#<bucket name> /mnt/s3 fuse _netdev,allow_other,passwd_file=/etc/passwd-s3fs 0 0

In conclusion, S3fs provides a convenient way to access and manage data stored in Amazon S3 by mounting it as a local file system. By following the steps outlined in this guide, you can easily install S3fs on your Ubuntu 20.04 system and mount an S3 bucket for optimal data management. This solution can streamline your data backup and archiving processes, as well as make it easier to share data between different systems. Give S3fs a try and take advantage of the benefits it provides for managing your data stored in Amazon S3.

Please note that I am not the original creator of the s3fuse project. I am simply providing a guide for others working on similar projects to follow. For more information on s3fuse, please visit the community responsible for building the project.

SHARE THIS ARTICLE

Tags: , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *