How to Mount Wasabi Storage Bucket on CentOS and Ubuntu 20 using S3FS
Introduction
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.
Prerequisite
- Sudo access for the remote server
- Credentials for the Wasabi bucket to know the bucket name and region
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 the fuse. Install the required packages to the system using 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.
Debian 9 and Ubuntu 16.04 or newer:
sudo apt install s3fs
RHEL and CentOS 7 or newer through via EPEL:
sudo yum install epel-release
sudo yum install s3fs-fuse
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 pwd-s3fs.
echo AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY > ${HOME}/.passwd-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 ${HOME}/.passwd-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 the mount point as /s3mnt.
mkdir /tmp/cache /s3mnt
chmod 777 /tmp/cache /s3mnt
s3fs -o use_cache=/tmp/cache mybucket /s3mnt -o passwd_file=${HOME}/.passwd-s3fs
Once this has been successfully run, you will be able to access all files within the test-bucket by just changing directories into /s3mnt.
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
s3fs#test-bucket /s3mnt fuse allow_other,use_cache=/tmp/cache,use_path_request_style,url=https://s3wasabisys.com 0 0
Note:
In order to unmount the folders, follow the below commands
umount -l /tmp/cache
umount -l /s3mnt