In this article i will go thru the steps required to mount an AWS S3 Bucket to an Linux EC2 instance. I assume who will follow this article will already have an AWS account setup and knows already what an EC2 & S3 Bucket are.
#Run as root...
#Install all dependencies
cd /tmp
yum install -y gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap
#Download the fuse tar file
wget http://pkgs.fedoraproject.org/repo/pkgs/fuse/fuse-2.8.4.tar.gz/a26ec54e410bb826a387947b10c0fd2c/fuse-2.8.4.tar.gz
tar zxvf fuse-2.8.4.tar.gz
cd fuse-2.8.4/ ./configure make make install
echo -e '\n/usr/local/lib' /etc/ld.so.conf
ldconfig
#Download the s3fs tar file
wget http://s3fs.googlecode.com/files/s3fs-1.74.tar.gz
tar zxvf s3fs-1.74.tar.gz
(cd s3fs-1.74/ autoreconf --install export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure --prefix=/usr make make install)
touch /etc/passwd-s3fs
chmod 640 /etc/passwd-s3fs
echo '<Access Key Id:<Secret Access Key' /etc/passwd-s3fs
mkdir /s301
/usr/bin/s3fs cf-templates-aghm0qs90bp9-sa-east-1 /s301 -o allow_other -o use_cache=/tmp
#test that is mounted
[root@ip-172-31-34-139 s301]# df -h /s301/
Filesystem Size Used Avail Use% Mounted on
s3fs 256T 0 256T 0% /s301
-- See the file system type
[root@ip-172-31-34-139 s301]# df -T /s301
Filesystem Type 1K-blocks Used Available Use% Mounted on
s3fs fuse.s3fs 274877906944 0 274877906944 0% /s301
[root@ip-172-31-34-139 s301]# echo 's3fs#cf-templates-aghm0qs90bp9-sa-east-1 /s301 fuse rw,allow_other,uid=1000,gid=1000 0 2' /etc/fstab
-- unmount the device
[root@ip-172-31-34-139 ~]# umount /s301
-- see that we no longer see the device
[root@ip-172-31-34-139 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 9.9G 4.2G 5.3G 45% /
/dev/xvdg 7.9G 146M 7.4G 2% /u00
/dev/xvdf 7.9G 146M 7.4G 2% /u01
-- run the mount -a command
[root@ip-172-31-34-139 ~]# mount -a
-- check to see if the s3 device was mounted
[root@ip-172-31-34-139 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 9.9G 4.2G 5.3G 45% /
/dev/xvdf 7.9G 146M 7.4G 2% /u01
s3fs 256T 0 256T 0% /s301