In this article, we will be using S3FS to mount cloud storage services locally on a CentOS or Ubuntu box. Mounting them locally will allow us to interact with the cloud providers as a local file system.
We will be covering three cloud storage providers namely, AWS S3, Wasabi Hot Storage and Digital Ocean Spaces. What makes this interesting is that all three providers use the same api, which is the S3 API.
S3FS is a FUSE (File System in User Space) based solution used to mount an Amazon S3 or compatible storage solutions, Just as mentioned above, we can use system commands with this drive just like as another Hard Disk in the system. On s3fs mounted files systems we can simply use cp, mv and ls the basic Unix commands similar to run on locally attached disks.
Step 1 – Update Packages
First, we will update the system to make sure we have the latest packages. We will then check if we have any existing s3fs or fuse package installed on your system. We will remove any existing packages and install everything anew.
### CentOS and RedHat Systems ### $ yum update $ yum remove fuse fuse-s3fs ### Ubuntu Systems ### $ sudo apt-get update $ sudo apt-get remove fuse
Step 2 – Install Dependencies
Once you have successfully removed the packages. We will install all dependencies for fuse. Install the required packages to system use following command.
### CentOS and RedHat Systems ### yum install gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap ### Ubuntu Systems ### sudo apt-get install build-essential libcurl4-openssl-dev libxml2-dev mime-support
Step 3 – Download and Compile Latest S3FS
In this step we will download and compile the latest version of s3fs from GitHub. For this article we are using s3fs version 1.74. After downloading extract the archive and compile source code in system using the commands below.
cd /usr/src/ git clone https://github.com/s3fs-fuse/s3fs-fuse.git cd s3fs-fuse ./autogen.sh ./configure make && make install
Step 4 – Configuring Access Key
In order to configure s3fs, we would require Access Key and Secret Key of your S3 Amazon account, Wasabi or Digital Ocean. You can access these keys from you account dashboard of the respective services. Once you have these keys, create a file, for the purpose of this tutorial we will be naming the file
echo AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY > ~/.pwd-s3fs ### Note: Change AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with your actual key values.
After creating the password file we will change the permission on the file for security reasons.
chmod 600 ~/.pwd-s3fs
Step 5 – Mount S3 Bucket
Finally we can mount the s3 bucket using following set of commands. For this example, we are using s3 bucket name as
test-bucket and mount point as
mkdir /tmp/cache /s3mnt chmod 777 /tmp/cache /s3mnt s3fs -o use_cache=/tmp/cache test-bucket /s3mnt -o passwd_file=/etc/pwd-s3fs
Once this has been successfully run, you will be able to access all files within the
test-bucket by just changing directories into
Step 6 – Mounting a Wasabi Hot Storage Bucket
If you are not familiar with Wasabi, It’s a S3 compatible storage which is 1/5th the price and 6x faster than Amazon S3, according to their website. Since it supports the S3 API the same command works, you only need to change the endpoint as describe below:
s3fs test-bucket /s3mnt -o passwd_file=/etc/pwd-s3fs -o url=https://s3.wasabisys.com
Step 7 – Mounting a Digital Space
Just like the approach with Wasabi we will be specifying the endpoint in the command. Use the command below to mount a digital ocean space unto your local drive.
s3fs test-bucket /s3mnt -o passwd_file=/etc/pwd-s3fs -o url=nyc3.digitaloceanspaces.com
In this article we have reviewed how to use s3fs to mount cloud storage services locally. By doing so we can use regular linux commands to interact with the files within the remote bucket locally. Some use cases include running backups, copying files and a whole lot more.