# Mount S3 Bucket to Linux operating system

S3fs is a FUSE (Filesystem in Userspace) module that allows for mounting an  S3 bucket as a local file system on a user’s machine. By utilizing `s3fs`Its users can seamlessly interact with objects stored in S3 as if they were local files, enabling typical operations like reading, writing, and deleting.

Prerequisite

Neevcloud Bucket - See our [Bucket Creation Guide](https://docs.neevcloud.com/neevcloud-products/storage/object-storage/create-bucket)

Access $ Secret Key Pair- See our [Access Key Guide](https://docs.neevcloud.com/neevcloud-products/access-details/s3-ec2-credentials/create-s3-ec2-credentials)

REST Endpoint to follow these [links](https://docs.neevcloud.com/neevcloud-products/storage/object-storage/service-urls-for-neevcloud-s3)

Linux operating system - [create a server](https://docs.neevcloud.com/neevcloud-products/computes/getting-started-launch-vms)

To mount an S3 bucket to a Linux machine, you can use a tool like s3fs.

Step 1: Update and upgrade the system

```
sudo apt-get update -y
sudo apt-get upgrade -y
```

Step 2: Install dependencies

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

Step 3: Set and store 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.

Step 4: Create a mount point&#x20;

Create a directory where you want to mount the S3 bucket.

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

Step 5: 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

```

* `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= **s3-api.neevcloud.com** 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.

Now, verify the mount

```
sudo df -h
```

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FB4HjtIZ9FLdLcpMzlAqX%2Fimage.png?alt=media&#x26;token=2f7fe7e2-81d4-435a-9e01-ae2c8e961474" alt=""><figcaption></figcaption></figure>

Now you can try to create a new file.

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FhTFphZFeGLRn0i1KWY39%2Fimage.png?alt=media&#x26;token=c07b4ea7-ce51-4415-8a18-5001d2bf2931" alt=""><figcaption></figcaption></figure>

Now, back to the Neevcloud Dashboard, click on the object storage and check the bucket.

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FMEdiJGqiLTXQEjhCRVx6%2Fimage.png?alt=media&#x26;token=8757378e-d75e-4e4e-ad73-e7e291a3c877" 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://s3-api.neevcloud.com,use_path_request_style,passwd_file=/root/.passwd-s3fs 0 0
```

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

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2F9Y9LqpnazJcTog7yYghC%2Fimage.png?alt=media&#x26;token=1c332465-bd44-4c2b-bde4-58aaa371c355" 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://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FsCI1aLU5JSeOruRh0iTS%2Fimage.png?alt=media&#x26;token=4bbe3f11-69f8-4837-ab9c-e01f77154ac7" alt=""><figcaption></figcaption></figure>

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

```
ls /mnt/s3bucket/
```

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FLgg5yh7b3otIVq5HwQMD%2Fimage.png?alt=media&#x26;token=d4141c23-e9d8-4973-9d9a-b878c7dbd06a" alt=""><figcaption></figcaption></figure>
