Giter Site home page Giter Site logo

gentoo-ami-builder's Introduction

Gentoo AMI Builder

Features

  • Single simple command line tool to create bootable Gentoo AMI images.
  • Uses spot instances by default to save up to 50% on bill. One image build usually costs less than ~20 cents (as of 2020-10-14).
  • Supports any customization and any kernel version (aws ec2 import-image supports only fixed predefined list of kernels).
  • Build time is around ~50 mins for amd64 and ~90 mins for arm64 with default instance types (as of 2020-10-14).
  • Steals kernel config from Amazon Linux so configures all needed kernel modules, including block device drivers to boot instance (NVMe etc) and network drivers to have network after boot (IXGBEVF, ENA etc).
  • Should support all known HVM types of instances (including amd64 and arm64).
  • Minimalistic, only mandatory packages will be installed to get bootable system. System eats just ~50 MB of RAM after boot.
  • Uses minimalistic ec2-init script that can bootstrap hostname, ssh keys and run shell script from EC2 user metadata similar to how cloud-init do that.
  • Nice, not too verbose, progress reporting with advanced verbose error handling.
  • Supports OpenRC and Systemd init systems.
  • Supports profile switching, including upgrade to 17.1 from 17.0 amd64 profiles.
  • Highly customizable (well, it is Gentoo), open source and free :-)
  • Multi-region support.
  • Automatic fresh Amazon Linux 2 image detection.

How it works

The builder replaces Amazon Linux with Gentoo Linux using second volume as temporary buffer (aux disk) in a few phases:

  • Phase 1: Prepare Instance - Spawn instance with Amazon Linux and two volumes
  • Phase 2: Prepare Root - Prepare second volume and install Gentoo stage3 to it
  • Phase 3: Build Root - Make Gentoo on second volume bootable
  • Phase 4: Switch Root - Reconfigure bootloader and reboot from second volume
  • Phase 5: Migrate Root - Clone second volume to first and reboot from first volume
  • Phase 6: Build AMI - Request AMI from first volume

The build process is orchestrated by builder so ensure that network connection is stable, otherwise, the process could crash.

"Build Root" has bottleneck on CPU.

"Migrate Root" has bottleneck on disk IO bandwidth (cloning volume to volume).

"Build AMI" has bottleneck on AWS, not controllable on our side.

Using more powerfull instance type helps to make Phase 3 faster, however, it doesn't have noticeable effect on other phases.

The builder is configured to use default instance types that are well-known to have good build time / cost ratio. You can pick another instance type to speedup the build or to make build process cheaper. Keep in mind, build on instance with less than 2GB of RAM will most-likely fail on kernel compilation phase.

Prerequisites

  • Locally installed and configured aws cli.
  • Linux or macOS with openssh, bash, curl, coreutils
  • AWS account
  • SSH key generated in AWS console or imported into AWS account (Key Pair)
  • AWS security group that allows incoming connections on 22 port
  • AWS user with enabled programmatic access
    • Permissions to build on on-demand instances:
      • ec2:CreateTags
      • ec2:RunInstances
      • ec2:TerminateInstances
      • ec2:DescribeInstances
      • ec2:CreateImage
      • ec2:DeregisterImage
      • ec2:DescribeImages
      • ec2:DeleteSnapshot
      • sts:GetCallerIdentity
    • Additional permissions to build on spot instances:
      • ec2:DescribeSpotInstanceRequests
      • ec2:RequestSpotInstances
    • Additional permission needed the first time you launch a spot instance. You don't need this if you already have the AWSServiceRoleForEC2Spot Service-Linked Role in your account; it's automatically created by the console app the first time you create a spot instance.
      • iam:CreateServiceLinkedRole

Usually the easiest solution is to just temporarily add AWS managed policy "AdministratorAccess" to your user.

Alternatively, this policy can be used to grant AWS user all needed permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:CreateTags",
        "ec2:RunInstances",
        "ec2:TerminateInstances",
        "ec2:DescribeInstances",
        "ec2:CreateImage",
        "ec2:DeregisterImage",
        "ec2:DescribeImages",
        "ec2:DescribeSpotInstanceRequests",
        "ec2:DeleteSnapshot",
        "ec2:RequestSpotInstances",
        "iam:CreateServiceLinkedRole",
        "sts:GetCallerIdentity"
      ],
      "Resource": "*"
    }
  ]
}

Usage

Usually you just need to configure aws cli and run command below to get working default Gentoo AMI amd64 / OpenRC image:

git checkout https://github.com/sormy/gentoo-ami-builder
cd gentoo-ami-builder
./gentoo-ami-builder.sh --key-pair "Your Key Pair Name"

You will find an AMI in AWS console once the builder will finish the process. The image can be used to start any instance for the same platform.

NOTE: Spot instances are used by default to save on bill.

The most important options:

  • --region - custom AWS region (by default it is us-east-1)
  • --subnet-id - AWS VPC subnet for spawned instance
  • --security-group - custom security group to attach to spawn instance
  • --key-pair - required to access EC2 builder instance over SSH
  • --gentoo-stage3 - pick what stage3 to use, usually, amd64 or arm64
  • --gentoo-image-name - what AMI name prefix to use
  • --user-phase - local script to sideload and execute to bootstrap additional tools into Gentoo AMI image
  • --update-world - setting to no can signtificantly reduce build time at the cost of using stage3 prebuilt packages as it is without attempt to rebuild or update them

In addition, some environment variables affect the underlying subsystems:

  • AWS_PROFILE, used by the AWS CLI commands.

  • SSH_OPTS is passed to ssh. For example, -i myidentityfile.pem -o ServerAliveInterval=30

  • GENKERNEL_OPTS, passed to genkernel

Run gentoo-ami-builder --help to see full list of available options.

Doesn't work? Please file a bug and we will take care of it!

Troubleshooting

Can't connect over SSH during prepare instance phase

Check if default security group "default" has enabled incoming access on 22 port form 0.0.0.0 or your IP address.

Timeout on "Waiting until AMI image will be available"

The time that takes to create image depends on multiple factors, including region, time of the day, day of the week, type of instance, size of volume etc.

Failing on last step doesn't mean that image creation won' be finished at all, most likely it will finish, but a bit later. You can still monitor progress in AWS console.

If you are experience continues failures when default 30 minutes is not enough, then submit an issue on the tracker.

Customization

Custom user phase build script

Use --user-phase option to pass custom script that can do any kind of special configuration, install needed packages, anything that is needed to make a base AMI for your use cases.

Custom provisioning script

Produced image has ec2-init service that automatically do a provisioning for hostname, ssh keys and can also execute custom provisioning shell script provided using EC2 metadata.

Read more here about ec2-init: https://github.com/sormy/ec2-init#module-exec

Read more about EC2 metadata: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html

Stage3

Here are all available Gentoo stage3 tarballs that are theoretically compatible with EC2 hardware (as of 2022-02-13):

Stage3 Profile Arch Status Last Verified
amd64-desktop-openrc default amd64 โ“
amd64-desktop-systemd default amd64 โ“
amd64-hardened-nomultilib-openrc default amd64 ๐Ÿ†— v1.1.0 on 2020-10-14
amd64-hardened-nomultilib-selinux-openrc default amd64 ๐Ÿ†— v1.1.0 on 2020-10-14
amd64-hardened-openrc default amd64 ๐Ÿ†— v1.1.0 on 2020-10-14
amd64-hardened-selinux-openrc default amd64 ๐Ÿ†— v1.1.0 on 2020-10-14
amd64-musl default amd64 โŒ v1.1.0 on 2020-10-14
amd64-musl-hardened default amd64 โŒ v1.1.0 on 2020-10-14
amd64-nomultilib-openrc default amd64 ๐Ÿ†— v1.1.0 on 2020-10-14
amd64-nomultilib-systemd default amd64 โ“
amd64-openrc default amd64 ๐Ÿ†— v1.1.7 on 2023-03-03
amd64-systemd default amd64 ๐Ÿ†— v1.1.7 on 2023-03-03
arm64 default arm64 โ“
arm64-desktop-openrc default arm64 โ“
arm64-desktop-systemd default arm64 โ“
arm64-musl default arm64 โ“
arm64-musl-hardened default arm64 โ“
arm64-openrc default arm64 ๐Ÿ†— v1.1.7 on 2023-03-03
arm64-systemd default arm64 ๐Ÿ†— v1.1.7 on 2023-03-03
i486-openrc default x86 โŒ
i686-hardened-openrc default x86 โŒ
i686-musl default x86 โŒ
i686-openrc default x86 โŒ
i686-systemd default x86 โŒ
x32-openrc default amd64 ๐Ÿ†— v1.1.1 on 2020-10-20

Status:

  • ๐Ÿ†— - it works, verified by maintainers
  • โŒ - it doesn't work, verified by maintainers (PRs are welcome!)
  • โ“ - not verified, could work or not, please submit a PR to update this table if you have tested the stage (PRs for fixes are also welcome!)

Problems:

  • x86 (stable) - needs x86 kernel config generated from amd64 config
  • musl (exp) - kernel compilation fails (dive deep)
  • uclibc (exp) - gettext compilation fails during world update (dive deep)

EC2 Instance Type

The build is tested to be working well on these instance types.

  • amd64 / c6a.2xlarge (network ENA, block NVMe, MBR boot)
  • amd64 / c6in.2xlarge (network ENA, block NVMe, MBR boot)
  • arm64 / t4g.xlarge (default cpu credits, ENA, NVME, EFI)
  • arm64 / c7g.2xlarge (network ENA, block NVME, EFI boot)

Build process on slow instances could fail (due to lack of RAM) or could take a lot of time (due to low CPU performance). For a default build (minimal compilation) all of the 8-CPU instances are about the same, whether amd64 or arm64, and take about an hour. The exception is c6in; it reduces elapsed time by 25% over the c6a or c6i, mostly due to reduced waiting for the AMI image to be available. The t4g.xlarge (4 cores) is about 15 minutes slower than the t4g.2xlarge.

Init System

This builder has been tested to work well with two init systems:

  • OpenRC (default)
  • Systemd

Kernel Config

This script uses kernel config that is used in Amazon Linux instances. This is a reason why bootstrap should be performed using Amazon Linux distribution, to steal kernel config :-)

By the way, there are some additional fixes performed by this script:

  • Some instances, like C4, have network only with IXGBEVF driver. Stock config has different name for driver so without fix it won't be enabled by default.
  • Some instances, like C5, have network only with ENA driver. This driver need to be compiled during installation from sources provided by Amazon.
  • Modern instances, C/M/R5 and above, and T3 and above, have NVMe block devices. The NVMe driver needs to be compiled into kernel to make sure that Gentoo will load it before mounting the root.

NOTE: EFA driver is not available yet. PRs are welcome!

FAQ

Downloading stage3 is slow

Sometimes Gentoo distfile server could work slow, around 200Kb/sec, making whole process much slower. You could terminate AMI builder and restart. New request will be most-likely served from another distfile server and will be fast. Another option is to change distfile server in settings to the one that you trust.

NOTE: Ensure that there are no any not terminated instances running if build process has been terminated.

AMI image creation is slow

AMI image creation could be slow, usually it is up to 10-20 minutes for 20GB volume.

What about PVM instances?

PVM is used on old instance types C1, C3, HS1, M1, M3, M2, and T1 that are not highly available these days and will be all eventually replaced with modern HVM instances.

Read more: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html

PVM is not supported at this time but technically can be implemented. Need to configure a bit differently bootloader and kernel.

Feel free to submit a PR that adds PVM support.

What about x86 support?

x86 architecture is not supported at this time but technically can be implemented.

Please also consider using Gentoo x32 stage3 that has benefits of both amd64 and x86 worlds.

Feel free to submit a PR that adds x86 support.

Why can't we just use aws ec2 import-image?

AWS cli has a command aws ec2 import-image that is designated to import existing disk images, however, there are a few reasons why it is not used in this builder:

  • It is picky to image content. It does STRICT validation of image, including kernel version, so you can easy get something like message below: "ClientError: Unsupported kernel version 5.4.66-gentoo-x86_64"
  • It is picky to image format. Only raw images are generally acceptable without compatibility issues. For vmdk created with qemu-img it produces this error: "ClientError: Disk validation failed [Unsupported VMDK File Format]"
  • It requires to upload image file to s3 before the process can be executed. This also makes process slower and adds additional cost for big images.
  • It is slower because source image is converted from source format to the format used by AWS.

This builder script doesn't have these limitations but the procedure it performs is more complex.

Examples

Success p1

Success p2

Success p3

Failure

Build log examples: amd64 amd64-systemd arm64 arm64-systemd x32

Reporting Issues

Gentoo is rolling release system, AWS is also releasing new instance types periodically, so the builder that worked Yesterday could stop working Today. This application requires periodical maintenance to ensure that it is still working on latest Gentoo and new AWS instance type. Please file a bug if you are experiencing an issue and we will take care of it.

Please use the GitHub issue tracker for any bugs or feature suggestions.

Contributing

Contributions are very welcome!

Please take a look on TODO to see what things could be improved.

Please submit fixes or improvements as GitHub pull requests!

For code changes please consider doing 4 default builds to verify that there are no any regressions: amd64, amd64-systemd, arm64 and arm64-systemd.

Contributions must be licensed under the MIT.

Copyright

gentoo-ami-builder is licensed under the MIT.

A copy of this license is included in the file LICENSE.txt

gentoo-ami-builder's People

Contributors

hlein avatar kensington avatar mgsouth avatar mrknarfy avatar sormy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gentoo-ami-builder's Issues

Gentoo portage location has been changed

 * PHASE 3: Build Root
 *   Updating configuration...
 *   Tuning compiler options...
 *   Rebuilding the world...
 *   Process has failed with error code 1: emerge --quiet --update --deep --newuse --with-bdeps=y @world
     > !!! Section 'gentoo' in repos.conf has location attribute set to nonexistent directory: '/var/db/repos/gentoo'
     > !!! Invalid Repository Location (not a dir): '/var/db/repos/gentoo'
     >
     >
     > !!! /etc/portage/make.profile is not a symlink and will probably prevent most merges.
     > !!! It should point into a profile within /var/db/repos/gentoo/profiles/
     > !!! (You can safely ignore this message when syncing. It's harmless.)
     >
     >
     > !!! Your current profile is invalid. If you have just changed your profile
     > !!! configuration, you should revert back to the previous configuration.
     > !!! Allowed actions are limited to --help, --info, --search, --sync, and
     > !!! --version.
 *   Phase bootstrap has failed

latest-stage3-*.txt files are now PGP signed, breaks parsing

latest-stage3-*.txt files are now PGP signed, so when lib/phase2-prepare-root.sh grabs the appropriate latest-stage3-$GENTOO_STAGE3.txt and tries to extract the correct filename, unexpected contents cause curl to go off the deep end:

 *   Installing stage3...
 *     Downloading: http://distfiles.gentoo.org/releases/amd64/autobuilds/-----BEGIN
Hash:

20240317T170433Z/stage3-amd64-hardened-openrc-20240317T170433Z.tar.xz
-----BEGIN

iQEzBAEBCAAdFiEEU05CCatJ7uHBnZYWLERpXbn2BD0FAmX6J0AACgkQLERpXbn2
BD1+UQf/eIO14P/a7dBVTWzeBsciEUbHtKvj8ROtFrqI+QPXycnWIYwycfIqLaim
Y0zVmmvuBTCM/jeZMcxjY0C9Z0TyCjGUfZHwmdIbn89XXT1Tjx23Ngor4OTAez+K
aUMCupGM/UfWaLtgk8KziTb7HdB2TfqL/zCp60fZECauHsEGOfQ/eZNqRAJ+cyLC
Fhjc/ceY5eR3sdweE8C4RZR2ePoSfvB45RUgtb5A8RIJsgP6lhrdOulxW9+kSTQX
jGYwj+vFoS8Y3NBJlDhIs4XNLSApJqbzZWo/SaabBqQiL212MULKM/bN/rHsbUAV
zn4UK9cetQi2BU010PUT6NtG3oHhUg==
=sk/3
-----END ...
 *     Process has failed with error code 3: curl --silent --fail -o "3
-----END" "http://distfiles.gentoo.org/releases/amd64/autobuilds/-----BEGIN
Hash:

20240317T170433Z/stage3-amd64-hardened-openrc-20240317T170433Z.tar.xz
-----BEGIN
...

A closer look confirms it really is trying to grab that whole thing as the URL, since STAGE3_PATH gets populated with all of it.

One approach would just be to strip out more stuff to find the dir/file part. But since these signatures are available, we should probably also use/validate them. Experimental PR incoming.

Script fails after phase 4 - instance not accessible through SSH

When attempting to build a default gentoo profile on m5zn.metal, m5zn.6xlarge and c5.2xlarge, the instance apparently becomes inaccessible over ssh.
I shall try again and will add the output to this issue.

Cheers.
Frank.

PS: this was all in us-west-2. I will now run the command line as suggested in the documentation.

grub-install failed due to error embedding is not possible

 *   Mounting primary disk...
 *     Mounting root...
 *     Mounting proc/sys/dev...
 *   Cleaning primary disk...
 *   Fixing boot on primary disk...
 *     Installing bootloader into MBR...
 *     Process has failed with error code 1: chroot /mnt/gentoo grub-install /dev/nvme0n1
       > Installing for i386-pc platform.
       > grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
       > grub-install: error: embedding is not possible, but this is required for cross-disk install.
 *   Phase bootstrap has failed
 * Terminating instance...

I got the issue when building on C6in.2xlarge instance. Is there any solution / pointer for me to solve this issue?

Kernel compatible issue with ena driver

With the latest stable 5.15.11 kernel, the ena driver doesn't compile. It works fine with 5.10.x version.

   >   CC [M]  /var/tmp/portage/net-misc/ena-2.6.0/work/amzn-drivers-ena_linux_2.6.0/kernel/linux/ena/ena_sysfs.o
   > /var/tmp/portage/net-misc/ena-2.6.0/work/amzn-drivers-ena_linux_2.6.0/kernel/linux/ena/ena_ethtool.c:1072:35: error: initialization of โ€˜int (*)(struct net_device *, struct ethtool_coalesce *, struct kernel_ethtool_coalesce *, struct netlink_ext_ack *)โ€™ from incompatible pointer type โ€˜int (*)(struct net_device *, struct ethtool_coalesce *)โ€™ [-Werror=incompatible-pointer-types]
   >  1072 |         .get_coalesce           = ena_get_coalesce,

Maybe a kernel option will benefit?

User Credentials

Anyone knows what is the username created in the AMI? I am unable to log into EC2 as it is asking for a password also tried to connect with the root/gentoo/admin username and it failed

Phase bootstrap has failed

First of all, I had to change the AWS AMI id as it couldn't find a matching one so I looked that the available AMI and used that instead. I mentioned this as I am not sure if this could be the cause of the problem below;

`* PHASE 2: Prepare Root

  • Synchronizing time...
  • Process has failed with error code 1: yum -y -q install ntp

    Existing lock /var/run/yum.pid: another copy is running as pid 2990.
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:10 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:12 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:14 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:16 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:18 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:20 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:22 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:24 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:26 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:28 ago
    State : Sleeping, pid: 2990
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 31 M RSS (323 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:30 ago
    State : Sleeping, pid: 2990
    Existing lock /var/run/yum.pid: another copy is running as pid 2994.
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:32 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:34 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:36 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:38 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:40 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:42 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:44 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:46 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:48 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:50 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:52 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:54 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:56 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 00:58 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 01:00 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 01:02 ago
    State : Sleeping, pid: 2994
    Another app is currently holding the yum lock; waiting for it to exit...
    The other application is: yum
    Memory : 35 M RSS (328 MB VSZ)
    Started: Fri Dec 4 12:53:48 2020 - 01:04 ago
    State : Sleeping, pid: 2994

    One of the configured repositories failed (Unknown),
    and yum doesn't have enough cached data to continue. At this point the only
    safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.
    
     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).
    
     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...
    
     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:
    
            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>
    
     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:
    
            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
    

    Cannot find a valid baseurl for repo: amzn2-core/2/x86_64
    Could not retrieve mirrorlist http://amazonlinux.eu-west-2.amazonaws.com/2/core/latest/x86_64/mirror.list error was
    12: Timeout on http://amazonlinux.eu-west-2.amazonaws.com/2/core/latest/x86_64/mirror.list: (28, 'Connection timed out after 5000 milliseconds')

  • Phase bootstrap has failed
  • Terminating instance...
    `

ena-driver build failure

*   Process has failed with error code 1: emerge --quiet net-misc/ena-driver
     > >>> Verifying ebuild manifests
     > 
     >  * IMPORTANT: 11 news items need reading for repository 'gentoo'.
     >  * Use eselect news read to view new items.
     > 
     > >>> Emerging (1 of 2) virtual/linux-sources-3-r6::gentoo
     > >>> Installing (1 of 2) virtual/linux-sources-3-r6::gentoo
     > >>> Emerging (2 of 2) net-misc/ena-driver-2.2.3-r1::gentoo
     > >>> Failed to emerge net-misc/ena-driver-2.2.3-r1, Log file:
     > >>>  '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/temp/build.log'
     >  * Package:    net-misc/ena-driver-2.2.3-r1
     >  * Repository: gentoo
     >  * Maintainer: [email protected]
     >  * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU
     >  * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox
     >  * Determining the location of the kernel source code
     >  * Found kernel source directory:
     >  *     /usr/src/linux
     >  * Found sources for kernel version:
     >  *     5.10.61-gentoo-x86_64
     >  * Checking for suitable kernel configuration options...
     >  [ ok ]
     > ln: failed to create symbolic link 'Module.symvers': File exists
     >  * Preparing ena module
     > make -C /usr/src/linux M=/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena modules
     > make[1]: Entering directory '/usr/src/linux-5.10.61-gentoo'
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.o
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_ethtool.o
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/dim.o
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/net_dim.o
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/../common/ena_com//ena_com.o
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/../common/ena_com//ena_eth_com.o
     >   CC [M]  /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_sysfs.o
     > In file included from /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.h:36,
     >                  from /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.c:52:
     > /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/kcompat.h:42: warning: "KERNEL_VERSION" redefined
     >    42 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
     >       | 
     > In file included from /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.c:45:
     > ./include/generated/uapi/linux/version.h:2: note: this is the location of the previous definition
     >     2 | #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
     >       | 
     > /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.c: In function โ€˜ena_xdp_tx_map_buffโ€™:
     > /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.c:303:18: error: implicit declaration of function โ€˜convert_to_xdp_frameโ€™; did you mean โ€˜xdp_convert_zc_to_xdp_frameโ€™? [-Werror=implicit-function-declaration]
     >   303 |  tx_info->xdpf = convert_to_xdp_frame(xdp);
     >       |                  ^~~~~~~~~~~~~~~~~~~~
     >       |                  xdp_convert_zc_to_xdp_frame
     > compilation terminated due to -Wfatal-errors.
     > cc1: some warnings being treated as errors
     > make[2]: *** [scripts/Makefile.build:280: /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena/ena_netdev.o] Error 1
     > make[2]: *** Waiting for unfinished jobs....
     > make[1]: *** [Makefile:1822: /var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena] Error 2
     > make[1]: Leaving directory '/usr/src/linux-5.10.61-gentoo'
     > make: *** [Makefile:40: all] Error 2
     >  * ERROR: net-misc/ena-driver-2.2.3-r1::gentoo failed (compile phase):
     >  *   emake failed
     >  * 
     >  * If you need support, post the output of `emerge --info '=net-misc/ena-driver-2.2.3-r1::gentoo'`,
     >  * the complete build log and the output of `emerge -pqv '=net-misc/ena-driver-2.2.3-r1::gentoo'`.
     >  * The complete build log is located at '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/temp/build.log'.
     >  * The ebuild environment file is located at '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/temp/environment'.
     >  * Working directory: '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena'
     >  * S: '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena'
     >  * Messages for package net-misc/ena-driver-2.2.3-r1:
     >  * ERROR: net-misc/ena-driver-2.2.3-r1::gentoo failed (compile phase):
     >  *   emake failed
     >  * 
     >  * If you need support, post the output of `emerge --info '=net-misc/ena-driver-2.2.3-r1::gentoo'`,
     >  * the complete build log and the output of `emerge -pqv '=net-misc/ena-driver-2.2.3-r1::gentoo'`.
     >  * The complete build log is located at '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/temp/build.log'.
     >  * The ebuild environment file is located at '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/temp/environment'.
     >  * Working directory: '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena'
     >  * S: '/var/tmp/portage/net-misc/ena-driver-2.2.3-r1/work/amzn-drivers-ena_linux_2.2.3/kernel/linux/ena'
     > 
     > 
     > 
     >  * IMPORTANT: 11 news items need reading for repository 'gentoo'.
     >  * Use eselect news read to view new items.
     > 
 *   Phase bootstrap has failed

systemd profiles are not supported

Unable to get past installation of portage repo since amd64-systemd profile does not have usr/.

 *   Installing portage repo...
 *     Initializing...
 *     Process has failed with error code 1: cp -f /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf                                    
       > cp: cannot stat โ€˜/mnt/gentoo/usr/share/portage/config/repos.confโ€™: No such file or directory                                                                                
 *   Phase bootstrap has failed

`sfdisk` broken on create partition (invalid option --label)

ap-southeast-2
ami-09cc0712275eacf93

sfdisk choked on create partition.
Manually edited this change using parted (possibly also not the best fix as we care about source and target sizes)
phase2-prepare-root.sh

# create partition with the same size on first disk to use `dd` later
#sfdisk --dump "$PRI_DISK_DEV" | grep "$PRI_ROOT_DEV\b" | grep -o 'size=[^,]*' | \
#    eexec sfdisk --label gpt "$AUX_DISK_DEV"
PRI_DISK_SIZE=$(parted -a optimal $PRI_ROOT_DEV unit B -- print | grep "^Disk /" | awk -F' ' '{print $3}')
einfo "Original partition size: $PRI_DISK_SIZE..."
einfo "Creating disk label..."
eqexec parted -a optimal $AUX_DISK_DEV unit B -- mklabel gpt
einfo "Creating target partition..."
parted -a optimal $AUX_DISK_DEV unit B -- mkpart pri 0% $PRI_DISK_SIZE

Phase2 - ntpd is broken on latest amazon linux ami

ap-southeast-2
ami-09cc0712275eacf93

NOTE: Doesn't seem to work when ntpd is already running

 *   Process has failed with error code 1: ntpd -gq
     > 18 Aug 03:43:28 ntpd[2688]: ntpd [email protected] Thu Sep 24 16:50:31 UTC 2020 (1): Starting
     > 18 Aug 03:43:28 ntpd[2688]: Command line: ntpd -gq
     > 18 Aug 03:43:28 ntpd[2688]: ----------------------------------------------------
     > 18 Aug 03:43:28 ntpd[2688]: ntp-4 is maintained by Network Time Foundation,
     > 18 Aug 03:43:28 ntpd[2688]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
     > 18 Aug 03:43:28 ntpd[2688]: corporation.  Support and training for ntp-4 are
     > 18 Aug 03:43:28 ntpd[2688]: available at https://www.nwtime.org/support
     > 18 Aug 03:43:28 ntpd[2688]: ----------------------------------------------------
     > 18 Aug 03:43:28 ntpd[2688]: proto: precision = 0.058 usec (-24)
     > 18 Aug 03:43:28 ntpd[2688]: basedate set to 2020-09-12
     > 18 Aug 03:43:28 ntpd[2688]: gps base set to 2020-09-13 (week 2123)
     > 18 Aug 03:43:28 ntpd[2688]: unable to bind to wildcard address 0.0.0.0 - another process may be running - EXITING

Manually routed around thusly (probably isn't the best way)
phase2-prepare-root.sh:

# having wrong time will cause all kinds of troubles
##eexec yum -y -q install ntp
##eexec ntpd -gq
eexec service ntpd stop
eexec ntpd -gq
eexec service ntpd start

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.