AWS

Mount S3 Bucket on Linux System Using S3FS

mount-s3-bucket
mm
Written by Santosh Prasad

s3fs is a file system in User Space (FUSE) based which is used to mount the Amazon s3 buckets. You can use the Linux/Unix command same as another Hard Drive on your server. After mounting the s3 buckets on your system you can simply use the basic Linux commands similar to run on locally attached disks.

In this article I will explain how you can mount the s3 bucket on your Linux system.

If fuse-s3fs and fuse is already install on your system remove it using below command:

# yum remove fuse fuse-s3fs

Install Fuse and fuse-s3fs Packages

To install the fuse and fuse-s3fs you will need to install it dependencies first, type the below command to install its dependencies:

# yum install gcc gcc-c++ openssl-devel libstdc++-devel curl-devel libxml2-devel mailcap

Now download and compile the latest version of fuse.

# cd /tmp/
# wget http://downloads.sourceforge.net/project/fuse/fuse-2.X/2.9.3/fuse-2.9.3.tar.gz
# tar -xzf fuse-2.9.3.tar.gz
# cd fuse-2.9.3
# ./configure --prefix=/usr/local
# make 
# make install
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# ldconfig
# modprobe fuse

Compile The s3fs From Source Code

# cd /usr
# wget https://s3fs.googlecode.com/files/s3fs-1.74.tar.gz
# tar -xzf s3fs-1.74.tar.gz
# cd s3fs-1.74
# ./configure --prefix=/usr/local
# make 
# make install

Setup Access Key

Now create a file in /etc/ called “passwd-s3fs” and paste your access key and secret key in it.

# vi /etc/passwd-s3fs
adfjafjafjajfafa;lfja;fj;ljfd544949

Save and close the file.

Alternatively

# echo AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY > ~/.passwd-s3fs

Set the permission on passwd-s3fs file.

# chmod 600 /etc/passwd-s3fs

Mount The S3 Bucket

Now mount the s3 bucket typing below command:

# mkdir /s3mount                < crate a directory 
# chmod 777 /s3mount
# s3fs  

Now check the s3 mounted bucket using below command:

# df -TH /s3mount

During system reboot mount the s3 bucket editing /etc/fstab.

# vim /etc/fstab
........
......
#s3fs#s3bucket-name:/  /s3mount fuse defaults,uid=root,gid=root,use_cache=/tmp/s3cache 0 0

Save and close.

Mount all the file systems listed in /etc/fstab.

# mount -a 

Check mounted bucket using below command:

# df -Th
Filesystem           Type       Size  Used Avail Use% Mounted on
/dev/xvde            ext4       100.9G  69.5G     0 59% /
tmpfs                tmpfs      1.8G     0  1.8G   0% /dev/shm
s3fs                 fuse.s3fs  256T     0  256T   0% /s3mount

Thanks:)

Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

1 Comment

Leave a Comment