# Mount S3 bucket to Linux operating system

To mount an S3 bucket to a Linux machine, you can use a tool like **s3fs**&#x20;

Step 1: Install dependencies

```
sudo apt-get update -y
sudo apt-get install s3fs -y
```

Step 2: Store your credentials

Create a credentials file to store your access and secret keys securely

```
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs
chmod 600 ~/.passwd-s3fs
```

Replace `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` with your actual credentials.

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FM8FH6dYYRHuSbuKLmQ7y%2Fimage.png?alt=media&#x26;token=326b5d7a-cd7e-445d-8c30-65884bdf1a22" alt=""><figcaption></figcaption></figure>

Step 3: Create a mount point

Create a directory where the S3 bucket will be mounted:

```
sudo mkdir /mnt/s3bucket
```

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2Fq3RvvSAaiXwMqjPLZmlJ%2Fimage.png?alt=media&#x26;token=be19b655-7e25-4dba-8f2c-be23d2961945" alt=""><figcaption></figcaption></figure>

Step 4:  Mount S3-Compatible Storage with Path-Style Addressing

```
s3fs BUCKET_NAME /mnt/s3bucket -o passwd_file=~/.passwd-s3fs,url=https://YOUR_S3_ENDPOINT,allow_other,use_cache=/tmp,sigv4,use_path_request_style

```

#### Breakdown of the Options:

* `BUCKET_NAME`: Replace this with your actual bucket name.
* `/mnt/s3bucket`: The mount point where the bucket will be mounted.
* `-o passwd_file=~/.passwd-s3fs`: Specifies the path to the file where your credentials are stored (replace with your own credentials file path if necessary).
* url=[https://idr01.zata.ai ](https://idr01.zata.ai) with your S3-compatible service's endpoint.
* `allow_other`: Allows other users to access the mounted directory.
* `use_cache=/tmp`: Caches files locally  `/tmp` to improve performance.
* `sigv4`: Forces Signature Version 4 signing (needed for most S3-compatible services).
* `use_path_request_style`: Forces path-style addressing, which is required for some S3-compatible service

Step 5: Verify the mount&#x20;

```
sudo df -h
```

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FdWs21h13TwJ0ErHSBsNL%2Fimage.png?alt=media&#x26;token=3f63e361-a9e4-4da5-9010-512270cf0199" alt=""><figcaption></figcaption></figure>

Now check to mount to navigate to the directory and create a new file on your system.

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2Fy91XO6WE9m1Ep63wbRD8%2Fimage.png?alt=media&#x26;token=8687304b-fe43-46ef-9445-fbdfe591b34e" alt=""><figcaption></figcaption></figure>

Now back to the Zata.ai dashboard click on the  bucket section, select the bucket, and check the content

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FdMIxHgRJNsbaThEanePL%2Fimage.png?alt=media&#x26;token=3733bf46-f920-4e4a-b4dd-2841f88390f5" alt=""><figcaption></figcaption></figure>

**Lets see file has been created.**

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FI0EDmkZh7MIhxpqT3dWa%2Fimage.png?alt=media&#x26;token=5e18a535-0708-4a57-94c0-4b0e5584a87b" alt=""><figcaption></figcaption></figure>

**To mount an S3-compatible bucket with path-style addressing** **permanently** (so that it is automatically mounted at boot), you can add an entry to your **/etc/fstab** file. Here’s how to configure that:

Open **/etc/fstab** in an editor

```
sudo vi /etc/fstab
```

Add an entry to mount your S3 bucket. The format should look like this:

```
s3fs#Bucket_Name /mnt/s3bucket fuse _netdev,nonempty,allow_other,url=https://idr01.zata.ai,use_path_request_style,passwd_file=/root/.passwd-s3fs 0 0
```

Replace **`BUCKET_NAME`** with your S3 bucket name.

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FzIkL6z50yK1KHvrkNAQt%2Fimage.png?alt=media&#x26;token=96e3240b-ae49-45dc-99de-b9597c8d341f" alt=""><figcaption></figcaption></figure>

Now, check if the mount entry in /etc/fstab works properly by running the following command

```
sudo mount -a
```

Now, reload the daemon service

```
sudo systemctl daemon-reload
```

Now, reboot the system and check the mount directory.

```
df -h
```

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FU1q5UEME4hUKVcBrMhdy%2Fimage.png?alt=media&#x26;token=1800b999-dea3-46b8-baa0-0f4d3483f900" alt=""><figcaption></figcaption></figure>

Verify the Mount:- To confirm that the bucket is mounted, list the contents of your mount point.

<pre><code><strong>sudo ls /mnt/s3bucket
</strong></code></pre>

<figure><img src="https://2683631041-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPVG4W649TwXN8OejRhb%2Fuploads%2FtdPDWpsfShP2hRXONwkn%2Fimage.png?alt=media&#x26;token=c8155091-1a7a-4c2a-8f01-6be005451b35" alt=""><figcaption></figcaption></figure>
