How to mount Amazon S3 Storage inside a Linux machine
Jump to navigation
Jump to search
Creating IAM user
- Login to the IAM console:
- From the left pane, click on Users -> click on “Add user” -> specify the user name -> access type: “Programmatic access” -> do not select “AWS Management Console access” -> click “Next: Permissions”
- From the “add user to group”, click on “Create group” -> from the policy list, select “AmazonS3FullAccess” -> click “Next: Review” -> click on “Create user”
- Download the CSV file with the “Access key ID” and “Secret access key” and save the CSV file in a secure location
- Click Close
S3FS installation
- Login using SSH to the target Linux machine using privileged account.
- Follow the instructions below to install the S3FS Fuse adapter:
- Run the command sudo vi /etc/passwd-s3fs to create config file with the following content:
- bucketName:accessKeyId:secretAccessKey
- Note 1: Replace bucketName, with the target bucket name
- Note 2: Replace accessKeyId, with the relevant value from the credentials created on the IAM console
- Note 3: Replace secretAccessKey, with the relevant value from the credentials created on the IAM console
- Change the permissions of the passwd-s3fs file (Amazon Linux):
- sudo chown ec2-user:ec2-user /etc/passwd-s3fs
- sudo chmod 600 /etc/passwd-s3fs
- Change the permissions of the passwd-s3fs file (Ubuntu):
- sudo chown ubuntu:ubuntu /etc/passwd-s3fs
- sudo chmod 600 /etc/passwd-s3fs
Mount phase
- Run the commands below to mount the Amazon S3 storage (Amazon Linux):
- sudo mkdir -p /dev/cloudstorage
- sudo chown -R ec2-user:ec2-user /dev/cloudstorage/
- sudo chmod 777 /dev/cloudstorage
- /usr/bin/s3fs MyBucket /dev/cloudstorage -o passwd_file=/etc/passwd-s3fs
- Note: Replace MyBucket, with the target bucket name
- Run the commands below to mount the Amazon S3 storage (Ubuntu):
- sudo mkdir -p /dev/cloudstorage
- sudo chown -R ubuntu:ubuntu /dev/cloudstorage/
- sudo chmod 777 /dev/cloudstorage
- /usr/bin/s3fs MyBucket /dev/cloudstorage -o passwd_file=/etc/passwd-s3fs
- Note: Replace MyBucket, with the target bucket name
- To view the content of the Amazon S3 bucket, switch to the new mount point:
- cd /dev/cloudstorage
Unmount phase
- en completing the work on the bucket, from the Linux SSH console, and run the commands below to unmount the Amazon S3 Storage:
- cd ~
- sudo fusermount -u /dev/cloudstorage
- Logoff the Linux machine