# Mount a bucket on Linux with s3fs

{{< recipes-disclaimer >}}

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](https://portal.exoscale.com/) or
the [CLI]({{< ref "/tools/command-line-interface/" >}}).
See the [Simple Object Storage documentation]({{< ref "/product/storage/object-storage/quick-start/" >}})
for more information.

- Create an IAM key, also via the Portal or the CLI. See the
[IAM documentation]({{< ref "/product/security/iam/quick-start/" >}})
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

```bash
apt install s3fs
```

### RHEL 7 or newer, using EPEL:

```bash
yum install epel-release
yum install s3fs-fuse
```

### SUSE 12 and openSUSE 42.1 or newer:

```bash
zypper install s3fs
```

## Storing your access key

Save your access key as the root user:

```bash
echo API-KEY-HERE:API-SECRET-HERE > /root/.passwd-s3fs
```

Change its permissions:

```bash
chmod 0600 /root/.passwd-s3fs
```

## Create a Folder

To mount the bucket, create an empty folder. This can be located in `/mnt/sos`:

```bash
mkdir /mnt/sos
```

## Mount by Hand

Before we add the mount point permanently, you can try it by hand:

```bash
s3fs BUCKET-NAME-HERE /TARGET/DIRECTORY -o use_path_request_style -o url=https://sos-EXOSCALE-ZONE-ID.exo.io/
```

For example:

```bash
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:

```bash
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:

```bash
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.

```bash
mount -a
```

