AWS S3 Mount on CentOS 7

Installing Goofys instead of S3FS1 min

1 point

I have used S3FS to mount S3 bucket which is easy to install and works. If your application or service writes heavily and multi-threading it could cause you errors on your files as I faced.

Goofys allows you to mount an S3 bucket as a filey system.

So let's start installing Goofys

$ sudo yum install fuse

Then we install golang:

$ cd ~/
$ wget
$ sudo tar -C /usr/local -xvzf go1.11.8.linux-amd64.tar.gz
$ mkdir -p ~/projects/{bin,pkg,src}
$ rm go1.11.8.linux-amd64.tar.gz

Add the below line /etc/profile.d/ file

$ sudo nano /etc/profile.d/
export PATH=$PATH:/usr/local/go/bin

Add the below two lines to .bash_profile file at the end

$ nano ~/.bash_profile
export GOBIN="$HOME/projects/bin"
export GOPATH="$HOME/projects/src"

To apply changes to your current session, run the below command

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

First let's test if Go works

$ go version
go version go1.11.8 linux/amd64

Now install Goofys from github, it could take few minutes to install

$ go get
$ go install

Now we need to mount the S3 bucket

$ mkdir /mnt/s3mybucket

Add our credentials to a file

$ mkdir .aws
$ nano .aws/credentials

Run the below to mout

$ ~/projects/bin/goofys –region [S3_REGION] –profile s3 [BUCKET_NAME] /mnt/s3mybucket

Check if you have mounted the bucket successfully

$ df -h

You should see your folder /mnt/s3mybucket listed. Go and test by creating a file and check your S3 bucket from AWS console.

To mount the folder on startup you will need to create a new service.

$ nano /etc/systemd/system/goofys.service
# /etc/systemd/system/goofys.service
Description=Goofys daemon

ExecStart=/home/[YOUR_USER]/projects/bin/goofys –region [S3_REGION] –profile s3 [BUCKET_NAME] /mnt/s3mybucket


Then run the below to start the service and check, if it works then enable it and reboot

$ systemctl daemon-reload
$ systemctl start goofys.service
$ df -h
$ systemctl enable goofys.service
$ reboot

Like it? Share with your friends!

1 point


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

Choose A Format
Formatted Text with Embeds and Visuals