This repository provides the example code and instructions for building a customized Edge Workload Abstraction and Orchestration Layer (EWAOL) distribution in form of an Amazon Machine Image (AMI).
-
An AWS account and the necessary IAM rights to create EC2 instances, EBS snapshots, EBS volumes, S3 buckets, and IAM roles and policies.
-
A VPC with appropriate subnets and routing required to access the build server.
-
The resources created by deploying the VMImport CloudFormation Template (roles, policies, S3 bucket for images).
- Take note of the outputs of the stack deployment as they'll be needed in the following steps.
-
An arm64 Ubuntu 20.04 EC2 instance using a Graviton processor (e.g. c6g.4xlarge) with 150GB+ root disk with internet access using the instance profile created by the CloudFormation template from previous step (VMBuilderEC2Role).
-
Update the Operating System and install the pre-requisites for Yocto, Kas, and our image creation script:
sudo apt-get update sudo apt-get install -y gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev make python3-pip jq zstd liblz4-tool qemu-utils
-
Install AWS CLI v2:
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "/tmp/awscliv2.zip" unzip /tmp/awscliv2.zip -d /tmp sudo /tmp/aws/install
-
Install the python packages:
sudo pip3 install sphinx sphinx_rtd_theme pyyaml kas==3.0.2 git-remote-codecommit
-
Clone the repo from the instance or upload the code and invoke the build command. For example:
git clone https://github.com/aws4embeddedlinux/meta-aws-ewaol.git cd meta-aws-ewaol
-
Customize the ewaol-graviton2-ami.yaml as needed and invoke the build:
kas build kas/machines/ewaol-graviton2-ami.yaml
From meta-aws-ewaol directory, run the bash script. Replace <S3_BUCKET_IMPORT_IMAGES> with the bucket name created by the CloudFormation Stack in the pre-requisites section, then choose the appropriate size which the future root disk of the AMI should have by entering a number (e.g. 16) in place of <AMI_DISK_SIZE_IN_GB> :
bash scripts/create-ami.sh <S3_BUCKET_IMPORT_IMAGES> <AMI_DISK_SIZE_IN_GB>
- In the Web Console, Navigate to EC2->Images->AMIs.
- Select the desired AMI and click 'Launch instance from Image'.
- Follow the wizard as usual.
- Access the image with the previously provided ssh key with user ewaol.
The image does not yet support online expansion of partitions/filesystems via cloud-init. Follow the below workaround to expand the root partition and filesystem (this can be used as a user data script):
#!/bin/sh
# disabling swap
swapoff -a
sed -i '/.*swap.*/d' /etc/fstab
# trick to fix GPT
printf "fix\n" | parted ---pretend-input-tty /dev/nvme0n1 print
# remove partition 3 (swap)
parted -s /dev/nvme0n1 rm 3
# resize partition 2 to use 100% of available free space
parted -s /dev/nvme0n1 resizepart 2 100%
# resizing ext4 filesystem
resize2fs /dev/nvme0n1p2
- Enable support for expanding the filesystem on boot with cloud-init which depends on growpart. This needs cloud-utils which is not in openembedded recipes yet.
See CONTRIBUTING for more information.
This code is licensed under the MIT-0 License. See the LICENSE file.