How to mount s3 bucket as a local drive on CentOS ?
Here I’m going to set this up step by step…
We will use s3fs-fuse to integrate amazon s3 bucket into a CentOS Linux machine as a local drive.
Login to your server using PuTTy, login as root or get root permission via sudo command.
yum -y install nano wget automake fuse fuse-devel gcc-c++ git libcurl-devel libxml2-devel make openssl-devel
git clone https://github.com/s3fs-fuse/s3fs-fuse.git
After successful installation we need to get the Amazon S3 bucket details. We need the bucket name, bucket region, access key id, secret access key.
We have to obtain the URL to access the bucket, the URL can be created by knowing the bucket region. Suppose, if you created the bucket on “US East (N. Virginia) us-east-1” the URL will be https://s3-us-east-1.amazonaws.com or, if you created the bucket on “US West (Oregon) us-west-2” region then the URL will be https://s3-us-west-2.amazonaws.com
Once we have the bucket credentials ready we have to create a password text file in /etc directory.
Write your bucket credential as accesskey:secretkey format in the password text file, then save and exit the file. (Note: Remember to give a colon <:> between the access key and secret key)
chmod 600 /etc/passwd-s3fs
I assume here that the local drive name is remotebackup and the s3 bucket name is relyfilestore and the bucket located in “US West (Oregon) us-west-2”
You should replace the bucket name, drive name and URL as yours.
s3fs relyfilestore /remotebackup -o passwd_file=/etc/passwd-s3fs -o url=https://s3-us-west-2.amazonaws.com/ -o use_path_request_style -o dbglevel=info
Add the line of code listed below after the end line of the fstab file, replace the folder names and URL as yours, then save and exit the fstab file.
s3fs#relyfilestore /remotebackup fuse _netdev,allow_other,use_path_request_style,url=https://s3-us-west-2.amazonaws.com 0 0
After restarted the machine check the s3 drive as it in your local drive.
Enjoy unlimited storage !