Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

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...

Saturday, March 17, 2007

How to copy files using tar without a tar file / How to tar and untar without a tar file.

# why do this, well tar keep the ownership and permission of the files
# where cp -r will make everything own by the user doing the copy.

(cd / ; tar cf - home) | (cd /newhome; tar xvf -)

How to partition/format a disk under linux

# first use fdisk to setup your partition, for more info on fdisk, type man fdisk
fdisk /dev/hda

# Now that you partitioned your disk let's format it (man mke2fs)
mke2fs /dev/hda1 <--- you have to do this for each partition you created, just replace 1 for partition #

How to mount a webdav share with a comand line

## Here is the command I use to mount a test webDav share on my Mac OS X / unix

/sbin/mount_webdav -o noautomounted -o browse -a15 -vmyfotoz http://localhost:8080/ /Volumes/myfotoz/

How to rsync data from one UNIX server to an other

## Like lots of people I have lots of pictures online, 36 GB... I don't want to lose those preciouses ## memories, so I setup a cron to rsync my data every weeks. The beauty of rsync is that it won't ## copy what's has not change. For more info on rsync just type: man rsync

cd /backup/
rsync -rlptgov root@thibeault.cc:/path/to/my/photos/on/thibeault/cc/ photos/

## here if you like to snoop around my photo Album.
http://thibeault.cc/photoAlbum/

How to mount an iso on Linux

# First image
mount -t iso9660 -o ro,loop=/dev/loop0 FIRST_TRIP.iso /mnt

# Second image (make sure mnt2 exist)
mount -t iso9660 -o ro,loop=/dev/loop1 LAST_TRIP.iso /mnt2

How to create an iso image on linux (dd/mkisofs)

# How to create the content of a directory into an iso image
## if you mount an unprotected DVD under /dev/disk2/
## Here how you can make an iso file from it.

dd if=/dev/disk2 of=FIRST_TRIP.iso bs=256k

or

cd /dev/disk2
mkisofs -r -o ~/FIRST_TRIP.iso .

Friday, March 16, 2007

How to Batch Uppercase/lowercase file/directory

## under tcsh shell

# make the directory lowercase...
foreach f ( `find . -type d -print ` )
mv $f `echo $f | tr A-Z a-z`
end

# make the file lowercase...
foreach f ( `find . -type f -print ` )
mv $f `echo $f | tr A-Z a-z`
end

How to Batch Change file names under tcsh

## example: for each file ending by .jpg, replace any spaces with underscores

foreach i (*.jpg*)
echo $i > /tmp/nom
set j=`sed -e '1,$s? ?_?g' /tmp/nom`
mv "$i" "$j"
\rm /tmp/nom
end