<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>My AWS Musings &#187; EBS</title>
	<atom:link href="http://aws-musings.com/category/ebs/feed/" rel="self" type="application/rss+xml" />
	<link>http://aws-musings.com</link>
	<description>Cloud computing, EC2, RDS, SQS, S3, Java...</description>
	<lastBuildDate>Mon, 30 May 2011 18:13:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>HBase on EC2 using EBS volumes : Lessons Learned</title>
		<link>http://aws-musings.com/hbase-on-ec2-using-ebs-volumes-lessons-learned/</link>
		<comments>http://aws-musings.com/hbase-on-ec2-using-ebs-volumes-lessons-learned/#comments</comments>
		<pubDate>Mon, 30 May 2011 18:12:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=426</guid>
		<description><![CDATA[We started using HBase on EC2 sometime back in 2009. We thought that our data is important and we should have an option of restoring the data. We attached EBS volumes to our HBase nodes and configured HBase and Hadoop installation to store all the data on the attached EBS volumes. Then came the concept [...]]]></description>
			<content:encoded><![CDATA[<p>We started using HBase on EC2 sometime back in 2009. We thought that our data is important and we should have an option of restoring the data. We attached EBS volumes to our HBase nodes and configured HBase and Hadoop installation to store all the data on the attached EBS volumes. </p>
<p>Then came the concept of EBS backed instances. In those days we were still experimenting and HBase was releasing new versions very frequently. We were already few versions ahead pf our original AMI for Hadoop and HBase. We were also in the process of tuning our HBase/Hadoop cluster. The process of documenting all the changes after the changes are done to the installation or creating a new image everytime you changed something was very cumbersome. Instead, we thought if we converted our nodes to EBS backed instances, we won&#8217;t have to do any of it. We simply have to take a snapshot of the root device and then restore it incase the volume fails. </p>
<p>And this worked happily for few months. One day it suddenly stopped working. </p>
<p>There are many wayas to restore EBS backed instances from their snapshots. Here are all of the ways I knew:<br />
1) Register the snapshot as an AMI and start an instance from the image.<br />
2) Create a volume from your snapshot. Start a similar EBS backed instance, stop the instance and swap the root device.<br />
3) Create an AMI from a running instance. This causes the instance to reboot immediately. It wasn&#8217;t an option for us. There is no way were could afford to reboot our master!</p>
<p>You have to know kernel and ramdisk ids if you want to go for option 1 and 2. You may think it&#8217;s a no brainer &#8211; just use the meta data query tool and find out kernel and ramdisk of the running instances. But not all instances have that meta data available to them! Our instances did not have a ramdisk meta data available! When we contacted Amazon support they told us that the instance is very old and there is simply no way to know which ramdisk it is using. That means you need to choose a ramdisk yourself. If the kernel or ramdisk you are using to create AMI from the snapshot is not compaitable, your instance will not boot up correctly. And this is especially true in case of Ubuntu images.</p>
<p>That&#8217;s what happened with us. It stopped working &#8211; somehow the kernel files were not available. Even though ramdisk information was not available, it was the kernel that caused us a problem. Here is what Amazon support had to say on our problems:</p>
<p>&#8220;Your practice of taking snapshots and starting instances from those machines can work, as it has in the past, but will always be susceptible to kernel/ramdisk mismatches.&#8221;</p>
<p>&#8220;Our standard practice of creating an image (AMI) from a running instance (option 3 as described above) and launching instances from that AMI would avoid the problem you&#8217;re seeing with the mismatched/incompatible kernels.&#8221;</p>
<p>When we told Amazon that it&#8217;s not an option for us as it causes the instance to reboot immidiately, here is what they suggested:</p>
<p>&#8220;Have you considered writing data to an EBS volume that is separate from your root EBS volume?  I&#8217;m just wondering if that&#8217;s a viable option as it wouldn&#8217;t require stopping or rebooting the instance.&#8221;</p>
<p>There lies the answer! We have a requirement of recreating the cluster in case we accidently delete entire data or if we loose our master. In such a case the reliable backup can only be taken if your HDFS data does not reside on the root devices. A reliable backup of the root device cannot be taken without rebooting the device. Furthermore it&#8217;s stored as an AMI which mean you have to create a new AMI every day and delete the old one. This means to solve all of our problems we need HBase installation and data both stored on attached EBS volumes that are not the root devices. </p>
<p>It was news to us. </p>
<p>We had no choice. We decided to invest time to convert our architecture to use attached EBS volumes rather than waking up in the middle of a night and realizing that we are not able to restore our backup!</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/hbase-on-ec2-using-ebs-volumes-lessons-learned/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manage EBS snapshots with a python script</title>
		<link>http://aws-musings.com/manage-ebs-snapshots-with-a-python-script/</link>
		<comments>http://aws-musings.com/manage-ebs-snapshots-with-a-python-script/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 19:43:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EBS]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=406</guid>
		<description><![CDATA[I was looking for a simple script that creates a new ebs snapshot and deletes all the previous snapshots except a few newest snapshots. I found a script written in php called manage snapshots at http://www.thecloudsaga.com/aws-ec2-manage-snapshots/. But the script only deletes snapshots. It does not create a new snapshot. That is why I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple script that creates a new <a href="http://aws.amazon.com/ebs/">ebs snapshot</a> and deletes all the previous snapshots except a few newest snapshots. I found a script written in php called manage snapshots at <a href="http://www.thecloudsaga.com/aws-ec2-manage-snapshots/">http://www.thecloudsaga.com/aws-ec2-manage-snapshots/</a>. But the script only deletes snapshots. It does not create a new snapshot. That is why I decided to write a script on my own.<br />
<span id="more-406"></span><br />
In this post I am going to describe how to use my script. You can download my script from <a href='http://aws-musings.com/wp-content/uploads/2011/01/manage_snapshots1.txt'>manage_snapshots.txt</a></p>
<p>It’s a <a href="http://www.python.org/">python script</a>. Change the extension to be .py. Ubuntu comes with python installed. You will need to install <a href="http://boto.cloudhackers.com/">aws python library boto</a>. To install boto all ob ubuntu you can simply execute<br />
<code><br />
sudo apt-get install python-boto</code></p>
<p>You will need to change the following lines with your aws access key and aws secret key. Replace MY_ACCESS_KEY_HERE with your access key and MY_SECRET_KEY_HERE with your secret key.<br />
<code><br />
# Substitute your access key and secret key here<br />
aws_access_key = 'MY_ACCESS_KEY_HERE'<br />
aws_secret_key = 'MY_SECRET_KEY_HERE'</code></p>
<p><strong>Here is how you can use the script:</strong><br />
The script takes three arguments:<br />
1) volume-id (required) &#8211; This is Amazon’s volume id<br />
2) number of snapshots to preserve (required) &#8211; An integer. If you specify 2 it will keep 2 newest snapshots (including the one it just created). If you specify 0, the script will delete all the snapshots (including the one it just created).<br />
3) description (optional) &#8211; Description you want to use for your snapshot.</p>
<p>Example:<br />
<code>python manage_snaphots.py vol-dkls343e 2  'log server daily snapshot'</code></p>
<p>This execution will  create a snapshot of vol-dkls343e and delete anything but that snapshot and the one before it. It will make sure that only two latest snapshots are kept. You can simply <a href="https://help.ubuntu.com/community/CronHowto">add a cron</a> per volume.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/manage-ebs-snapshots-with-a-python-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon AWS Java SDK released</title>
		<link>http://aws-musings.com/amazon-aws-java-sdk-released/</link>
		<comments>http://aws-musings.com/amazon-aws-java-sdk-released/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 01:25:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[RDS]]></category>
		<category><![CDATA[S3]]></category>
		<category><![CDATA[SNS]]></category>
		<category><![CDATA[SQS]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=252</guid>
		<description><![CDATA[Amazon recently announced the AWS SDK for java. SDK or a java api is very much needed &#8211; especially if you are writing your automation scripts in groovy. We have tried multiple java apis in our scripts including JetS3t and Typica. These apis were really helpful, but they only supported some of the AWS services [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon recently <a href="http://aws.amazon.com/about-aws/whats-new/2010/03/22/announcing-the-aws-sdk-for-java/">announced</a>  the AWS SDK for java. </p>
<p>SDK or a java api is very much needed &#8211; especially if you are writing your automation scripts in groovy. We have tried multiple java apis in our scripts including <a href="http://jets3t.s3.amazonaws.com/index.html">JetS3t</a>  and <a href="http://code.google.com/p/typica/">Typica</a>. These apis were really helpful, but they only supported some of the AWS services and were not up to date (for obvious reasons). Having one java api that can support all of AWS technologies was definitely the need of the hour. I am sure Amazon will keep it updated as new services are released. They have the necessary resources to do so.</p>
<p>Furthermore, Amazon has also uploaded the SDK to the <a href="http://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk/1.0.002">maven repository</a>.<br />
You can use the following dependency in your pom.xml:<br />
<code><br />
&lt;dependency><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId>com.amazonaws&lt;/groupId><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId>aws-java-sdk&lt;/artifactId><br />
    &nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;1.0.002&lt;/version><br />
&lt;/dependency><br />
</code><br />
The java doc for the SDK is hosted at <a href="http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/index.html">http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/index.html</a></p>
<p>Amazon has also opened the SDK source code for all. They have mirrored the SDK code repository at github. You can look at the SDK code at <a href="http://github.com/amazonwebservices/aws-sdk-for-java">http://github.com/amazonwebservices/aws-sdk-for-java</a></p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/amazon-aws-java-sdk-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>7 easy tips to reduce your Amazon ec2 cloud costs</title>
		<link>http://aws-musings.com/7-easy-tips-to-reduce-your-amazon-ec2-cloud-costs/</link>
		<comments>http://aws-musings.com/7-easy-tips-to-reduce-your-amazon-ec2-cloud-costs/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 18:54:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[RDS]]></category>
		<category><![CDATA[cloud cost]]></category>
		<category><![CDATA[cloud money saving]]></category>
		<category><![CDATA[it cost]]></category>
		<category><![CDATA[reduce ec2 costs]]></category>
		<category><![CDATA[save ec2 money]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=177</guid>
		<description><![CDATA[Amazon ec2 costs can grow very fast if you are not mindful of the Amazon ec2 billing structure. We came across the following ways to save money at our company. Keep machines in the same availability zone Don&#8217;t scatter your machines that talk to each other across multiple availability zones. You will end up paying [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon ec2 costs can grow very fast if you are not mindful of the Amazon ec2 billing structure. We came across the following ways to save money at <a href="http://gumgum.com">our company</a>. </p>
<p><strong>Keep machines in the same availability zone</strong><br />
Don&#8217;t scatter your machines that talk to each other across multiple availability zones. You will end up paying for the bandwidth. Off course this does not apply to the people who purposely keep their machines in different availibilty zones to ensure high availibility.</p>
<p><strong>Use cnames instead of A records </strong><br />
In other words do not map your domain name to an elastic ip. Map it to the public domain name of the instance. Let&#8217;s say you have a machine with name splunk.gumgum.com. All the web servers (within the same availability zone) send considerable data to this machine. If you setup splunk.gumgum.com as an A record, your data will go out and come back in. But if you map it as cname, your data will always remain within the ec2 cluster. To read more about this visit <a href="http://alestic.com/2009/06/ec2-elastic-ip-internal">Eric Hammond&#8217;s Using Elastic IP to Identify Internal Instances on Amazon EC2</a> post.</p>
<p><span id="more-177"></span><br />
<strong>Use spot instances</strong><br />
Use spot instances whenever possible. Spot instances cost less than on demand instances. You can read more about<a href="http://aws.amazon.com/ec2/spot-instances/"> spot instances on Amazon&#8217;s web page</a>.  There is a website that shows <a href="http://www.spothistory.com/">spot history price graphs</a>. It  will tell you an average price of various types of instances. The average price of a m1.small sport instance is 3 cents an hour. You pay 8.5 cents an hour for the same type of on demand instance.</p>
<p><strong>Choose your instance types wisely</strong><br />
A smallest possible instance may not be the right choice to save money. For example c1.medium costs twice as much as m1.small. But it offers 5 times more compute power than m1.small. Thus in some compute heavy jobs it might be cheaper to use c1.medium instead of the least expensive m1.small.</p>
<p><strong>Choose the smallest possible storage</strong><br />
Choose the smallest possible EBS volumes and RDS instances. It is very easy to expand an ebs volume when needed. Same is the case with a RDS instance. Furthermore by choosing smaller drives, you will save money needed for the backup(snapshot) storage too.</p>
<p><strong>Use Autoscaling</strong><br />
<a href="http://aws.amazon.com/autoscaling/">Autoscaling</a>  can start additional instances when needed. It can shut down the additional instances when the need disappears. This is especailly useful for hosting websites/web services that have a specific traffic/usage pattern.</p>
<p><strong>Reserve your instances</strong><br />
You can reduce your costs significantly by reserving number of instances for a year or for three years. Reservation is only a billing concept and thus you don&#8217;t have to designate any istances as reserved. If you reserve 4 m1.small instances, Amazon will make 4 of your running m1.small instances as reserved. For more information <a href="http://www.allthingsdistributed.com/2009/03/amazon_ec2_reserved_instances.html">visit Werner Vogels&#8217;s (Amazon CTO) blog</a>.  </p>
<p>There might be numerous other ways you can save money. Please feel free to leave a comment to share your ways. The more the merrier!</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/7-easy-tips-to-reduce-your-amazon-ec2-cloud-costs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to expand your ebs volume</title>
		<link>http://aws-musings.com/how-to-expand-your-ebs-volume/</link>
		<comments>http://aws-musings.com/how-to-expand-your-ebs-volume/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:56:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[ebs volume]]></category>
		<category><![CDATA[expand ebs volume]]></category>
		<category><![CDATA[grow ebs]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=104</guid>
		<description><![CDATA[Increasing size of your ebs volume is pretty easy. resize2fs does the trick. Here is the detailed procedure to increase size of your ebs volume. First detach the volume and take a snapshot of the volume. If you already have a snapshot and haven&#8217;t made any changes after that, no need to take a new [...]]]></description>
			<content:encoded><![CDATA[<p>Increasing size of your ebs volume is pretty easy. resize2fs does the trick. Here is the detailed procedure to increase size of your ebs volume.</p>
<p>First <a href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?detaching-ebs.html">detach the volume</a> and take a snapshot of the volume. If you already have a snapshot and haven&#8217;t made any changes after that, no need to take a new snapshot.</p>
<p><span id="more-104"></span><br />
No create a new volume from this snapshot. Let&#8217;s say your original volume was 10G and you wanted to increase its size to 20G.<br />
<code><br />
ec2-create-volume -z us-east-1a --size 20 --snapshot snap-xxxxxxxx<br />
</code><br />
The command will output id of the new volume. Use that id in the following command to attach the volume to any instance you have up.<br />
<code><br />
ec2-attach-volume vol-yyyyyyyy --instance i-xxxxxxxx --device /dev/sdh<br />
</code><br />
Make sure that ec2-describe-volumes show the state of the instance as attached. Once the volume is attached, mount it at a path say /mnt/data. I am assuming here that your volume had ext3 filesystem.<br />
<code><br />
mkdir /mnt/data<br />
echo '/dev/sdh /mnt/data ext3 defaults,noatime 0 0' >> /etc/fstab<br />
mount /mnt/data<br />
</code><br />
Mounting the volume is necessary as otherwise you wont&#8217; be able to execute the following (resize2fs) command.<br />
Now execute the following command to resize the volume<br />
<code><br />
resize2fs /dev/sdh<br />
</code><br />
You should see the following output (sizes you see might be different):<br />
<code><br />
Filesystem at /dev/sdh is mounted on /mnt/data; on-line resizing required<br />
old desc_blocks = 1, new_desc_blocks = 2<br />
Performing an on-line resize of /dev/sdh to 5505024 (4k) blocks.<br />
The filesystem on /dev/sdh is now 5505024 blocks long.<br />
</code><br />
The command should execute in a minute or two for 20G size. That&#8217;s it, you can verify your new size by executing:<br />
<code><br />
df -h<br />
</code><br />
This should show you that the volume&#8217;s new size. That&#8217;s it! </p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/how-to-expand-your-ebs-volume/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>ylastic &#8211; an amazing web based interface for aws</title>
		<link>http://aws-musings.com/ylastic-an-amazing-web-based-interface-for-aws/</link>
		<comments>http://aws-musings.com/ylastic-an-amazing-web-based-interface-for-aws/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 19:22:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[RDS]]></category>
		<category><![CDATA[S3]]></category>
		<category><![CDATA[SQS]]></category>
		<category><![CDATA[cloud interface]]></category>
		<category><![CDATA[cloud website]]></category>
		<category><![CDATA[ec2 interface]]></category>
		<category><![CDATA[ylastic]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=81</guid>
		<description><![CDATA[Let&#8217;s say you have 10 ec2 instances up and they do various different kinds of work. Some are web servers, some are queue servers, some are cache servers and a cluster with hadoop/hbase. Have you found it hard to remember which server is which? Wouldn&#8217;t it be cool if Amazon let us name our servers? [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you have 10 ec2 instances up and they do various different kinds of work. Some are web servers, some are queue servers, some are cache servers and a cluster with <a href="http://hadoop.apache.org/">hadoop</a>/<a href="http://hadoop.apache.org/hbase">hbase</a>. Have you found it hard to remember which server is which? Wouldn&#8217;t it be cool if Amazon let us name our servers?</p>
<p>We have found a solution. <a href="http://ylastic.com">Ylastic</a> provides an amazing and inexpensive web based interface for various AWS services. It allows you to name your ec2 instances and remembers it. If you have an autoscaling setup it will automatically name your autoscaled instances when they start e.g. webserver001, webserver002 etc.</p>
<p><span id="more-81"></span><br />
Ylastic does much more than just naming the servers. It has a very user friendly user interface and also provides an iphone website from which you can start, stop instances etc. It also has a concept of locking an instance so that you don&#8217;t accidentally terminate it.<br />
<div id="attachment_84" class="wp-caption alignnone" style="width: 310px"><a href="http://aws-musings.com/wp-content/uploads/2009/12/ysplash_inst.png"><img src="http://aws-musings.com/wp-content/uploads/2009/12/ysplash_inst-300x102.png" alt="ylastic ec2 instances table" title="ylastic-instances-page" width="300" height="102" class="size-medium wp-image-84" /></a><p class="wp-caption-text">ylastic ec2 instances table</p></div></p>
<p>It has nice graphs for <a href="http://aws.amazon.com/cloudwatch">cloudwatch</a> data. </p>
<div id="attachment_87" class="wp-caption alignnone" style="width: 310px"><a href="http://aws-musings.com/wp-content/uploads/2009/12/ysplash_cwatch.png"><img src="http://aws-musings.com/wp-content/uploads/2009/12/ysplash_cwatch-300x266.png" alt="ylastic cloudwatch graphs" title="ylastic-cloudwatch" width="300" height="266" class="size-medium wp-image-87" /></a><p class="wp-caption-text">ylastic cloudwatch graphs</p></div>
<p>It supports most of the AWS services such as EC2, RDS, Auto scaling, S3, Simple DB.<br />
<div id="attachment_82" class="wp-caption alignnone" style="width: 310px"><a href="http://aws-musings.com/wp-content/uploads/2009/12/ysplash_db.png"><img src="http://aws-musings.com/wp-content/uploads/2009/12/ysplash_db-300x255.png" alt="ylastic dashboard" title="ylastic-dashboard" width="300" height="255" class="size-medium wp-image-82" /></a><p class="wp-caption-text">ylastic dashboard</p></div></p>
<p>It also lets you schedule tasks such as taking a snapshot of your ebs volumes etc. It keep tabs on your instances by receiving alerts when the state of the launched instance changes. </p>
<p>Ylastic costs only $25 per month per Amazon account. It allows you to create multiple users for the same Amazon account. Furthermore <a href="http://ylastic.com">ylastic</a> guys are amazingly fast. Their customer service usually comes back with an answer within the first hour. We have hardly had any complaints though. Most of the times we have suggested new features and these people have implemented them in few days.</p>
<p>I totally recommend <a href="http://ylastic.com">ylastic</a>. We are very happy with it at <a href="http://bedrock.com">Bedrock</a>. It has made our life easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/ylastic-an-amazing-web-based-interface-for-aws/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to create an ebs image from an existing ec2 instance</title>
		<link>http://aws-musings.com/how-to-create-an-ebs-image-from-an-existing-ec2-instance/</link>
		<comments>http://aws-musings.com/how-to-create-an-ebs-image-from-an-existing-ec2-instance/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 02:11:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EBS]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[ebs backed instance]]></category>
		<category><![CDATA[ec2 image]]></category>
		<category><![CDATA[s3 image]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=63</guid>
		<description><![CDATA[Amazon recently announced a new feature which allows you to boot from an ebs volume. But it doesn&#8217;t provide any tools to convert your existing AMIs to this new type of image. There is no easy way to create an ebs image from scratch. There are some posts that explain how to convert your existing [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon recently announced a <a href="http://aws.amazon.com/about-aws/whats-new/2009/12/03/amazon-ec2-instances-now-can-boot-from-amazon-ebs/">new feature which allows you to boot from an ebs volume</a>.  But it doesn&#8217;t provide any tools to convert your existing AMIs to this new type of image. There is no easy way to create an ebs image from scratch. There are some posts that explain how to convert your existing AMI into this new type of image using ec2-unbundle and <a href="http://en.wikipedia.org/wiki/Dd_%28Unix%29">dd (a linux utility)</a>.  I am going to take a little different route and explain how we can create an ebs image from an existing instance. It&#8217;s fairly simple to create a new image using dd from an existing instance. </p>
<p><span id="more-63"></span><br />
Make sure that you have the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351">latest ec2 api tools</a> before you start creating and ebs type of image. Support for some of the commands (such as to register a snapshot as an image) is only available in the version 46266 onwards.</p>
<p>1) <a href="http://docs.amazonwebservices.com/AmazonEC2/dg/2006-10-01/CLTRG-run-instances.html">Launch an ec2 instance</a> from the image you want to convert to an ebs image. Make the changes (if any) you want to make to this instance. Let&#8217;s say that your instance id is i-xxxxxxxx</p>
<p>2) Launch an 10G ebs volume and attach it to this instance. You can create a bigger volume too. But currently the default size of Amazon&#8217;s ephemeral storage is 10G and hence a 10G volume should be sufficient for most of the people.<br />
The following code will launch an ebs volume and attach it to your instance. The code assumes that us-east-1a is the availability zone of your instance.<br />
<code><br />
ec2-create-volume --size 10 --availability-zone us-east-1a<br />
</code><br />
The command should give you an volume id in the form of  vol-yyyyyyyy. Note it down and use it in the next command to attach this volume to your instance.<br />
<code><br />
ec2-attach-volume vol-yyyyyyyy --instance i-xxxxxxxx --device /dev/sdh<br />
</code><br />
Create ext3 filesystem on this volume and mount the volume<br />
<code><br />
yes | mkfs -t ext3 /dev/sdh<br />
mkdir /mnt/ebsimage<br />
echo '/dev/sdh /mnt/ebsimage ext3 defaults,noatime 0 0' >> /etc/fstab<br />
mount /mnt/ebsimage<br />
</code><br />
3) Now that the volume is ready and mounted at /mnt/ebsimage, we are going to copy your entire disk to this volume using <a href="http://wiki.linuxquestions.org/wiki/Dd">dd (a linux disc imaging utility)</a>.<br />
<code><br />
nohup dd if=/dev/sda1 of=/dev/sdh &#038;<br />
</code><br />
The command above will start copying the disc to the ebs volume in background. This could take really long time (e.g. 20 minutes) depending upon your data. To check status of copying you will first need to get pid of the dd process by executing<br />
<code><br />
ps -aef | grep dd<br />
</code><br />
And then use the pid obtained in the following command<br />
<code><br />
kill -SIGUSR1 pid<br />
</code><br />
The above command will clearly print a message similar to<br />
<code><br />
531694080 bytes (532 MB) copied, 11.6338 seconds, 45.7 MB/s<br />
</code><br />
Please note that the message is printed by the dd process and not by the kill process. This means if you have your output redirected to somewhere else, the message will be printed there instead of your screen.</p>
<p>3) Once dd finishes, do a spot check on the data copied in /mnt/ebsimage. If you find everything ok, unmount the volume and detach the volume from the ec2 instance. You can use the following commands to do so:<br />
<code><br />
umount /mnt/ebsimage<br />
ec2-detach-volume vol-yyyyyyyy --instance i-xxxxxxxx<br />
</code></p>
<p>4) Now take the snapshot of the ebs volume.<br />
<code><br />
ec2-create-snapshot vol-yyyyyyyy<br />
</code></p>
<p>5) Register this snapshot as an image. Use the snapshot id obtained from the output of the above command.<br />
<code><br />
ec2reg -s snap-zzzzzzzz -a <em>x86_64</em> -d <em>Description</em> -n <em>imagename</em><br />
</code><br />
Make sure that you replace the snapshot id, image name, description and the image type (x86_86 or x86_64) in the command above.</p>
<p>That&#8217;s it! Your ebs image is ready. Simply launch your instance from this image exactly the same way you launch any other ec2 instance!</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/how-to-create-an-ebs-image-from-an-existing-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

