How to mount AWS S3 bucket with Goofys

In this article, we will learn how to mount AWS S3 bucket with Goofys file system. Goofys file system is developed in GO language https://golang.org/  which help to mount AWS S3 bucket as a file system. Currently, it is available only on the Linux based system.

Goofys installation

As I mentioned earlier Goofys is written in Go language so first install GO programming language compiler and runtime. Execute below command to install Go.

Download Go tarball, make sure that you are downloading the version which is 1.8 or higher or Goofy installation may fail. You can download the latest version from  https://golang.org/dl/  site.

# curl -LO https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz

untar the downloaded file and move to /usr/local

# tar -C /usr/local -xvzf go1.9.linux-amd64.tar.gz

Create GO language work directories

#mkdir -p /go/projects/goofys/{bin,pkg,src}

Once the directory created then create a path.sh file inside the /etc/profile.d folder

# vi /etc/profile.d/path.sh

and paste the following line.

export PATH=$PATH:/usr/local/go/bin

Now set GO bin and GO path in bash_profile file

# vi bash_profile

export GOBIN=/go/projects/goofys/bin/
export GOPATH=/go/projects/goofys/

Apply these changes to your current bash session by sourcing both scripts

# source /etc/profile && source ~/.bash_profile

Install GIT Utility

To install Goofys utility from GIT hub we have to install all GIT packages

# yum -y  install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils git-all
# git version
git version 1.8.3.1

Here we are mounting Goofys with fuse utility. So we have to install Fuse utility.

#yum -y install fuse

# go get github.com/kahing/goofys

#go install github.com/kahing/goofys

Now, we have completed goofys installation, next set up your AWS account to access S3 bucket.

Create a file as follows and add your AWS account access key and secret key to communicate with aws.

# vi .aws/credentials

[default]
aws_access_key_id=AKABCDEFGHIJKL
aws_secret_access_key=12345abcdefgh15Gr5

Once you configured it correctly you can list all s3 bucket created under your account by typing the following command. Here my bucket name is “techiescorner”.

Create a directory to mount our s3 bucket.

#mkdir /mybucket

# /go/projects/goofys/bin/goofys techiescorner /mybucket

Here we have mounted our s3 bucket “techiescorner” to “/mybucket”.

Create a test file to confirm that the file that we create in /bucket location will be synced to our s3 bucket

#cd /mybucket

#touch testfile

Then login to your AWS account and go the s3 bucket. Here we can see the file that we just created.

 

4 Comments

Leave a Reply

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