How to mount object storage in Linux

S3 is a protocol for storing and retrieving data on and from remote servers. An S3 account is identified by a pair of identifiers, which are called Access Key and Secret Key. These keys act as a username and password for your S3 account.

Usually, external memory for desktop computers is organized as files within a directory. In S3 terminology, a file is called “object” and its name is called “key”. The S3 term for directory (or folder) is “bucket”.

To mount object storage in your Linux computer, you will use command s3fs. S3FS is short for FUSE, which is an acronym for File System in User Space. It will mount files in s3 standard as a local file system.

Prerequisites

No. 1 Hosting

To use s3 protocol, you need a Destination Earth hosting account. It comes with graphical user interface called Horizon:

You can also use s3 commands from terminal in various operating systems.

No. 2 Valid EC2 credentials

The Access Key and Secret Key for access to an s3 account are also called the “EC2 credentials”. See article

How to generate and manage EC2 credentials

That article also contains instructions

  • how to make OpenStack CLI operational as well as

  • how to access the cloud environment.

The result that you are looking for is that the command openstack has become operational.

Check your credentials and save them in a file

Check your credentials with the following command:

openstack ec2 credentials list

where Access token and Secret token will be used in s3fs configuration:

echo Access_token:Secret_token > ~/.passwd-s3fs

That command will store the credentials into a file called passwd-s3fs. Since it starts with a dot, it will be invisible to the usual searches under Linux.

The file will be created in the present directory, but you can also create it anywhere else, for instance, in /etc/ folder and the like.

Change permissions of the newly created file

chmod 600 .passwd-s3fs

Code 600 means you can read and write the file or directory but that none of the other users on the local host will have access to it.

Enable s3fs

Edit configuration file for s3fs command, which is called fuse.conf. Uncomment “user_allow_other” in fuse.conf file, as root:

sudo nano /etc/fuse.conf

Now you are ready to mount object storage to your Linux system. The command looks like this:

s3fs w-container-1 /local/mount/point - passwd_file=~/.passwd-s3fs -o url=https://s3.central.data.destination-earth.eu -o use_path_request_style -o umask=0002 -o allow_other

Note that the command also contains -o allow_other. So you first allow for it in the fuse.conf file and then use it via an -o parameter in the actual s3fs command.

What To Do Next

If you want to access s3 files without mounting to the local computer, use command s3cmd.

How to access private object storage using S3cmd or boto3