AMI building AMI

Rafal Lukawiecki raf at rafal.net
Mon Jan 1 16:17:01 UTC 2018


> On 29 Dec 2017, at 02:44, Colin Percival <cperciva at tarsnap.com> wrote:
> 
> us-east-1 ami-e6a6ea9c is a FreeBSD 11.1-RELEASE AMI-building AMI.

Many thanks, Colin. And a Happy New Year!

May I ask you if what I am hoping to do makes sense? Taking the gist from http://www.daemonology.net/blog/2015-11-21-FreeBSD-AMI-builder-AMI.html I plan to make an AMI, install packages, patch and install the kernel, all in one go. I am unsure how to “make kernel” so that it ends up in the new AMI, rather than just in the builder AMI.

Firs, I create an IAM role with a policy which grants access to the EC2 CreateImage API. Then I launch your AMI building AMI ami-e6a6ea9c in us-east-1 using config init script as follows, on a sufficiently large c5:

#!/bin/sh
export ASSUME_ALWAYS_YES=YES
PKGS_TO_INSTALL=lots of packages go here
pkg -r /mnt fetch -d $PKGS_TO_INSTALL
pkg -c /mnt install $PKGS_TO_INSTALL
svnlite co https://svn.freebsd.org/base/releng/11.1/ /usr/src/
cd /usr/src
cat > /tmp/kernel.patch <<EOT
Patch goes here
EOT
patch < /tmp/kernel.patch
make kernel -j16
*** How to copy the new kernel into the AMI’s kernel on /mnt without messing anything up ***
mkami "FreeBSD 11.1 for PB” “PB Customised FreeBSD"
shutdown -p now

Afterwards I copy my new AMI to eu-west-1.

Does this make sense? Is there documentation to mkami? I could not find it. I am curious if I could parametrise it to create an encrypted volume snapshot of a given target size.

Many, many thanks and my regards from Ireland,
Rafal


More information about the freebsd-cloud mailing list