top of page

Mount AWS S3 Bucket On Linux

Amazon S3 (Simple Storage Service) is a scalable, highly durable, and cost-effective cloud storage solution. In many cases, you might want to mount an S3 bucket as a partition on your CentOS server, allowing you to access and manage your data in a familiar file system structure. This blog will guide you through the process of mounting an AWS S3 bucket on Linux.


Prerequisites:

Before you begin, make sure you have the following prerequisites in place:

  1. An Amazon Web Services (AWS) account.

  2. A CentOS server (you can use a virtual private server or a physical machine).

  3. AWS CLI (Command Line Interface) installed and configured on your CentOS server. You can install it with the following command:

Mounting S3 Bucket on CentOS

Follow these steps to mount an S3 bucket on your CentOS server: Step 1: Configure AWS CLI

If you haven't already configured AWS CLI with your AWS credentials, you can do so using the aws configure command. You will need your AWS Access Key ID and Secret Access Key.

[root@siddhesh ~]# aws configure
AWS Access Key ID : ********************************
AWS Secret Access Key : *************************************************
[root@siddhesh ~]# 

Step 2: Install and Configure S3FS S3FS is a FUSE-based file system that allows you to mount an Amazon S3 bucket as a local directory on your CentOS server. You can install S3FS using the following commands:

[root@siddhesh ~]# yum install s3fs-fuse
---
Output Truncated
---
Installed:
  s3fs-fuse.x86_64 0:1.93-1.el7

Dependency Installed:
  fuse.x86_64 0:2.9.2-11.el7                                                 fuse-libs.x86_64 0:2.9.2-11.el7

Complete!
[root@siddhesh ~]#

Step 3: Create a Mount Point

Create a directory on your CentOS server where you want to mount the S3 bucket. For example, let's create a directory named /mnt/buiddevops_bucket:

[root@siddhesh ~]# mkdir -v /mnt/buiddevops_bucket
mkdir: created directory ‘/mnt/buiddevops_bucket’
[root@siddhesh ~]#

Step 4: Mount the S3 Bucket


Now, you can use the s3fs command to mount your S3 bucket. Replace mybucket-siddhesh-test with the actual name of your S3 bucket:

[root@siddhesh ~]# s3fs mybucket-siddhesh-test /mnt/buiddevops_bucket/
[root@siddhesh ~]# 

If the mounting process is successful, you'll see no error messages. Your S3 bucket is now mounted at /mnt/buiddevops_bucket/


Step 5: Verify the Mount You can verify the mount by listing the contents of the mounted S3 bucket:

[root@siddhesh ~]# df -h /mnt/buiddevops_bucket/
Filesystem      Size  Used Avail Use% Mounted on
s3fs            4.0G     0  4.0G   0% /mnt/buiddevops_bucket
[root@siddhesh ~]# ls -lhrt /mnt/buiddevops_bucket/
total 148K
-rw-r-----. 1 root root 148K Jul 21 16:48 MyProject.doc
[root@siddhesh ~]#

Conclusion Mounting an Amazon S3 bucket on CentOS using S3FS can be a convenient way to work with your cloud storage as if it were a local directory. This allows you to easily transfer files, back up data, and perform various operations on your S3 objects directly from your CentOS server. Just remember to configure AWS CLI with your AWS credentials, install S3FS, and create a mount point to get started.



bottom of page