Amazon S3 is a highly scalable and durable object storage service that allows you to store and retrieve any amount of data from anywhere on the web. S3FS is a FUSE (Filesystem in Userspace) interface for Amazon S3 that allows you to mount Amazon S3 buckets as a local file system on your CentOS or Fedora system. This allows you to easily access and manipulate your S3 data as if it were stored on a local file system. In this article, we’ll show you how to mount an Amazon S3 bucket on a CentOS or Fedora system using S3FS.
Before we begin, make sure that you have the following:
- An Amazon S3 account with at least one bucket created
- An access key and secret key with access to your S3 bucket
- A CentOS or Fedora system with root access
- S3FS installed on your system
Here’s the step-by-step guide to mounting an Amazon S3 bucket on a CentOS or Fedora system using S3FS:
Step 1: Remove Existing Packages
First, check if you have any existing s3fs or fuse packages installed on your system. If installed already remove it to avoid any file conflicts.
yum remove fuse fuse-s3fs
Step 2: Install Required Packages
After removing packages. First, we will install all the dependencies for fuse and s3cmd. Install the required packages to the system using the following command.
yum install gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap
Step 3: Download and Compile Fuse
Download and compile latest version of fuse source code. For this article, we are using fuse version 3.13. Following the set of commands will compile the fuse and add the fuse module to the kernel.
- Downlaod fuse source code:
- Extract the archive file
tar Jxf fuse-3.13.0.tar.xz
- Configure the source code and compile it.
make && make install
- Set the environment variable and enable the fuse module.
Step 4: Download and Compile Latest S3FS
Download and compile latest version of s3fs source code. For this article, we are using s3fs version 1.74. After downloading extract the archive and compile the source code in the system.
- Download the source code from the git repository.
git clone https://github.com/s3fs-fuse/s3fs-fuse.git
- Configure the source code
- Compile and install s3fs
make && make install
Step 5: Create Credentials File
Also In order to configure s3fs, we would require an Access Key and Secret Key of your S3 Amazon account. Get these security keys from Here.
Create a password file to store your access and secret keys:
echo AWS_ACCESS_KEY:AWS_SECRET_KEY > ~/.passwd-s3fs
chmod 600 ~/.passwd-s3fs
Note: Change AWS_ACCESS_KEY and AWS_SECRET_KEY with your actual Amazon S3 access and secret keys. This file stores your access and secret keys securely, and the permissions are set to prevent unauthorized access.
Step 6: Mount S3 Bucket
Create a directory to mount the S3 bucket:
mkdir /tmp/cache /s3-mount
This creates a directory where the S3 bucket will be mounted. You can choose a different directory name as desired.
Modify the permissions for the mount directory:
chmod 777 /tmp/cache /s3-mount
This sets the permissions for the mount directory to allow read/write access for all users.
s3fs -o use_cache=/tmp/cache BUCKET_NAME /s3-mount
Replace BUCKET_NAME with the actual name of your Amazon S3 bucket. This command mounts the S3 bucket at the specified mount directory.
Step 7: Verify Mount
The df command displays the disk usage and mounted file systems on your system. If the S3 bucket is successfully mounted, you should see the mount directory listed with its corresponding S3 bucket name.
That’s it! You have now successfully mounted an Amazon S3 bucket on your CentOS or Fedora system using S3FS. You can now access and manipulate the data in your S3 bucket as if it were stored on a local file system.
In conclusion, mounting an Amazon S3 bucket on a CentOS or Fedora system using S3FS is a simple and effective way to access your S3 data. With S3FS, you can easily access and manipulate your S3 data as if it were stored on a local file system, making it easier to work with your S3 data in your CentOS or Fedora environment.