Friday, October 3, 2008

How to map s3fs drive on an EC2 ubuntu server

Install the appropriate libraries

apt-get update 
apt-get -y install libfuse-dev libfuse2 libc6-dev make pkg-config gcc build-essential libcurl3-dev libxml2-dev libfuse-dev

Download the packages

mkdir –p /mnt/work/downloads  
cd /mnt/work/downloads  

Install fuse

cd /mnt/work  
tar xfz downloads/fuse-2.8.0-pre1.tar.gz   
cd /mnt/work/fuse-2.8.0-pre1/  
make install

Install s3fs

cd /mnt/work   
tar xfz downloads/s3fs-r177-source.tar.gz
cd /mnt/work/s3fs/   
make install

Link the fusermount to /usr/sbin (for rc.local purposes)

ln –s /usr/local/bin/fusermount /usr/bin/fusermount

Mounting your s3 folder

This assume that you have the folder /myfolder in your s3 account.

mkdir -p /mnt/s3buckets/myfolder 
s3fs -o allow_other myfolder /mnt/s3buckets/myfolder/ -o use_cache=/tmp/s3fs_cache -o accessKeyId=YOURACCESSKEYID -o secretAccessKey=YOURSECRETACCESSKEY
Note: If you trust your server and the users that has access to your /etc, you can create a file /etc/passwd-s3fs which contains just your Amazon ID and secret key separated by ":", e.g: YOURACCESSKEYID:YOURSECRETACCESSKEY). Next you can add the mount cmd into your rc.local file... everytime you boot you will see the mount s3 folder...