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  
wget http://downloads.sourceforge.net/fuse/fuse-2.8.0-pre1.tar.gz?modtime=1215728006&big_mirror=0  
wget http://s3fs.googlecode.com/files/s3fs-r177-source.tar.gz

Install fuse

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

Install s3fs

cd /mnt/work   
tar xfz downloads/s3fs-r177-source.tar.gz
cd /mnt/work/s3fs/   
make   
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...

2 comments:

Eric Thibeault said...

always look to see if you can find a more recent version of those software... EC2 and S3 are evolving very fast...

Very cool stuff...

Dan Moore said...

Yes, and there is even newer code available with lots of improvements. Stop by and see what's new:

http://code.google.com/p/s3fs/wiki/FuseOverAmazon