S3FS is FUSE (File System in User Space) based solution to mount an Amazon S3 buckets, 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.
If you like to access S3 buckets without mounting on system, use s3cmd command line utility to manage s3 buckets. s3cmd is also provides faster speed for data upload and download rather than s3fs. To work with s3cmd use next articles to install s3cmd in Linux systems and Windows systems.
This article will help you to install S3FS and Fuse by compiling from source, and also help you to mount S3 bucket on your CentOS/RHEL and Ubuntu systems.
Step 1 – Remove Existing Packages
First, check if you have any existing s3fs or fuse package installed on your system. If installed it already remove it to avoid any file conflicts.
### CentOS and RedHat Systems ### yum remove fuse fuse-s3fs ### Ubuntu Systems ### sudo apt-get remove fuse
Step 2: Install Required Packages
After removing packages. First, we will install all dependencies for fuse and s3cmd. 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 Fuse
Download and compile latest version of fuse source code. For this article, we are using fuse version 2.9.3. Following the set of command will compile fuse and add fuse module in the kernel.
cd /usr/src/ wget https://github.com/libfuse/libfuse/releases/download/fuse-3.1.0/fuse-3.1.0.tar.gz tar xzf fuse-3.1.0.tar.gz cd fuse-3.1.0 ./configure --prefix=/usr/local make && make install export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ldconfig modprobe fuse
Step 4 – Download and Compile Latest S3FS
Download and compile latest version of s3fs source code. For this article we are using s3fs version 1.74. After downloading extract the archive and compile source code in system.
cd /usr/src/ git clone https://github.com/s3fs-fuse/s3fs-fuse.git cd s3fs-fuse ./autogen.sh ./configure make && make install
Step 5 – Setup Access Key
Also In order to configure s3fs, we would require Access Key and Secret Key of your S3 Amazon account. Get these security keys from Here.
echo AWS_ACCESS_KEY_ID:AWS_SECRET_ACCESS_KEY > ~/.passwd-s3fs chmod 600 ~/.passwd-s3fs
Note: Change AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with your actual key values.
Step 6 – Mount S3 Bucket
Finally mount your s3 bucket using following set of commands. For this example, we are using s3 bucket name as mydbbackup and mount point as /s3mnt.
mkdir /tmp/cache /s3mnt chmod 777 /tmp/cache /s3mnt s3fs -o use_cache=/tmp/cache mydbbackup /s3mnt