How to mount a bucket on Linux with s3fs
Linux brings the advantage of having a large number of open source solutions to access the Simple Object Storage. One of these is S3FS.
Warning
The Object Storage is not a disk drive! Using it as a storage backend with a database or similar from multiple machines may have unintended consequences.
Prerequisites
Before you start this guide, you will need to:
-
Create a SOS Bucket, either via the Portal or the CLI. See the Simple Object Storage documentation for more information.
-
Create an IAM key, also via the Portal or the CLI. See the IAM documentation for more information.
Installation
S3FS is supplied as a package in most Linux distributions, which makes the installation simple. Execute the following commands on a root console.
Note
S3FS could not show the file sizes before version 1.84. If you see only 0-byte files, update your S3FS version.
Ubuntu Linux 16.04 or higher, Debian Linux 9 or higher
apt install s3fs
RHEL 7 or newer, using EPEL:
yum install epel-release
yum install s3fs-fuse
SUSE 12 and openSUSE 42.1 or newer:
zypper install s3fs
Storing your access key
Save your access key as the root user:
echo API-KEY-HERE:API-SECRET-HERE > /root/.passwd-s3fs
Change its permissions:
chmod 0600 /root/.passwd-s3fs
Create a Folder
To mount the bucket, create an empty folder. This can be located in /mnt/sos
:
mkdir /mnt/sos
Mount by Hand
Before we add the mount point permanently, you can try it by hand:
s3fs BUCKET-NAME-HERE /TARGET/DIRECTORY -o use_path_request_style -o url=https://sos-EXOSCALE-ZONE-ID.exo.io/
For example:
s3fs my-testbucket /mnt/sos -o use_path_request_style -o url=https://sos-at-vie-1.exo.io/
Automated Mount
To mount the object storage automatically at system start, edit the /etc/fstab
file.
Warning
This file is required for a correct system start. If you make a mistake, your system may not boot. Make sure to read up on the restore procedure and create a backup (such as a snapshot) before you proceed.
Insert the following line followed by a new line character:
s3fs#BUCKET-NAME /TARGET/DIRECTORY fuse _netdev,allow_other,use_path_request_style,url=https://sos-EXOSCALE-ZONE-ID.exo.io/ 0 0
For example:
s3fs#my-testbucket /mnt/sos fuse _netdev,allow_other,use_path_request_style,url=https://sos-at-vie-1.exo.io/ 0 0
Now you can mount the folder.
mount -a