How to Mount Amazon S3 in Ubuntu

Spread the love

Amazon S3 is a useful web service that allows you to store files for cheap. In Ubuntu (desktop), you can easily access Amazon S3 via the various software, such as S3Fox or Dragon Disk. However, in a server situation, you won’t have the luxury of using a desktop software. In this tutorial, we will show you how you can mount Amazon S3 in Ubuntu, be it desktop or server.

Note: This whole tutorial will be done in the terminal

Installation

1. To get started, first install the dependencies.

sudo apt-get install build-essential gcc make automake autoconf libtool pkg-config intltool libglib2.0-dev libfuse-dev libxml2-dev libevent-dev libssl-dev

2. Next, download riofs. This is a userspace filesystem for mounting Amazon S3. (S3FS is another fuse module that you can use, but it is very buggy and I can’t get it to work properly.)

wget https://github.com/skoobe/riofs/archive/master.zip

Alternatively, if you are using GIT, you can checkout its Github page for more detail.

3. Extract the file:

tar xvzf riofs-master.zip

You should now find a “riofs-master” folder.

4. Enter the “riofs-folder” folder and compile it.

cd riofs-master
./autogen.sh
./configure
make
sudo make install

Mounting of Amazon S3

To mount Amazon S3 in Ubuntu, you have to make sure that you already have bucket(s) available for mounting. Also, get your S3 security credential (Access ID and Secret Access key) ready as they are required for authentication.

1. Before we can mount our bucket, we have to configure the configuration file for riofs. In your terminal:

mkdir ~/.config/riofs
sudo cp /usr/local/etc/riofs.conf.xml ~/.config/riofs/riofs.conf.xml

This will copy the default configuration file to your local folder. You can change the destination folder if you want to.

Next, we need to add the security credential to the configuration file:

nano ~/.config/riofs/riofs.conf.xml

Scroll down the page till you see the AWS_ACCESS_KEY section.

Uncomment that section and replace “###AWS_ACCESS_KEY###” with your access key and “###AWS_SECRET_ACCESS_KEY” with the secret key.

Save (Ctrl + o) and exit (Ctrl + x).

2. Change the permission for the riofs.conf.xml file.

chmod 600 ~/.config/riofs/riofs.conf.xml

3. Create a directory (preferably in your Home folder) that you can mount Amazon S3 to.

mkdir ~/S3

4. Lastly, mount your Amazon S3 bucket to the S3 directory.

riofs -c ~/.config/riofs/riofs.conf.xml my_bucket_name ~/S3

To check if your bucket is successfully mounted, just list all the files in the mounted directory:

ls ~/.S3

More Configuration

There are a few things that you can set in riofs.

  • --cache-dir: set a cache directory to minimize downloads
  • -o "allow_other": allow other users to access your bucket. You will need to enable the “user_allow_other” option in the fuse config file (/etc/fuse.conf)

Conclusion

For those who are using Amazon S3 to store your files, it is very useful to have your buckets mounted on your computer (or server) so you can easily access it. You can even configure your backup application to save the backup files to this folder where they will automatically sync to the cloud.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Damien Oh

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Comments (6)