How to Mount Amazon S3 in Ubuntu

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

1. To get started, first install the dependencies.

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.)

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

3. Extract the file:

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

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

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:

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:

Scroll down the page till you see the AWS_ACCESS_KEY section.

riofs-aws-acccess-key

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.

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

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

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

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

riofs-configuration

  • --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)

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.

6 comments

  1. Hi,
    I’ve found this tutorial usefull but there is some mistakes. I use unzip instead of tar for uncompress the file. Also, I use this line instead.
    sudo cp /usr/local/etc/riofs/riofs.conf.xml ~/.config/riofs/riofs.conf.xml

    Also, there is just somthing missing, how to automount? But still, great tuto!

  2. A great post! Super handy to have the -o “allow_others” which odd’s are good you’ll need to add to the launch command.

    Got this up and running in no time thanks to your guide! Much appreciated for sharing the knowledge!

  3. Thank you, Daminen, everything worked like a charm. One thing that I could not figure out is how to make the mounted volume “stick” after the server is rebooted. I tried putting the command line statement in crontab and rc.local. The command runs, but for some reason the mapping does not occur. It seems to only happen when launched from CLI.

    • I am not really sure about this. My guess is that you run the script too
      early, before the server can access your local data and that is where the
      riofs config file is located. Try placing the config file within the root
      folder. Alternatively, run the script last or, with a delay.

Comments are closed.

Sponsored Stories