How to mount Amazon S3 storage to AWS Lightsail Instance

Following are the instructions on how to mount Amazon S3 storage to an AWS Lightsail Instance using S3FS and Fuse.

Prerequisites

Install dependencies:

Run the following command to assume root permissions all the time:

 

Install S3FS-Fuse

Go to your home directory.

Clone Fuse

Go to cloned directory:

You’ll see something like this:

Compile Fuse using make command:

And install:

Add symlink:

 

 

Install Linux Fuse

Visit https://github.com/libfuse/libfuse/releases and look for the latest package, in my case: fuse-3.1.0.tar.gz is the latest, located at https://github.com/libfuse/libfuse/releases/download/fuse-3.1.0/fuse-3.1.0.tar.gz, let’s mark this path down and use wget to download it.

Extract tar file, move to extracted directory, then follow by installing Fuse and exporting config path:

Edit /etc/ld.so.conf

Add /usr/local/lib/ to the top, it should look something like this:

Run ldconfig again:

 

Create Access Key File

Create a file that will hold your AWS access key id and secret access key

Setup Auto Mount (fstab)

 

Edit /etc/fstab

This is if you need to auto-mount your bucket when your Amazon Linux machine starts

Add this line:

Just make sure to provide your AWS bucket name instead of <bucket>

Save the file

 

Start NETFS service

Or enable it to start on boot:

Now re-mount:

 

 

TEST

Now, you should be able to cd into your s3 bucket

You’ll see the same content as is currently in your Amazon S3 bucket

 

If you run into any issues, turn on the logging to see what the problem is

 

 

Limitations

Generally, S3 cannot offer the same performance or semantics as a local file system. More specifically:

  • random writes or appends to files require rewriting the entire file
  • metadata operations such as listing directories have poor performance due to network latency
  • eventual consistency can temporarily yield stale data(Amazon S3 Data Consistency Model)
  • no atomic renames of files or directories
  • no coordination between multiple clients mounting the same bucket
  • no hard links

 

 

ENJOY!