Linux : Mount an Bucket on a Linux Machine


Background

If you are already using an object store, you probably have a use case where you want to access the content of the bucket directly from the Linux filesystem. In my case, I'm using Cloudian, and I would like to directly read/write content from/to my Linux machine. Cloudian is object store and Linux is using traditional block store. But, wait ! it is possible to mix those environments !

Linux Fuse
Linux Fuse is a package which comes by default in many Linux distribution. It the short name for File system in USErspace. It allows any user to create its own filesystem on the Linux environment. You can see this as a virtual filesystem. With our use case, we are going to use a derived version of Fuse called S3-Fuse (https://github.com/libfuse/libfuse/releases/).

Installation

Note : before installing S3-Fuse on our test machine, we need to do some cleanup and get rid of any previous version of Fuse to avoid and replace it with the latest.

# yum remove fuse fuse* fuse-devel
# yum install automake gcc-c++ git libcurl-devel libxml2-devel make openssl-devel
Now, we have the prerequisites and we can start to install s3-fuse (note : this is not the latest version of fuse, but this is the easiest to install).

# cd /usr/local/src
# wget https://www.github.com/libfuse/libfuse/releases/download/fuse-2.9.7/fuse-2.9.7.tar.gz 
# tar xvf fuse-2.9.7.tar.gz
# rm -f fuse-2.9.7.tar.gz
# mv fuse-2.9.7/ fuse
# cd fuse/
# ./configure --prefix=/usr
# make
# make install
# export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
# ldconfig
# pkg-config --modversion fuse
# cd /usr/local/src/
# git clone https://github.com/s3fs-fuse/s3fs-fuse.git
# cd s3fs-fuse/
# ./autogen.sh
# ./configure
# make
# make install
# s3fs --version

Amazon Simple Storage Service File System V1.89 (commit:e477d7d) with OpenSSL
Copyright (C) 2010 Randy Rizun <rrizun@gmail.com>
License GPL2: GNU GPL version 2 <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


Last set of actions, we need to prepare a password file, adjust the DNS or the local hosts file and finally, mount the bucket on a mount point we have created before.

The password file will be similar to this : 

# cd
vi .passwd-s3fs
<access_key_id>:<secret_key>

The way you get those credentials depend what system you are using.

Next :

# chmod 600 .passwd-s3fs
# mkdir /bucket
echo 192.168.1.10 s3-object.localdomain.local >> /etc/hosts
# s3fs test /bucket -o passwd_file=/root/.passwd-s3fs -o use_path_request_style -o parallel_count=15 -o multipart_size=128 -o nocopyapi -o url=http://s3-object.localdomain.local -d

At this stage, you should have the test bucket located on host 192.168.1.10 mounted on the local Linux machine in the /bucket mount point.

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_client-lv_root 14G 1,2G 12G 9% /
tmpfs                         939M 0 939M 0% /dev/shm
/dev/sda1                     477M 52M 400M 12% /boot
s3fs                          256T 0 256T 0% /bucket

# cd /bucket/
# ls -la
total 101614
drwx------. 1 root root 0 1 jan 1970 .
dr-xr-xr-x. 23 root root 4096 7 jui 13:23 ..
-rw-r--r--. 1 root root 0 7 jui 18:56 mydata
drwxr-xr-x. 1 root root 0 7 jui 16:21 test2
-rw-r--r--. 1 root root 104046664 7 jui 18:47 videoplayback.mp4

And on my Object Store Server, here is the content of the test bucket : 


So, you would say, why the hell should I attach a bucket on a file system ? Well, you can have a couple of reasons : 
  • The platform you are using is not natively supporting object storage;
  • You need to script to actions initiated from the filesystem on the content of the bucket;
  • ...
I think each one could probably have its own reason/use case.

Windows ? Yes, there is some sort of Fuse port on Windows (https://github.com/billziss-gh/winfsp) but I did not test it. It probably works.

Anyway, as always, I hope it was helpful at least for one of you.


Comments

What's hot ?

ShredOS : HDD degaussing with style

Wallbox : Get The Most Of It (with API)

PCBWay : CNC Machining