<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6348989372796903616</id><updated>2011-11-27T16:48:49.224-08:00</updated><category term='ec2 ubuntu ami'/><title type='text'>Random Musings</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.pautinka.co.uk/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6348989372796903616/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.pautinka.co.uk/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Darrell</name><uri>http://www.blogger.com/profile/13056962701116162385</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6348989372796903616.post-5262168320817166395</id><published>2011-10-24T13:41:00.000-07:00</published><updated>2011-10-24T13:55:47.836-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ec2 ubuntu ami'/><title type='text'>Create Lucid Lynx EC2 micro ami from Canonical Images with XFS root filesystem and ec2-consistent-snapshot</title><content type='html'>I read Shlomo Swidler's excellent post &lt;a href="http://shlomoswidler.com/2010/01/creating-consistent-snapshots-of-live.html"&gt;Creating Consistent Snapshots of a Live Instance with XFS&lt;/a&gt; but couldn't get it working for Ubuntu 10.04 (Lucid Lynx) on a micro EC2 instance. This guide details the steps that I used to create my AMI.&lt;br /&gt;&lt;br /&gt;As a starting point I used the latest 64 bit official &lt;a href="http://cloud.ubuntu.com/ami/"&gt;Canonical Ubuntu 10.04 Lucid Lynx AMI&lt;/a&gt; which is currently ami-ad36fbc4 in the us-east-1 zone.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Launch an Ubuntu 10.04 Lucid Lynx instance and note the instance id.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@localhost:~$ ami=ami-ad36fbc4&lt;br /&gt;ubuntu@localhost:~$ security_groups=default&lt;br /&gt;ubuntu@localhost:~$ keypair=mykeypair&lt;br /&gt;ubuntu@localhost:~$ instance_type=t1.micro&lt;br /&gt;ubuntu@localhost:~$ zone=us-east-1c&lt;br /&gt;ubuntu@localhost:~$ ec2-run-instances $ami --availability-zone $zone -t $instance_type -g $security_groups -k $keypair&lt;br /&gt;ubuntu@localhost:~$ instance_id=i-XXXXXXXX&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Create an EBS volume and attach it to the running instance.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@localhost:~$ ec2-create-volume --size 10 -z $zone&lt;br /&gt;ubuntu@localhost:~$ xfs_volume=vol-XXXXXXXX&lt;br /&gt;ubuntu@localhost:~$ ec2-attach-volume $xfs_volume --instance $instance_id --device /dev/sdm&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Wait until the instance is running then ssh to it.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@localhost:~$ host=$(ec2-describe-instances $instance_id | awk '-F\t' '$2 == instance_id { print $4 }' instance_id=${instance_id} )&lt;br /&gt;ubuntu@localhost:~$ ssh -i mykeypair ubuntu@${host}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Update and upgrade existing packages and install ec2-consistent-snapshot.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@ec2:~$ sudo apt-get update &amp;&amp; sudo apt-get -y upgrade&lt;br /&gt;ubuntu@ec2:~$ sudo add-apt-repository ppa:alestic&lt;br /&gt;ubuntu@ec2:~$ sudo apt-get update&lt;br /&gt;ubuntu@ec2:~$ sudo apt-get install -y ec2-consistent-snapshot&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Create and mount the xfs filesystem.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@ec2:~$ sudo apt-get install -y xfsprogs&lt;br /&gt;ubuntu@ec2:~$ sudo mkfs.xfs /dev/sdm&lt;br /&gt;ubuntu@ec2:~$ sudo mkdir -p -m 000 /vol/xfs&lt;br /&gt;ubuntu@ec2:~$ sudo mount -t xfs /dev/sdm /vol/xfs&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Copy the contents of the instance’s root filesystem to the xfs EBS volume.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@ec2:~$ sudo rsync -avx --exclude /vol / /vol/xfs&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Ubuntu looks for a disk labelled 'cloudimg-rootfs' when booting but xfs labels have a 12 character limit. So modify fstab and grub to work using partition names.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@ec2:~$ sudo vi /vol/xfs/etc/fstab&lt;br /&gt;&lt;/pre&gt;replace&lt;br /&gt;&lt;pre name="code" class="brush: plain; toolbar: false; gutter: false;"&gt;LABEL=cloudimg-rootfs / ext3 defaults 0 0&lt;br /&gt;&lt;/pre&gt;with&lt;br /&gt;&lt;pre name="code" class="brush: plain; toolbar: false; gutter: false;"&gt;/dev/sda1 / xfs defaults 0 0&lt;br /&gt;&lt;/pre&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@ec2:~$ sudo vi /vol/xfs//boot/grub/menu.lst&lt;br /&gt;&lt;/pre&gt;replace all occurrences of LABEL=cloudimg-rootfs with /dev/sda1&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Unmount the xfs volume.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@ec2:~$ sudo umount /vol/xfs&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Snapshot the xfs volume and register as an AMI.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@localhost:~$ ec2-create-snapshot $xfs_volume&lt;br /&gt;ubuntu@localhost:~$ snapshot=snap-XXXXXXXX&lt;br /&gt;ubuntu@localhost:~$ kernel=aki-427d952b&lt;br /&gt;ubuntu@localhost:~$ description="Ubuntu 10.04 Lucid formatted with XFS"&lt;br /&gt;ubuntu@localhost:~$ ami_name=ubuntu-10.04-64-bit-ami-ad36fbc4-xfs&lt;br /&gt;ubuntu@localhost:~$ ec2-register --snapshot $snapshot --kernel $kernel --description="$description" --name=$ami_name --architecture x86_64 --root-device-name /dev/sda1&lt;br /&gt;ubuntu@localhost:~$ ami=ami-XXXXXXXX&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Launch an instance.&lt;/b&gt;&lt;br /&gt;&lt;pre name="code" class="brush: bash; toolbar: false; gutter: false;"&gt;ubuntu@localhost:~$ ec2-run-instances $ami -t $instance_type -g $security_groups -k $keypair&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6348989372796903616-5262168320817166395?l=blog.pautinka.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6348989372796903616/posts/default/5262168320817166395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6348989372796903616/posts/default/5262168320817166395'/><link rel='alternate' type='text/html' href='http://blog.pautinka.co.uk/2011/10/create-lucid-lynx-ec2-micro-ami-from.html' title='Create Lucid Lynx EC2 micro ami from Canonical Images with XFS root filesystem and ec2-consistent-snapshot'/><author><name>Darrell</name><uri>http://www.blogger.com/profile/13056962701116162385</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
