How to install s3fs in Ubuntu 18.04|20.04|21.04

How to install s3fs in Ubuntu 18.04|20.04|21.04

In this tutorial, we will be looking at installing s3fs on Ubuntu 20.04. s3fs is a FUSE-based file system backed by Amazon S3, it allows you to mount an Amazon S3 bucket as a local filesystem.
It stores files natively and transparently in S3 (i.e., you can use other programs to access the same files).

We will use apt-get and apt, to install s3fs on our Ubuntu system.

Installing s3fs in Ubuntu 18.04, 20.04 and 21.04

Installing s3fs using apt-get

We start the process by logging into our system with an account with sudo privileges or as root. And updating the system using the below command.

$ apt-get update -y

After updating the database, we can install s3fs by running the following command:

$ apt-get install s3fs -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
s3fs
0 upgraded, 1 newly installed, 0 to remove and 77 not upgraded.
Need to get 234 kB of archives.
After this operation, 678 kB of additional disk space will be used.
Get:1 http://ke.archive.ubuntu.com/ubuntu focal/universe amd64 s3fs amd64 1.86-1 [234 kB]
Fetched 234 kB in 4s (52.4 kB/s)
Selecting previously unselected package s3fs.
(Reading database ... 71732 files and directories currently installed.)
Preparing to unpack .../archives/s3fs_1.86-1_amd64.deb ...
Unpacking s3fs (1.86-1) ...
Setting up s3fs (1.86-1) ...
Processing triggers for man-db (2.9.1-1) ...

To verify that s3fs is successfully installed, we run the below command:

$ s3fs --version 
Amazon Simple Storage Service File System V1.86 (commit:unknown) with GnuTLS(gcrypt)
Copyright (C) 2010 Randy Rizun <rrizun@gmail.com>
License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Installing s3fs using apt

Update apt database with apt using the following command.

$ apt update -y 
Hit:1 http://ke.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://ke.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://ke.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://ke.archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Fetched 336 kB in 1s (250 kB/s)    
Reading package lists... Done
Building dependency tree       
Reading state information... Done

After a database update, we can now install s3fs using the following command:

$ apt install s3fs -y 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
s3fs
0 upgraded, 1 newly installed, 0 to remove and 77 not upgraded.
Need to get 0 B/234 kB of archives.
After this operation, 678 kB of additional disk space will be used.
Selecting previously unselected package s3fs.
(Reading database ... 71732 files and directories currently installed.)
Preparing to unpack .../archives/s3fs_1.86-1_amd64.deb ...
Unpacking s3fs (1.86-1) ...
Setting up s3fs (1.86-1) ...
Processing triggers for man-db (2.9.1-1) ...

Verify the successful installation of s3fs.

$ s3fs --version 
Amazon Simple Storage Service File System V1.86 (commit:unknown) with GnuTLS(gcrypt)
Copyright (C) 2010 Randy Rizun <rrizun@gmail.com>
License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Creating S3fs Credentials file

Now we need to create a credentials file to hold our S3 object storage key and secret. Once you have the values for your key and secret, place them in a text file in your home directory (~/.passwd-s3fs) or in another location you prefer. The key and secret should be separated by a colon.

$ echo ACCESS_KEY:SECRET_KEY > ~/.passwd-s3fs

Secure the file credentials by setting the correct access permissions, by typing the below command:

$ chmod 600  ~/.passwd-s3fs

Verify the file permission:

$ ls -alts 
total 40
4 -rw-------  1 root root   62 Sep 28 13:35 .passwd-s3fs

Mounting S3 Bucket on Ubuntu Filesystem

Create a folder to mount the S3 bucket at your preferred location.

$ mkdir /mnt/backups/

To mount the S3 bucket on the server, type the command:

$ s3fs mys3_bucket_name /mnt/backups/ -o passwd_file=~/.passwd-s3fs -o url=https://s3-af-south-1techiescode.com -o use_path_request_style -o dbglevel=info

To verify the S3fs on the Ubuntu filesystem table if properly mounted.

$ df -h | grep s3fs
s3fs                               256T     0  256T   0% /mnt/backups

Conclusion

You successfully installed s3fs in Ubuntu 20.04, we have also looked at how to install, create and mount our bucket. That should give you an added scope in your journey to start using and working with s3fs. Thank you!

How to Install 3CX Phone System V18.0 in Debian 10

How to Install Docker Container Engine in CentOS 7

How to Install MariaDB on Ubuntu 18.04|20.04|22.04

Leave a Reply

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

two × five =