• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to mount s3 bucket in linux EC2 instance

March 8, 2013 by Sharad Chhetri 12 Comments

How to mount s3 bucket in linux EC2 instance

Learn how to mount s3 bucket in linux EC2 instance.
Tested in : EC2 and EC2-beanstalk instances

If you have not created a s3 bucket kindly go through with EC2 documentation.The documentation is very clear and easy to understand .This is the link how to create S3bucket

After creating a new bucket follow the given below steps.

Step 1: Download the latest s3fs package from S3fs link

http://s3fs.googlecode.com/files/s3fs-1.63.tar.gz

Step 2: Untar the package in EC2 instance.

tar -xvzf s3fs-1.63.tar.gz

Step 3: If it is new centos or ubuntu instance. Update the system .

For CentOS or Red Hat

yum update all
For Ubuntu

sudo apt-get update

Step 4: Now install the dependencies.

In CentOS or Red Hat

yum install gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel openssl-devel mailcap
In Ubuntu or Debian

apt-get install build-essential gcc libfuse-dev fuse-utils libcurl4-openssl-dev libxml2-dev mime-support build-essential libcurl4-openssl-dev

Step 5: Now change to extracted directory

cd s3fs-1.63

Step 6: Now compiling

./configure  --prefix=/usr

make

make install

Step 7: To check where s3fs command is placed in O.S. It will also tell you the installation is ok.

which s3fs

Step 8: Now getting the access key and secret key.
Click on AWS Menu -> Your AWS Account Name -> Security Credentials

Note:
The option is at top Right corner of the aws console page

Here you can see access key and secret key (secret key is visible when you click on show tab)

Copy these both keys seperately

Step 9 : Create a new file in /etc with the name passwd-s3fs

Paste the access key and secret key in this manner .

accesskey:secretkey

Note: colon (:) is require in between of both keys.

for eg.

Access key: bwbshjklwmsysiene7hh

Secret key
: jdjbeeosakw3389

vi /etc/passwd-s3fs

bwbshjklwmsysiene7hh:jdjbeeosakw3389

save and exit from file.

Note: I just gave an eg. of keys by randomely typing the letters. But you have to only paste the keys which you have obtained from "Security Credential" tab -see step 8

Step 10: change the permission of file

chmod 640 /etc/passwd-s3fs

Step 11 : now create a directory to mount S3bucket

mkdir /mys3bucket


Step 12:
Now mount the s3 bucket

s3fs bucketname /mys3bucket

Note: you can get bucket name from S3 management console.

Step 13: To check mounted s3 bucket

df -Th /mys3bucket

Step 14 : If you already had some data in s3bucket and it is not visible then you have to set permission in ACL at S3 AWS management console for related s3 bucket.

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to enable direct ssh to EC2 linux instance without keypair file
  2. How to set Name of EC2 instance by aws cli
  3. Be carefull while using phpinfo script in EC2 beanstalk
  4. Create and Remove AWS EC2 key pair by using command line
  5. How to create iso file from CD/DVD and how to mount .iso file in folder
  6. What is /dev/shm and how to mount /dev/shm
  7. how to mount NAS storage in owncloud to keep all users data
  8. Attach security groups to existing instance with AWS cli
  9. How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4
  10. How to configure multiple mysql instance in Ubuntu

Filed Under: AWS Tagged With: AWS, ec2, S3 bucket

Reader Interactions

Comments

  1. Sourav Mohanty says

    December 7, 2016 at 3:34 pm

    Can I use this AWS S3 bucket post mount like a normal filesystem (NFS)?

    For example : can I copy files from /home/root to this mount point which is the S3 storage/bucket

    Reply
    • Sharad Chhetri says

      December 7, 2016 at 6:39 pm

      Hi Sourav,

      1. Yes! you can mount the s3 bucket in system.
      2. I hope it is /root not /home/root
      3. Please install latest package. This is an old post I have still not updated. But I can help you here –

      – https://github.com/s3fs-fuse/s3fs-fuse The project is moved to Github now and installation instruction is available in given github link

      Regards
      Sharad

      Reply
  2. sunil says

    February 19, 2016 at 6:52 pm

    Connection established, waiting for welcome message…
    Response: 220 (vsFTPd 2.2.2)
    Command: USER backup
    Response: 530 Permission denied.
    Error: Could not connect to server

    Getting error after connecting to ftp. User default directory set as s3 bucket mounted folder.

    Reply
  3. Slawek says

    September 16, 2015 at 10:03 pm

    Hi, I get the error message “s3fs: MOUNTPOINT: /mys3bucket permission denied.”
    I’ll appreciate for any advice.

    Reply
    • sharad chhetri says

      September 17, 2015 at 4:55 am

      Hello Slawek,

      Check the IAM policy of user which Access key you are using or s3 bucket permission policy in AWS. Do the appropriate changes.
      Note: The post is outdated, I will update this post with new s3fs package soon.

      Regards
      Sharad

      Reply
      • Slawek says

        September 17, 2015 at 9:20 am

        My ec2 instance has s3 full access role assigned. However it looks like ec2-user doesn’t have correct rights to the folder /mys3bucket

        Reply
  4. Jeetendra Garg says

    October 8, 2013 at 8:07 am

    Thanks for this useful information.

    I have created a folder inside s3 bucket, but I can not see these folders in the mounted bucket.

    Folders are public.

    Do I need to set any permission to make this accessible?

    Reply
    • sharad chhetri says

      October 9, 2013 at 3:57 pm

      Yes you have to set permission for S3 bucket from your amazon S3 panel also.

      Reply
  5. Gordon says

    July 29, 2013 at 7:05 pm

    Cool, thank you.

    Reply
    • sharad chhetri says

      July 29, 2013 at 7:26 pm

      Most Welcome

      Regards
      Sharad

      Reply
  6. Gordon says

    July 24, 2013 at 11:21 am

    Hi, Thanks for the step by step guide. Will it stay mounted after re-boot?

    Reply
    • sharad chhetri says

      July 24, 2013 at 4:06 pm

      Thanks Gordon,
      Yes you can mount the s3bucket after reboot,you have to write script and put it into /etc/rc.local file.

      Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

How to add/install Ubuntu fonts in CentOS/Red Hat Linux

Protect from w00tw00t.at.blackhats.romanian.anti-sec

Forward all incoming emails to other SMTP server or gateway

How to page scroll up/down in Linux terminal

Could not find make anywhere!!! Please edit the config section to include the path to make. at ./install.pl line 2101

Password prompt in single user mode is not secure : CentOS/Red Hat

Change the default port number of ssh server

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy