Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Gentoo Bootstrap

These bash scripts are an attempt to have a repeatable process for creating Gentoo Linux images in the Amazon EC2 service. The scripts generally try to follow the Gentoo Handbook. There are two flavors of the script:

  • build_gentoo_(32|64).sh
  • build_gentoo_minimal(32|64).sh

The build_gentoo_(32|64).sh scripts try to give a quickly usable base install; while the build_gentoo_minimal(32|64).sh are very lightweight setups, allowing for a very flexible setup with no extra cruft.

The scripts have a requirement of the ec2-api-tools. A guide for installing it can be found at http://www.dowdandassociates.com/content/howto-install-aws-cli-amazon-elastic-compute-cloud-ec2-api-tools/

setup_build_gentoo.sh

Optional script. Does the security group and key pair setup that is in build_gentoo.sh. Done so keys and security group can be set up just once.

can pass 4 options, in order:

  1. region
  2. security group
  3. key pair
  4. private key of key pair

if you do not set these:

  • region defaults to us-east-1
  • security group defaults to gentoo-bootstrap and it will be created if needed
  • key pair defaults to "gentoo-bootstrap_$region" e.g. gentoo-bootstrap_us-east-1
  • key file defaults to "gentoo-bootstrap_$region.pem" e.g. gentoo-bootstrap_us-east-1.pem
  • The key pair will be created if needed.

Sample command to setup us-east-1

./setup_build_gentoo.sh us-east-1

build_gentoo.sh

The pain of keeping the 32 and 64 bit versions in sync finally outweight the pain of merging the two scripts together. This and remote_gentoo.sh (as opposed to i386/remote_gentoo.sh and x86_64/remote_gentoo.sh) are the result of that.

Builds Gentoo image for architecture given. Will use a c1.medium for bootstrap instance.

Will use a t1.micro as test instance.

Because sudo will be called, this script cannot be run in the backgroud.

Recommend running screen before running.

Takes 5 options:

  1. architecture
  2. region
  3. security group
  4. key pair
  5. keyfile

if you do not set these:

  • architecture is not optional. The script will give an error. Valid values are: i386, x86_64
  • region defaults to us-east-1
  • security group defaults to gentoo-bootstrap and it will be created if needed
  • key pair defaults to "gentoo-bootstrap_$region-uuidgen" e.g. gentoo-bootstrap_us-east-1-78917775-1adc-40b9-9fba-bc84b7158683
  • key file defaults to "gentoo-bootstrap_$region-uuidgen.pem" e.g. gentoo-bootstrap_us-east-1-78917775-1adc-40b9-9fba-bc84b7158683.pem
  • key pair will be created if needed.

Default AMI name is Gentoo_64-bit-EBS-date +%Y-%m-%d-%H-%M-%S if architecture is x86_64 and is Gentoo_32-bit-EBS-date +%Y-%m-%d-%H-%M-%S if architecture is i386, but can be changed if the environment variable AMI_NAME is set.

Sample command for building 64 bit gentoo on us-east-1, using all defaults

./build_gentoo.sh x86_64

Sample command for building 64 bit gentoo on us-east-1

./build_gentoo.sh x86_64 us-east-1 gentoo-bootstrap gentoo-bootstrap_us-east-1 gentoo-bootstrap_us-east-1.pem

Sample command for building 32 bit gentoo on us-east-1

./build_gentoo.sh i386 us-east-1 gentoo-bootstrap gentoo-bootstrap_us-east-1 gentoo-bootstrap_us-east-1.pem

build_gentoo_64.sh

Wrapper for build_gentoo.sh, builds the regular 64-bit Gentoo image.

Because sudo will be called, this script cannot be run in the backgroud.

Recommend running screen before running.

Architecture is set for you, but the other 4 options remain:

  1. region
  2. security group
  3. key pair
  4. keyfile

Sample command for building 64 bit gentoo on us-east-1

./build_gentoo_64.sh us-east-1 gentoo-bootstrap gentoo-bootstrap_us-east-1 gentoo-bootstrap_us-east-1.pem

build_gentoo_32.sh

Wrapper for build_gentoo.sh, builds the regular 32-bit Gentoo image.

Because sudo will be called, this script cannot be run in the backgroud.

Recommend running screen before running.

Architecture is set for you, but the other 4 options remain:

  1. region
  2. security group
  3. key pair
  4. keyfile

Sample command for building 32 bit gentoo on us-east-1

./build_gentoo_32.sh us-east-1 gentoo-bootstrap gentoo-bootstrap_us-east-1 gentoo-bootstrap_us-east-1.pem

build_minimal_gentoo_64.sh

Wrapper for build_gentoo.sh, builds the minimal 64-bit Gentoo image. See the AMI_TYPE for more about minimal build.

Because sudo will be called, this script cannot be run in the backgroud.

Recommend running screen before running.

Architecture is set for you, but the other 4 options remain:

  1. region
  2. security group
  3. key pair
  4. keyfile

Default AMI name is minimal-Gentoo_64-bit-EBS-date +%Y-%m-%d-%H-%M-%S, but can be changed if the environment variable AMI_NAME is set.

Sample command for building 64 bit gentoo on us-east-1

./build_minimal_gentoo_64.sh

See the AMI_TYPE section below for more information on this AMI.

build_minimal_gentoo_32.sh

Wrapper for build_gentoo.sh, builds the minimal 64-bit Gentoo image. See the AMI_TYPE for more about minimal build.

Because sudo will be called, this script cannot be run in the backgroud.

Recommend running screen before running.

Architecture is set for you, but the other 4 options remain:

  1. region
  2. security group
  3. key pair
  4. keyfile

Default AMI name is minimal-Gentoo_32-bit-EBS-date +%Y-%m-%d-%H-%M-%S, but can be changed if the environment variable AMI_NAME is set.

Sample command for building 32 bit gentoo on us-east-1

./build_minimal_gentoo_32.sh

remote_gentoo.sh

The script to copied to and executed on bootstrap instance.

x86_64/

The contents of this directory will be copied to /tmp on the instance building the 64-bit gentoo image.

i386/

The contents of this directory will be copied to /tmp on the instance building the 32-bit gentoo image.

x86_64/.config & i386/.config

The .config file for building the kernel.

make_latest_push.sh

Makes the latest gentoo AMI public.

Takes 3 options:

  1. region
  2. architecture
  3. root_device_type

Sample command for making us-east-1 64-bit EBS image public

./make_latest_public.sh us-east-1 x86_64 ebs

Sample command for making us-east-1 32-bit EBS image public

./make_latest_public.sh us-east-1 i386 ebs

Sample command for making us-east-1 64-bit Instance Store image public

./make_latest_public.sh us-east-1 x86_64 instance-store

copy_ebs_across_region.sh

Copies latest public EBS gentoo image across regions.

Takes 3 options:

  1. from_region
  2. architecture
  3. to_region

Sample command for copying 64-bit image from us-east-1 to us-west-2

./copy_ebs_across_region.sh us-east-1 x86_64 us-west-2

Sample command for copying 32-bit image from us-east-1 to us-west-2

./copy_ebs_across_region.sh us-east-1 i386 us-west-2

AMI_TYPE

Using the AMI_TYPE environment variable, variants of the AMI can be built. Currently there is only one value that does anything:

  • minimal

minimal

Will setup a minimal AMI.

The only items in /var/lib/portage/world are app-admin/sudo and sys-kernel/gentoo-sources

Setup across all regions

Need to setup only once.

./setup_build_gentoo.sh us-east-1

Building can be run in parallel to save time.

./build_gentoo_64.sh us-east-1 gentoo-bootstrap gentoo-bootstrap_us-east-1 gentoo-bootstrap_us-east-1.pem
./build_gentoo_32.sh us-east-1 gentoo-bootstrap gentoo-bootstrap_us-east-1 gentoo-bootstrap_us-east-1.pem

Copy across regions

./make_latest_public.sh us-east-1 x86_64 ebs
./make_latest_public.sh us-east-1 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 us-west-2
./copy_ebs_across_region.sh us-east-1 i386 us-west-2
./make_latest_public.sh us-west-2 x86_64 ebs
./make_latest_public.sh us-west-2 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 us-west-1
./copy_ebs_across_region.sh us-east-1 i386 us-west-1
./make_latest_public.sh us-west-1 x86_64 ebs
./make_latest_public.sh us-west-1 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 eu-west-1
./copy_ebs_across_region.sh us-east-1 i386 eu-west-1
./make_latest_public.sh eu-west-1 x86_64 ebs
./make_latest_public.sh eu-west-1 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 sa-east-1
./copy_ebs_across_region.sh us-east-1 i386 sa-east-1
./make_latest_public.sh sa-east-1 x86_64 ebs
./make_latest_public.sh sa-east-1 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 ap-northeast-1
./copy_ebs_across_region.sh us-east-1 i386 ap-northeast-1
./make_latest_public.sh ap-northeast-1 x86_64 ebs
./make_latest_public.sh ap-northeast-1 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 ap-southeast-1
./copy_ebs_across_region.sh us-east-1 i386 ap-southeast-1
./make_latest_public.sh ap-southeast-1 x86_64 ebs
./make_latest_public.sh ap-southeast-1 i386 ebs

./copy_ebs_across_region.sh us-east-1 x86_64 ap-southeast-2
./copy_ebs_across_region.sh us-east-1 i386 ap-southeast-2
./make_latest_public.sh ap-southeast-2 x86_64 ebs
./make_latest_public.sh ap-southeast-2 i386 ebs
Gentoo is a trademark of Gentoo Foundation, Inc. Gentoo Bootstrap is not part of the Gentoo Project and is not directed or managed by Gentoo Foundation, Inc.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.