Tuesday, May 26, 2009

Auto Mounting EBS on EC2

I assume that you have already created a EC2 instance (On top of your custom AMI),  EBS volume (both in the same availability zone) . Below are some instructions to automount EBS on EC2. 


AutoMount Init Script
===========================
http://developer.amazonwebservices.com/connect/thread.jspa?threadID=25071&start=0&tstart=0

1)apt-get install sun-java6-jre sun-java6-bin sun-java6-source
2)cd /usr/local/src/
3)wget http://developer.amazonwebservices.com/connect/servlet/JiveServlet/download/30-25071-102530-2022/mountec2vol
4)wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-api-tools.zip
5)edit mountec2vol
set JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.13/  or equivalent
set EC2_PRIVATE_KEY EC2_CERT
set EC2_HOME=/usr/local/src/ec2-api-tools-1.3-36506/
set VOL and DEV
6)cp mountec2vol /etc/init.d/
7)chmod +x /etc/init.d/mountec2vol
8)test  mountec2vol
/etc/init.d/mountec2vol start
/etc/init.d/mountec2vol stop
9)update-rc.d mountec2vol start 15 2 3 4 5 . start 47 S . start 35 0 1 6 .
10)Bundle the new image
ec2-bundle-vol -d /mnt -k /mnt/pk-balbal.pem -c /mnt/cert-balhbalh.pem -u userid  -r i386  -p automountingebs
11)upload the new image
ec2-upload-bundle  --url https://s3.amazonaws.com/subdir/ -b yourbucket  -m /mnt/automountingebs.xml -a accessid -s yoursecret
12)register image
ec2-register yourbucket /subdir/automountingebs.xml



Some additional info to create EBS 
=========================
On local machine
================
ec2-create-volume -z us-east-1c -s 10
ec2-describe-volumes vol-VVVV1111
ec2-attach-volume -d /dev/sdh -i i-IIII1111 vol-VVVV1111

On EC2 Instance
===============
apt-get install -y xfsprogs
modprobe xfs
mkfs.xfs /dev/sdh

echo "/dev/sdh /vol xfs noatime 0 0" >> /etc/fstab

mkdir /vol
mount /vol

http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663


AutoMount
=========
http://www.ioncannon.net/system-administration/199/automounting-amazon-ebs-volumes-on-ec2-instances/

No comments: