Install s3fs on Centos 7

s3fs allows Linux users to mount an S3 bucket via FUSE as if it were like any other file system.

Install the EPEL repository.

[root@downloads ~]# yum install epel-release

Then install s3fs.

[root@downloads ~]# yum install s3fs-fuse

Copy public and private keys to ~/.passwd-s3fs.

[root@downloads ~]# echo AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY > ~/.passwd-s3fs
[root@downloads ~]# chmod -v 600 ~/.passwd-s3fs

To test, create the directory you wish to mount your S3 bucket on.

[root@downloads ~]# mkdir /mnt/bucket-test

Then try mounting.

[root@downloads ~]# s3fs downloads-repository /mnt/bucket-test -o passwd_file=${HOME}/.passwd-s3fs

My bucket was empty so I do not currently see anything in my mount directory.

[root@downloads ~]# ls -la /mnt/bucket-test/
total 5
drwx------. 1 root root    0 Jan  1  1970 .
drwxr-xr-x. 3 root root 4096 Mar  4 11:09 ..

Upload an image from the web control panel.

And then check it is sync’d over to your mount directory.

[root@downloads ~]# ls -la /mnt/bucket-test/
total 22
drwx------. 1 root root     0 Jan  1  1970 .
drwxr-xr-x. 3 root root  4096 Mar  4 11:09 ..
----------. 1 root root 17916 Mar  4 11:21 test_logo.png

You may also want to test you can delete the file too.

[root@downloads ~]# rm -v /mnt/bucket-test/test_logo.png 
rm: remove regular file ‘/mnt/bucket-test/test_logo.png’? yes
removed ‘/mnt/bucket-test/test_logo.png’

Currently, if you reboot, the mount will be lost. To make it permanent, make an entry in your fstab.

vim /etc/fstab

My entry looks like this.

s3fs#downloads-repository	/mnt/bucket-test	fuse _netdev,rw,nosuid,nodev,allow_other,nonempty 0 0

If hot already mounted, the below will mount it.

[root@downloads ~]# mount -a

Reboot and use df -h to check its still mounted on start.

[root@downloads ~]# df -h | grep s3fs
s3fs            256T     0  256T   0% /mnt/bucket-test

Be the first to comment

Leave a Reply