Creating new a instance-store AMI for Amazon AWS EC2

This is a HOWTO build your own instance-store backed AMI image which is suitable for creating a Paid AMI. The motivation for doing this HOWTO is simple: I tried it, and it has a lot of little gotchas, so I want some notes for myself. This HOWTO assumes you’re familiar with launching EC2 instances, logging into them, and doing basic command line tasks.

Choosing a starting AMI

There’s a whole ton of AMIs available for use with EC2, but not quite so many which are backed by instance-store storage. Why’s that? Well, EBS is a lot more flexible and scalable. The instance-store images have a fairly limited size for their root partition. For my use case, this isn’t particularly important, and for many use cases, it’s trivial to mount some EBS volumes for persistant storage.

Amazon provides some of their Amazon Linux AMIs which are backed by EBS or instance-store, but they’re based on CentOS, and frankly, I’ve had so much troubles with CentOS in the past, that I just prefer my old standby: Ubuntu. Unfortunately, I had a lot of trouble finding a vanilla Ubuntu 12.04 LTS instance-store backed image through the AWS Console. They do exist, however, and they’re provided by Canonical. Thanks  guys!

Here’s a list of all the 12.04 Precise official AMIs:
http://cloud-images.ubuntu.com/releases/precise/release/

Conveniently, there’s a Launch button right there for each AMI instance. Couldn’t be easier!

Installing the EC2 Tools

Once you’ve got an instance launched and you’re logged in and sudo‘d to root, you’ll need to install the EC2 API and AMI tools provided by Amazon. The first step is, of course, to download them. Beware! The tools available through the Ubuntu multiverse repositories are unfortunately out of date.

The latest EC2 API tools can be found here:
http://aws.amazon.com/developertools/351

The latest EC2 AMI tools can be found here:
http://aws.amazon.com/developertools/368

I like to copy the download link and use wget to download them rather than scp‘ing them from my client machine.

sudo su
mkdir -p /tmp/ec2-tools
cd /tmp/ec2-tools
wget -O ec2-api-tools.zip 'http://www.amazon.com/gp/redirect.html/ref=aws_rc_ec2tools?location=http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip&token=A80325AA4DAB186C80828ED5138633E3F49160D9'
wget -O ec2-ami-tools.zip 'http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip'

Before we can install the EC2 tools, we need to install a few packages that our vanilla Ubuntu is lacking, namely zip and Java.

apt-get install zip
apt-get install openjdk-6-jre-lib
apt-get install ruby

Once we have those installed, we need to unzip our packages and install them to the /usr/local directory.

unzip "*.zip"
find . \( -name bin -o -name lib -o -name etc \) | \
    xargs -I path cp -r path /usr/local

Lastly we have to set the EC2_HOME and the JAVA_HOME environment variables for the EC2 tools to work properly. I like to do this by editing /etc/bash.bashrc so anyone on the machine can use the tools without issue.

echo -e "\nexport EC2_HOME=/usr/local\nexport JAVA_HOME=/usr\n" >> /etc/bash.bashrc

Once we log out and back in, those variables will be set, and the EC2 tools will be working.

# exit
$ sudo su
# ec2-version
1.6.7.4 2013-02-01

Customizing Your AMI

At this point, your machine should be all set for you to do whatever customization you need to do. Install libraries, configure boot scripts, create users, get your applications set up, anything at all. Once you’ve got a nice, stable (rebootable) machine going, then you can image it.

Bundling, Uploading and Registering your AMI

This is actually pretty easy, but I’ll still go through it. The Amazon documentation is fairly clear, and I recommend following along with that as well, as it explains all the options to each command.

Here’s the official Amazon documentation:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-snapshot-s3-linux.html

  1. Create an S3 bucket. This is where you’ll upload your AMI images. If you already have a bucket, you can use that.
  2. Download your AWS security certificates and copy your API keys. They can be found here: https://portal.aws.amazon.com/gp/aws/securityCredentials
  3. Copy your credentials to the instance you’re going to image. First, create a directory to store them in on your instance:
    mkdir -p /tmp/cert
    chmod 777 /tmp/cert
  4. Then copy them from the place you downloaded them on your client machine, to your instance:
    scp -i <keypair_name> pk-*.pem cert-*.pem ubuntu@<host_name>:/tmp/cert
  5. Bundle your instance image. The actual image bundle and manifest will end up in /tmp.
    cd /tmp/cert
    ec2-bundle-vol -k <private_keyfile> -c <certificate_file> \
        -u <user_id> -e <cert_location>
    cd /tmp
  6. Upload your bundled image. Note that <your-s3-bucket> should include a path that is unique to this image, such as my-bucket/ami/ubuntu/my-ami-1, otherwise things will get very messy for you, because an image consists of an image.manifest.xml file and many chunks which compose the image itself, which are generically named by default when you use this tool.
    ec2-upload-bundle -b <your-s3-bucket> -m <manifest_path> \
        -a <access_key> -s <secret_key>
  7. Register your new AMI.
    ec2-register <your-s3-bucket>/<path>/image.manifest.xml -n <image_name> \
        -O <your_access_key> -W <your_secret_key>

That’s it! You should be all set with a new AMI, which should also show up in the AWS Console.

Read More

Evo 4G Customization Goodness

Since my initial rooting and unlocking project last weekend I haven’t been able to stop thinking about the shiny new ROM I have installed and how awesome it is.  So now that I have the taste for flashing custom ROM’s, I wanted to see what else was out there.  I did some digging and learned (to my happy surprise) that the Evo 4G, or the “OG” as community members refer to it as, is still alive and well, with a very talented community and very active user base.  Especially for a device that is nearly 3 years old.

If you missed my original ROM flashing post you can view it here.  That should get you up speed.

Custom ROM’s can be confusing and maybe a bit intimidating at first but once you start to wrap your head around the concept then things get much easier.  If you have any questions let me know and I will do my best to help explain things as best I can (from my own understanding of how it all works at this point).  I am certainly new to this as well but am quickly beginning to understand the power and draw behind custom ROM’s, especially for tinkerers and people that are interested in DIY tech projects, there is really a whole world out there to go explore for this type of stuff.  I would take a look at XDA Developers forum for a good place to get started on many of these topics.

I am working on putting together a list of the latest and greatest ROM’s that I have stumbled across since my initial flash using the MazWoz Jelly Bean ROM last week.  I will also try to offer some perspective and comparisons between these custom ROM’s to help you choose which one will suit your needs and will work best in your use case.  All of the ROM’s that I have been testing are currently all 4.2.x (Jelly Bean) and are all fantastic, so if you are having trouble picking one out I would advise that you just pick one.  More than likely it will be a good fit.  The only difference between many of these are small subtleties such as specific themes, customization options, look and feel and a few packaged apps here and there.  So for example, Slim Bean offers a UI “pie controls” that aren’t built in to some of the other ROM’s.  But for the most part many of these ROM’s are using a lot of the same “stuff” in the background.  There are probably more out there but I will just be covering the most popular and most active ROM’s that I cam across, so let’s go ahead get started.

MazWoz – http://forum.xda-developers.com/showthread.php?t=1947452

This is a great ROM and the first custom ROM that I tried.  Nearly everything is working currently, it is certainly stable enough for every day use IMO.  It did a hot reboot on me once and the camera was a little bit on the glitchy side, there were some strange GUI effect glitches every now and WiMax is broken (which won’t get a fix it doesn’t look like but who cares) but otherwise worked flawlessly, it is very snappy and responsive, it provides a buttery smooth experience.  I would highly recommend giving this ROM a shot since it is both stable and smooth.  It isn’t quite there 100% on all the new Jelly Bean features but it is getting there and is under active development by its creator and maintainer.  The latest release was about a month ago so hopefully there will be an update to provide some of these niceties in the near future.

Slim Bean – http://forum.xda-developers.com/showthread.php?t=2217412

Currently testing this ROM out.  So far so good, it is fast and everything I’ve tried seems to be working correctly.  This ROM is designed to be light weight and snappy, so only basic themes, look and feel and apps although I will say that after booting initially it felt a very tiny bit slower than the MazWoz ROM but this slowdown was still very tolerable.  I suspect there may have been issues since it was trying to sync up and download things in the background, because everything has been working much more smoothly after the everything is in sync.  The camera works slightly more fluidly than the MazWoz camera and there do not appear to be any other noticibly odd glicthy behaviors with the GUI.  Other initial findings were that there is no WiMax (again expected) and no front camera.  This ROM is very smooth and there is support for facial recognition and unlock which is pretty slick.  There are some other cool features baked in such that other ROM’s do not offer such as “The Real Dark Slim (TRDS)” which is basically a customization engine for this particular ROM as well as Slim PIE and a few other unique customizations for this ROM which allow for a more fine tuned experience.

Cyanogenmod 10.1 – http://forum.xda-developers.com/showthread.php?t=2244061

This is the defacto for custom ROM’s currently, it easily has the largest user and developer base and its latest version has been ported over to the Evo 4G.  This is pretty much the most complete package as far as custom 4.2.x ROM’s go.  It has basically every standard feature that comes along with this version of Android as well as a ton of tweaks and improvement, including pie controls and speed/optimization improvements and other nice goodies.  There is no official release for this build because this current port literally just happened not more than a few weeks ago but I’m sure the word will spread quickly.  So far I have liked this release for the most part, there are some issues though, such as a little big of glitchiness as with the other releases I have tried, the swype style keyboard doesn’t work all the time, the launcher (trebuchet) crashed ones, no front camera, some of the camera options aren’t perfect either and there is no WiMax support.  These are really just small gripes though and outside of that it is snappy and also probably the smoothest ROM I’ve tried so far.  It has some slick features built in including a custom launcher, file manager and media player, as well as some additional themes and widgets built in which are a really nice touch.  The CyanogenMod is an all around good experience and with all of the little additions and bells and whistles built in has been my favorite ROM so far.

AOKP – http://forum.xda-developers.com/showthread.php?t=2257194

This is one of the newer projects out there but it is gathering steam and the community as well as developers have really worked hard to make this ROM very nice.  The features of this ROM are on par (some may even say better) than Cyanognmod and this ROM certainly delivers so very nice customization options as well as a stable and fast platform.  I have only recently tried this ROM out myself yet so I can’t report on all of the issues that it has other than the standard issues that all of these ROM’s suffer from.  No front camera, no WiMax, some weird camera issues, etc.  Nothing out of the ordinary.  I have really liked the quickness of this ROM so far, I’d say it is on par or better than Slim Bean and offers a really nice experience overall and the ability for a lot of customization.  I would definitely recommend trying this ROM out.  The only caveat for getting this ROM to work correctly is that you need to partition your SD card prior to flashing, otherwise you will suffer from boot loops which caught me originally.  Other than that, it is pretty straight forward to flash and use.

Evervolv – http://forum.xda-developers.com/showthread.php?t=2172323

This one is worth a mention as well but seems to be losing some of its previous favor amongst the community as of late (at least as far as I can tell, I could be totally wrong about this though).  It seems like a lot of ROM’s are built using much of Evervolv’s code but the project itself isn’t quite as popular as it was at one time.  I haven’t tried this ROM out for myself yet, I just found that it was worth a mention because of its support for the Evo 4 G.  I might come back and update this post if I ever switch and try this ROM out, but I just can’t get away from Cyanogenmod right now.

Read More

Hack your Evo 4G into a High End Smart Phone

I was in desperate need of a phone upgrade recently and ran across a nice little deal on an old Evo 4G (not to be confused with the Evo 4G LTE) on craigslist this past weekend, which to my surprise turned into a nice little phone hacking project.  Luckily for me the phone I got was basically in mint condition as it belonged to an older gentlemen who I imagine didn’t get a lot of mileage out of it.  On top of that, it was layered in protective casings.

Sometimes buying phones on craigslist can be scary and turn into a crap shoot but in my own experience I’ve found them to work out more often than not.  The two pieces of advice I can offer when buying a used phone on craigslist are to have the seller send you the ESN number prior to meeting so you can check to make sure it is active (there are many online ESN checkers out there).  The other, simple advice is to look at the phone when you meet and make sure you can turn it on and off and that it can hold a charge.

I also want to take a moment and tell everybody about the provider I use, which is Ting.  Why?  Because they are awesome and super easy to use.  Ting offers a very competitive price and doesn’t require contracts, which I believe are important things to consider when selecting a provider.  Anyway, I could probably write an entire post about how awesome Ting is and why you should use their service but I will forego the details for now.  I just wanted to mention that you can activate your phone entirely on your own in like 5 minutes, which helped me out a lot with this project.  There are detailed instructions on their site about activating new/used phones and porting over numbers, it is easy and Ting even encourages its users to root and unlock their phones.  Long story short, Ting is awesome, it made this project much easier and you should give them a try.

Once you do all the running around and finally get your phone it is time to actually get down to the fun stuff.  I learned that rooting the Evo 4G was a bit tricky since it had all of the newest firmware and protection from HTC.  I have had less issues with rooting some other HTC devices in the past, but I don’t know how that effects the steps if the software and firmware change.  In all reality the additional steps are just a technicality I would say and aren’t too much of a hindrance.  So in the following details I will outline the process of getting your phone from the basic locked version of HTC Android to a fully unlocked phone with the capability of running custom ROMS, namely the MazWoz ROM which is currently the Jelly Bean ROM that I am using for the Evo 4G.

The first step is to get root.  This is essential because without it you will not be able to get S-OFF and be able to flash custom ROM’s.  Rather than go into great detail and post all of the steps here I will instead point you in the right direction on how to get started yourself.  There are a ton of guides out there already on how to do this and there would really be no point to add another to that collection of guides, since there are some really good ones out there that have all the links and resources.  I found this one and this one to be the most relevant and helpful.  The first one is especially nice because it offers some video guidance as well as written.  Basically when I got stuck with one of the guides I would just switch back and forth and reference the other.   I feel that they both definitely compliment each other very well.

The second step is to obtain S-OFF.  Use the links mentioned previously for obtaining root to obtain S-OFF as well, after you root your phone.  This step was very confusing to me at first so I thought I would clarify the process to make things easier for readers to understand.  Once you have root on your phone you can The major issue I ran across with this step was when I reached the step for copying over the flashimage and mtd-eng.img files.  To get this step to work I had to be in Fastboot mode to gain read/write access to the sdcard.  Other than that, everything else worked great.  I should also note that for S-OFF I chose to use to use revolutionary.exe following the instructions from the first site.  I think the steps for flashing S-OFF using the unrevoked method from the second link would work fine, maybe even preferably, I just never tested this myself.

The third step is to flash the custom ROM, along with the other apps and fixes that turn your phone in the Jelly Bean device.  Jelly Bean brings with it a number of features and improvements that make for a much better, much smoother smart phone experience.  It is really leaps and bounds above the stock version of Android OS that is shipped by default on the Evo 4G and the experience is often referred to as “buttery smooth” because it is so nice.  Here is the link for getting the MazWoz Supersonic ROM.  I used the B4 release, which is the most current as of this writing as well as the link to Gapps and the GPS fix.  As of the B4 release the WiMax wasn’t working and the video is a little glitchy and the front camera isn’t working but other than that, this ROM is a fully functioning 4.2.1 Jelly Bean image.  The WiMax isn’t important to me as I don’t have access to it where I live and the video isn’t really a big issue for me either since I don’t shoot a lot of video.

The positives of using this custom ROM immensely outweigh the negatives in my opinion. So all in all, hacking an almost 3 year old phone in about 3 hours time into a usable Jelly Bean device that typically sells for upwards of $300 for the bargain $80 price tag seems like a steal to me, the experience is nearly flawless.  Granted there are a few caveats and you need to be willing to follow the steps for the upgrade but in my opinion this is still a great deal.  You get to a) revive an old piece of hardware that is beginning to show its age, b) save a shitload of money on the cost of a new phone and c) get to tinker with your phone, which to me was the best part out of this project.  Here is a link to some other devices that have been quickly faded in popularity that can potentially be updated and given new life.  My hop is that this post will inspire you or at least give you some ideas to go and check what’s out there and maybe even help breathe some new life into some of your otherwise antiquated and dying android devices.

Read More

8 Golden Rules for Sysadmins

Getting the most out of your career can be rewarding.  Today I feel like taking a minute to slow down and reflect on a few of the things that I have observed in my time as a system administrator that I believe lead to success.  The following are some general rules that I have found to be true both in my work and more generally, many of these rules are just attitudes which can be applied to life as well.  Hopefully these come as common sense to you but it is always good to take time to reflect on good things.  I hope this isn’t too cliche or too much of a time waste for many of you but rather an opportunity to take a moment and analyze your current situation and potentially reevaluate anything you feel to be a weak area or area that could use improvement.

1. ) Always have a backup. Good backups are an invaluable asset to you as a system administrator, and can be a great bargaining piece if necessary in political battle.  Often times backups are overlooked by IT staff, so by ensuring you have good backups (you must always test them!) you are covering your own ass and are able to deflect blame if something out of your control occurs.   As a bonus, you look like a hero when the CEO or president of the company needs files from a month ago and have no idea where to turn, you will look like a magician and could potentially strengthen their view of IT.

2.)  Be likable. It can be a sad truth but many promotions hinge on whether or not people like you. You may be far and away the smartest, most technical or most talented person on your team but it is not going to get you very far if you are an asshole, and people don’t like you.  In this profession it is the case more often than not I see colleagues take the “holier than thou” approach which just perpetuates the stereotype that IT people are jerks.  If you can manage to be smart and not an asshole in IT you will go far.

3.)  Learn how to write. This doesn’t mean you have be able to produce enough volume for a novel, just use writing to develop your own voice, and use it as a way to communicate things effectively.  The great thing about writing is, the more you do it, the easier and more impactful it becomes.  Use your writing as an opportunity to help position yourself for success in the future.

4.)  Learn to program. Again, following up on the last point; this doesn’t mean that you need to become a software engineer, this is just the ability to quickly patch some code together to automate something that you are doing every day or having the ability to look at some process and say, “hey, I bet I could write a script to make this work better”.  It will make you more productive and efficient and will free up your time for other important tasks.

5.)  Patience. In this line of work the number one virtue any Sysadmins can have is patience. Being able to be pulled away from your work multiple times a day to help with completely unrelated issues can quickly become frustrating so having patience to deal with these things is incredibly helpful. And if you can deal with distractions well, people will like you more. Reference rule #2 for more on that.

6.)  Never stop learning.  System administration changes considerably quickly, which in my opinion is great, if you embrace it.  New technologies are always are always on the horizon, companies get bought and integrated into other companies all the time and technology strategies change all the time.  It is a never ending game of catch up for the sysadmins, so if you become content with where you are at and don’t keep up on your studies and on your technologies you will surely fall by the way side sooner than later.

7.) Attention to detail.  This one can be a real difference maker.  There is something to be said for tidiness and orderliness in system administration. Not only does it make things much easier to fix when everything is in a specific place, but it just makes you look better and in all reality doesn’t take much time to do things correctly. We all know the reckless admin who pays no attention to the mess they are making, and in turn it reflects poorly on their character.  Even if they are a genius and amazingly talented, it makes that person look sloppy and lazy to me.

8.) Balance your life.  This helps prevent stress and burnout.  Work and everything associated can get stressful at times so finding a balance becomes a great benefit when you learn how to manage it correctly.  Being able to leave work at work when you need to is crucial in keeping your sanity, but that’s not the only thing that’s important in balancing your life.  It is also helpful to find things outside of work that you enjoy doing.  Whether that be a hobby, interests outside of work, exercise, an interest group, vacations, whatever.  When you spend time focusing on the things that make you happy outside of work it will recharge your spirit more quickly and ultimately help keep you happy as well as productive at work.

Did I miss anything?  Have any other helpful tips that you’d like others to know about?  If so, let me know.

Read More

Deliberate Practice and System Administration (Part 3)

So far we have covered the following,

  • All the ideas, concepts and techniques needed for applying deliberate practice. (Part 1)
  • A framework for how to apply techniques of deliberate practice to system administration. (Part 2)

Now let’s wrap this all together and examine the last important piece in this series.  A real world example of deliberate practice in action and its association with expertise.  We can put some of these ideas and techniques into practice and build our own customized version for applying deliberate practice to system administration.

Practically everybody knows who Tiger Woods is and how incredibly skilled he is.  If you don’t I suggest you Google him.  However, few understand the level of dedication he has to his craft and how much he actually puts into the sport to compete at the level he does.  So let’s go ahead and take a look at what his daily routine consists and figure out what conclusions we can draw and how we can model a practice routine for system administration after this.

  • 6:30 a.m. – One hour of cardio. Choice between endurance runs, sprints or biking. 
  • 7:30 a.m. – One hour of lower weight training. 60-70 percent of normal lifting weight, high reps and multiple sets.
  • 8:30 a.m. – High protein/low-fat breakfast. Typically includes egg-white omelet with vegetables.
  • 9:00 a.m. – Two hours on the golf course. Hit on the range and work on swing.
  • 11:00 a.m. – Practice putting for 30 minutes to an hour.

Noon – Play nine holes.

  • 1:30 p.m. – High protein/low-fat lunch. Typically includes grilled chicken or fish, salad and vegetables.
  • 2:00 p.m. – Three-to-four hours on the golf course. Work on swing, short game and occasionally play another nine holes.
  • 6:30 p.m. – 30 minutes of upper weight training. High reps.
  • 7:00 p.m. – Dinner and rest.

That is pretty crazy.  So how do we model this to fit our purposes for system administration?

There are two obvious things that I think are crucial that we can borrow from this right away.  Exercise and healthy diet.  These are important facets because as I’ve talked about previously and has been proven many times, proper diet and exercise contribute to improved cognitive abilities.  I don’t suggest following Tiger’s workout or meal plan but I would suggest at least an hour of exercise as well as a healthy meal plan to help operate at optimal energy levels throughout the day.

Next, nearly all of the rest of his practice schedule revolves around improving very specific aspects of his game.  Thankfully we came up with some of these generalized aspects of improvement for system administration in Part 1 and Part 2 so we can put these to use in our own plan.  It is important that  we combine everything into one practice schedule that is challenging but is also realistic.  We also don’t want to go over 4-5 hours each day.  So here is the schedule I propose, feel free to adapt these any way you like:

  • 8:00 a.m – Breakfast.  Fresh made juice or several pieces of fruit + supplements (multivitamin, fish oil, vitamin D).
  • 9:00 a.m. – Check relevant news, new trends and tech, check mail, forums, etc.
  • 10:00 a.m. – Focused study on new or weak areas, 60 minutes on, 15 minutes off.  This can consist of reading, videos, audio.
  • 12:00 p.m. – Lunch.  Mixed salad.  The more vegetables the better!
  • 1:00 p.m. – Lab time.  Focus on strengthening and understanding of study topics.  This is where the most time and energy should be spent.
  • 4:00 – p.m. – Work on command line/programming skills and techniques.  This fulfills more of our hands on and practice time requirements.
  • 5:00 – p.m. – Gym.  Alternate days between cardio and strength training.
  • 7:00 – p.m. – Dinner and relaxation.
  • 9:00 – p.m. – Writing and reflections on the day.  Areas of improvement, etc.

Again, this is only a guideline.  I plan on updating this as I test these techniques and make refinements and adjustments to it.  As an example, I like to work out in the evening to help me relieve stress but many others (including Tiger like to take care of this in the morning), you just have to figure out what works best for your lifestyle, so I would definitely encourage you to experiment with what works and what doesn’t.  I’m very curious to know myself.  Since this is a first revision I think there will probably need to be a number of adjustments, but I look forward to trying it out and reporting back with some results!  If you have suggestions or have your own practice schedule let me know and I’ll definitely incorporate it into my routine.

Read More