<?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>Ideas.... &#187; ec2</title>
	<atom:link href="http://rosalynmetz.com/ideas/tag/ec2/feed/" rel="self" type="application/rss+xml" />
	<link>http://rosalynmetz.com/ideas</link>
	<description>a blog for me to record thoughts and ideas</description>
	<lastBuildDate>Thu, 14 Apr 2011 17:56:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Resizing an EBS Backed AMI</title>
		<link>http://rosalynmetz.com/ideas/2011/04/14/resizing-an-ebs-backed-ami/</link>
		<comments>http://rosalynmetz.com/ideas/2011/04/14/resizing-an-ebs-backed-ami/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 12:51:23 +0000</pubDate>
		<dc:creator>Rosalyn Metz</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[ebs]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://rosalynmetz.com/ideas/?p=950</guid>
		<description><![CDATA[So in my previous post I talked about all this work to make an EBS backed AMI.  At the end though I realized that I didn&#8217;t size the server right.  Doh!  This was fairly stupid of me.  So I followed &#8230; <a href="http://rosalynmetz.com/ideas/2011/04/14/resizing-an-ebs-backed-ami/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So in my previous post I talked about all this work to make an EBS backed AMI.  At the end though I realized that I didn&#8217;t size the server right.  Doh!  This was fairly stupid of me.  So I followed the same set of steps because all the instructions I found on resizing an existing image didn&#8217;t seem to work.  And then I tried something, you know, for $#!*$ and giggles.  Imagined how annoyed I was when it worked.</p>
<p>So here is the command for registering an EBS backed image based on a particular snapshot:</p>
<pre>ec2-register --block-device-mapping /dev/sda1=s&lt;snapshot id&gt;::false
--name "&lt;ami name&gt;" --kernel &lt;kernel id&gt; --ramdisk &lt;ramdisk id&gt;
-K &lt;key file&gt; -C &lt;cert file&gt;</pre>
<p>(<strong>Note</strong>: If you want the <em>volume</em> to persist after termination then you&#8217;ll want to change the true in the &#8211;block-device-mapping flag to false)</p>
<p>So the key is in the &#8211;block-device-mapping flag.  The documentation for Amazon states:</p>
<div id="attachment_951" class="wp-caption aligncenter" style="width: 1022px"><a href="http://rosalynmetz.com/ideas/wp-content/uploads/2011/04/Screen-shot-2011-04-14-at-8.45.47-AM.png"><img class="size-full wp-image-951 " title="Block Device Mapping Documentation" src="http://rosalynmetz.com/ideas/wp-content/uploads/2011/04/Screen-shot-2011-04-14-at-8.45.47-AM.png" alt="Block Device Mapping Documentation" width="1012" height="394" /></a><p class="wp-caption-text">Block Device Mapping Documentation</p></div>
<p>So it says somewhere in there that you can specify the size of the AMI in that particular flag, so if I want to increase the size of the instance all I would need to do is change the flag to read:</p>
<pre>--block-device-mapping /dev/sda1=s&lt;snapshot id&gt;:50:true</pre>
<p>or whatever size you want.  Afterwards you&#8217;ll need to log on to the server and resize the drive.  You can do this by running the following (assuming you&#8217;re using an ext3 root file system, which is what I used in my previous post):</p>
<pre>sudo resize2fs /dev/sda1
</pre>
<p>it&#8217;ll resize the drive and you should be good to go.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Frosalynmetz.com%2Fideas%2F2011%2F04%2F14%2Fresizing-an-ebs-backed-ami%2F&amp;title=Resizing%20an%20EBS%20Backed%20AMI" id="wpa2a_2">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://rosalynmetz.com/ideas/2011/04/14/resizing-an-ebs-backed-ami/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating an EBS Backed AMI</title>
		<link>http://rosalynmetz.com/ideas/2011/04/14/creating-an-ebs-backed-ami/</link>
		<comments>http://rosalynmetz.com/ideas/2011/04/14/creating-an-ebs-backed-ami/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 12:39:50 +0000</pubDate>
		<dc:creator>Rosalyn Metz</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[ebs]]></category>
		<category><![CDATA[ec2]]></category>

		<guid isPermaLink="false">http://rosalynmetz.com/ideas/?p=943</guid>
		<description><![CDATA[There are tons of instructions out there on how to create an EBS backed images.  Most of them don&#8217;t work for me because they are either out dated or the person&#8217;s instructions for copying the file structure doesn&#8217;t work.  I &#8230; <a href="http://rosalynmetz.com/ideas/2011/04/14/creating-an-ebs-backed-ami/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are tons of instructions out there on how to create an EBS backed images.  Most of them don&#8217;t work for me because they are either out dated or the person&#8217;s instructions for copying the file structure doesn&#8217;t work.  I finally found instructions though that do work.</p>
<p>So here is how I did it:</p>
<p>1) Start Up an Instance</p>
<p>The first thing I do is start up an instance.  Everyone has instructions on how to do this from the command line.  But I&#8217;m lazy and find that Amazon&#8217;s API tools change regularly which is annoying and makes it difficult to follow the instructions other people have written.  I recommend doing it in the AWS Console.</p>
<p>Go to EC2 in the AWS Console.  Choose AMI and find an image that you like (I tend to lean toward Alestic&#8217;s Ubuntu images, but that&#8217;s just me).  Once I found an AMI I like I highlight it and then choose &#8220;Launch Instance&#8221;.  I follow the instructions, making sure that I choose the correct security group (aka firewall) and the correct key pair (you access ec2 servers using a key pair rather than a password).</p>
<p>Once the server is up and running, I update everything, configure it, transfer data onto it, blah blah blah.  The usual things that you do when you are prepping a server.  Once I&#8217;m all set I&#8217;m ready to make it an EBS backed AMI.</p>
<p>2) Create a New EBS Volume</p>
<p>The next thing I do is create an EBS Volume, again doing it in the AWS Console.  Go to the EC2 section of the AWS Console.  Choose &#8220;Volumes&#8221; and then &#8220;Create Volume&#8221;.  You&#8217;ll want to make sure of two things:</p>
<p>First that the volume is large enough to hold everything.  I forgot to do that the first time around and *thought* I had to do everything all over again (see next post for how to really do it).  The easiest thing would be to just size it right the first time around.</p>
<p>Second that the volume is in the same availability zone as the instance you started up in step 1.  If you aren&#8217;t sure what the availability zone is for your instance, go back to the instance, highlight it, and in the bottom panel you&#8217;ll see what zone its in.</p>
<p>3) Attach Volume to Instance</p>
<p>When you are done you&#8217;ll want to attach the volume to the instance that you created in step 1.  Once the volume is available, highlight it and choose &#8220;Attach Volume&#8221;.  You&#8217;ll be stepped through attaching it to your server.  If you have only one instance running its pretty straightforward.  If you have multiple ones running, you&#8217;ll want to make sure that you&#8217;re attaching it to the right place.  You&#8217;ll be asked to indicate where you want the attached, I usually do /dev/sdf.  Oh and this process won&#8217;t work if the volume and the instance aren&#8217;t in the same availability zone, hence my warning in the previous step.</p>
<p>4) Copy the Data from the Server to the Volume</p>
<p>This part of the instructions I found over at <a title="Winners Don't Lose" href="http://winnersdontlose.com/?p=95" target="_blank">Winners Don&#8217;t Lose</a>.  This helps you format the volume and copy the data on the current instance over to the volume:</p>
<pre>In a root shell on the instance:

# mkfs.ext3 /dev/sdf
# mkdir /mnt/target &amp;&amp; mount /dev/sdf /mnt/target
# rsync -avHx / /mnt/target
# rsync -avHx /dev /mnt/target
# sync;sync;sync;sync &amp;&amp; umount /mnt/target

The above commands did the following:

formatted the entire volume /dev/sdf as an extended 3 filesystem
created directory /mnt/target and mounted /dev/sdf at /mnt/target
rsync’d the root instance-store filesystem to the ebs volume
synchronized the /dev directory from the instance-store filesystem
flush all pending write ops, and unmount the EBS volume</pre>
<p>To be honest these are the only instructions I&#8217;ve ever been able to follow that doesn&#8217;t produce some error that I have to debug.</p>
<p>5) Detach the Volume</p>
<p>The next step is to detach the volume that you just created from the running instance.  Again you can do this in the AWS console by finding the volume, highlighting it, and choosing detach.  Make sure the you&#8217;re detaching the right volume though!</p>
<p>6) Create a Snapshot of the Volume</p>
<p>You&#8217;ll want to create a snapshot of the volume that you just created.  You can again do that in the AWS Management console but finding the volume, right clicking on it, and choosing create snapshot.</p>
<p>7) Register your AMI</p>
<p>This is the part that took me forever to figure out.  Mostly because the documentation for the ec2-register command didn&#8217;t jive with the tools that i had access too.  The command I used was:</p>
<pre>ec2-register --block-device-mapping /dev/sda1=&lt;snapshot id&gt;::true
--name &lt;ami name&gt; --kernel &lt;kernel id&gt; --ramdisk &lt;ram disk id&gt;
-K &lt;your pk file&gt;.pem -C &lt;your cert file&gt;.pem</pre>
<p>(note i updated this:  if you want the <em>volume</em> to persist after termination then you&#8217;ll want to change the true in the &#8211;block-device-mapping flag to false)</p>
<p>You&#8217;ll want to make sure that you specify and kernel id and a ram disk id, I usually use the same one that my instance I&#8217;m creating this new AMI from was using.  You don&#8217;t have to do it, but that would mean that if your AMI users don&#8217;t choose one during start up, then the instance won&#8217;t work.</p>
<p>Note that you may have your key and cert file set as part of your environment variable.  I have multiple accounts so I don&#8217;t, and instead just specify them when I&#8217;m running any commands (annoying but I don&#8217;t do much from the commandline anyway).</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Frosalynmetz.com%2Fideas%2F2011%2F04%2F14%2Fcreating-an-ebs-backed-ami%2F&amp;title=Creating%20an%20EBS%20Backed%20AMI" id="wpa2a_4">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://rosalynmetz.com/ideas/2011/04/14/creating-an-ebs-backed-ami/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Creating an EBS Backed AMI in the Cloud</title>
		<link>http://rosalynmetz.com/ideas/2009/12/07/creating-an-ebs-backed-ami-in-the-cloud/</link>
		<comments>http://rosalynmetz.com/ideas/2009/12/07/creating-an-ebs-backed-ami-in-the-cloud/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 23:11:29 +0000</pubDate>
		<dc:creator>Rosalyn Metz</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[ami]]></category>
		<category><![CDATA[blacklight]]></category>
		<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[ebs]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[Solr]]></category>

		<guid isPermaLink="false">http://rosalynmetz.com/ideas/?p=786</guid>
		<description><![CDATA[I decided that I wanted to create an EBS backed AMI on Amazon&#8217;s Cloud Computing platform.  I thought this would be REALLY hard.  I was completely wrong. The first thing I did was start with an already existing EBS AMI. &#8230; <a href="http://rosalynmetz.com/ideas/2009/12/07/creating-an-ebs-backed-ami-in-the-cloud/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I decided that I wanted to create an EBS backed AMI on Amazon&#8217;s Cloud Computing platform.  I thought this would be REALLY hard.  I was completely wrong.</p>
<p>The first thing I did was start with an already existing EBS AMI. Right now there aren&#8217;t too many available but they are growing.  I chose an Ubuntu 9.04 image since I&#8217;m going to install a stack on it, and I&#8217;ve already done *most* of it before on Ubuntu.</p>
<p>A quick note: it is possible to create an EBS AMI from an S3 AMI, but I wasn&#8217;t able to figure that out (quickly).  Although I did find a script that will do this for you: http://gist.github.com/249915.</p>
<p>Next, I wanted to get the Ubuntu server prepared.  I needed to:</p>
<ul>
<li> install mysql &#8212; http://www.howtogeek.com/howto/ubuntu/install-mysql-server-5-on-ubuntu/</li>
<li>install ruby on rails &#8212; http://www.hackido.com/2009/04/install-ruby-rails-on-ubuntu-904-jaunty.html (up to and including step 6)</li>
<li>install zlib &#8212; http://www.techsww.com/tutorials/libraries/zlib/installation/installing_zlib_on_ubuntu_linux.php</li>
<li>install blacklight &#8212; http://projectblacklight.org (includes solr and a number of gem dependencies)</li>
</ul>
<p>I did all of this.  One thing I noticed, Blacklight requires me to use non-standard ports (ie not 22 and 80).  While the server was running, I went into the AWS console and opened ports for its associated security group.  The changes took effect immediately.  I definitely liked that.</p>
<p>Finally, I went in to the AWS Management Console and chose &#8220;Create Image (EBS AMI)&#8221;.</p>
<p><a href="http://rosalynmetz.com/ideas/wp-content/uploads/2009/12/Picture-1.png"><img class="size-large wp-image-787 alignnone" title="Create Image (EBS AMI)" src="http://rosalynmetz.com/ideas/wp-content/uploads/2009/12/Picture-1-300x130.png" alt="Picture 1" width="300" height="130" /></a></p>
<p>Then I filled in the information including a description of my image:</p>
<p><a href="http://rosalynmetz.com/ideas/wp-content/uploads/2009/12/Picture-2.png"><img class="alignnone size-large wp-image-788" title="EBS AMI Details" src="http://rosalynmetz.com/ideas/wp-content/uploads/2009/12/Picture-2-300x213.png" alt="EBS AMI Details" width="300" height="213" /></a></p>
<p>and voila! EBS backed AMI.  the one caveat is:</p>
<p>DON&#8217;T TERMINATE THE INSTANCE UNTIL THE NEW AMI HAS FINISHED BEING CREATED</p>
<p>because then you&#8217;ll loose all the work that you have just done.  doh!</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Frosalynmetz.com%2Fideas%2F2009%2F12%2F07%2Fcreating-an-ebs-backed-ami-in-the-cloud%2F&amp;title=Creating%20an%20EBS%20Backed%20AMI%20in%20the%20Cloud" id="wpa2a_6">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://rosalynmetz.com/ideas/2009/12/07/creating-an-ebs-backed-ami-in-the-cloud/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

