TipsAndTricks/Building core-image-minimal on AWS

From Yocto Project
Jump to navigationJump to search

Sometimes, a Cloud Server is just easier

I won't rehash the already very good instructions on how to create an EC2 instance. Instead, I'll outline what I did and how long it took. Here's a good starting point to get an EC2 instance up and connect to it: [1]

My Setup

Machine (AMI) Chosen - Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-6e1a0117 Instance Type - m4.xlarge (4 cpu, 16 Gb memory, high network performance )

Changes from Default

  • I have a security group that allows ssh/http/https/icmp from my ip into my AWS instances, I chose this security group.
  • I upped storage to 90 GB; note since everything was setscened using sstate, I only ended up using 1.7Gb total ,
 
du -sh ~/work
1.7G	/home/ubuntu/work 

After you have successfully ssh'ed into your EC2 Instance, what now?

  • From the quick start guide, you can just cut and paste the sudo apt-get install line for ubuntu.
  • clone poky as usual: $ git clone git://git.yoctoproject.org/poky and checkout the release: $ git checkout yocto-2.4
    • Note: the sstate for the rolling branch (in this case rocko) may not be available, but the tagged sstate will be.
  • set up the environment $ . ./poky/oe-init-build-env
  • create (or cp ) a site.conf into the conf directory that leverages the sstate YP publishes. This is key to making a quick build! Here's a sample site.conf, (this was done for the 2.4 release):

SSTATE_MIRRORS = "\
file://.* http://sstate.yoctoproject.org/2.4/PATH;downloadfilename=PATH \n \
file://.* http://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH \n \
"

  • build it $ time bitbake core-image-minimal
 
... many setscene tasks ...
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 2384 tasks of which 2177 didn't need to be rerun and all succeeded.
real	2m26.947s
user	0m5.832s
sys	0m0.924s

    • Note, time to image is only 2 1/2 minutes . Pretty nice!
  • you could then rsync the images or whatever else you'd like to grab from the instance. or store it on S3, or ...
  • make sure to terminate the instance when you are done with it. this will delete the files, so make sure you have what you want saved.

What's the Big Deal?

Nothing, really. The point of this very short article is that it is trivial to get an EC2 instance up that can build a YP image and do so in a very short time, assuming you leverage our sstate mirrors.
Note: The free tier instance type <italic>t2.micro</italic> can NOT build core-image-minimal as it runs out of ram in it's default configuration.

Results

  • Time to build core-image-minimal leveraging a release sstate-mirror - 2.5 minutes
  • Cost on AWS (on demand cost which is higher than spot) - $0.29
    • this includes me pulling in the necessary build dependencies, cloning poky, and building.