iPXE in Amazon EC2

You can use iPXE to boot Amazon (AWS) EC2 instances using a public iPXE AMI. You can use an iPXE script to direct the EC2 instance to boot via any means supported by iPXE. For example, you could boot a set of diskless EC2 instances using HTTPS or iSCSI from a single server hosted in the same AWS region.

Launching

The EC2 iPXE images are published outside of the AWS Marketplace and are shared directly from account 833372943033.

Launch the latest iPXE AMI for your AWS region and CPU architecture from the table below:

AWS region CPU architecture AMI ID
af-south-1 x86_64 ami-06d597d38e8a578cd
af-south-1 arm64 ami-03719d8d751ee2d2e
ap-east-1 x86_64 ami-0a475f25a1b3e60ef
ap-east-1 arm64 ami-00358f64095b335eb
ap-northeast-1 x86_64 ami-0dab8fa52ec84aa78
ap-northeast-1 arm64 ami-0a345976e764dfe2e
ap-northeast-2 x86_64 ami-0416ae00cd48806c5
ap-northeast-2 arm64 ami-0a34d9b554c74c7af
ap-northeast-3 x86_64 ami-085b48faf06a54655
ap-northeast-3 arm64 ami-09aaba83098526309
ap-south-1 x86_64 ami-04492975caecf9d53
ap-south-1 arm64 ami-04237fbae1ab556c9
ap-south-2 x86_64 ami-015612971b103e78f
ap-south-2 arm64 ami-0d00c68f500cc7ec7
ap-southeast-1 x86_64 ami-0316170fa5b8ac1ad
ap-southeast-1 arm64 ami-0c152e7fa6111e01a
ap-southeast-2 x86_64 ami-0b333e182f6262eee
ap-southeast-2 arm64 ami-020a5df6a1f77ea05
ap-southeast-3 x86_64 ami-00c353f4aa6428bde
ap-southeast-3 arm64 ami-00c2e810ca6fd20f0
ap-southeast-4 x86_64 ami-0befbe5938635b5fa
ap-southeast-4 arm64 ami-0159084cf52ca4fc8
ap-southeast-5 x86_64 ami-01d7956ead8255530
ap-southeast-5 arm64 ami-01fc95dac82186a20
ca-central-1 x86_64 ami-06ee14d90e299e773
ca-central-1 arm64 ami-079398422e06d6324
ca-west-1 x86_64 ami-04b42427c4b6048bc
ca-west-1 arm64 ami-0107cc7afe67c5933
eu-central-1 x86_64 ami-0a6e6dbf3e8eda047
eu-central-1 arm64 ami-070b31fc8f51f5161
eu-central-2 x86_64 ami-0b47f7345438ecfdc
eu-central-2 arm64 ami-0636b666315ea3ce4
eu-north-1 x86_64 ami-01f4c8566743333c2
eu-north-1 arm64 ami-0ae6d063e58333a73
eu-south-1 x86_64 ami-052544cae0b645543
eu-south-1 arm64 ami-0fd94f8115ddb8cce
eu-south-2 x86_64 ami-0ce1caf1acf1ace5c
eu-south-2 arm64 ami-0205b74fcb1c35a09
eu-west-1 x86_64 ami-008a75417e2934a71
eu-west-1 arm64 ami-0772f55943f2bddb8
eu-west-2 x86_64 ami-0de42e27e4d955e32
eu-west-2 arm64 ami-02de0b06ee5011079
eu-west-3 x86_64 ami-0ea709c9a47667ac8
eu-west-3 arm64 ami-0c4645c152460c429
il-central-1 x86_64 ami-0bd817989b9e12622
il-central-1 arm64 ami-01926c20091d8e06f
me-central-1 x86_64 ami-04acfab1036244dcb
me-central-1 arm64 ami-07868331a6c943bc5
me-south-1 x86_64 ami-08852752ebb168e4a
me-south-1 arm64 ami-033d1c5164c1dad85
sa-east-1 x86_64 ami-0ae0375a87cf5eedf
sa-east-1 arm64 ami-0528d1e70fd64cfad
us-east-1 x86_64 ami-0c251d3330c2c9793
us-east-1 arm64 ami-0ef594dad6565da53
us-east-2 x86_64 ami-064999b96b089bd78
us-east-2 arm64 ami-0250d918ed5737fc1
us-west-1 x86_64 ami-094e51be5aae03db9
us-west-1 arm64 ami-0a4303d255ed3dd21
us-west-2 x86_64 ami-0e589596b7b8069d6
us-west-2 arm64 ami-07fd24e8c56a53881

You can use any compatible EC2 instance type (including instance types with Enhanced or SR-IOV networking).

Configuring

iPXE EC2 instances are controlled via an iPXE script stored as the instance user-data. The iPXE AMI includes an embedded script that will automatically obtain an IP address via DHCP, print out some useful diagnostic information, and then download and execute http://169.254.169.254/latest/user-data.

You can use this user-data iPXE script to direct the remainder of the network boot process. For example, to download and boot Tiny Core Linux, you could set your instance's user data to contain:

  #!ipxe
  set base http://tinycorelinux.net/12.x/x86/release/distribution_files/
  kernel ${base}/vmlinuz64 initrd=rootfs.gz initrd=modules64.gz
  initrd ${base}/rootfs.gz
  initrd ${base}/modules64.gz
  boot

EC2 iPXE boot

Congratulations on successfully booting an EC2 instance using iPXE!

Success

iSCSI

You can use your user-data script to direct iPXE to boot from an iSCSI target. For example: to boot from an iSCSI target hosted on another EC2 instance 172.16.0.1 within the same VPC, you could set your instance's user data to contain:

  #!ipxe
  sanboot iscsi:172.16.0.1::::iqn.1995-08.org.example.iscsitarget:disk1

Note that the operating system on the iSCSI target disk will need to include the appropriate software and configuration to allow it to identify its own iSCSI root disk. You can install software such as sanbootable to help set up the required configuration.

IPv6

The iPXE AMI will include support for both IPv4 and IPv6. You should enable IPv6 in your VPC to speed up the boot, since otherwise iPXE will spend several seconds attempting to obtain an IPv6 address.

Troubleshooting

You can view the iPXE output via the EC2 system log or instance screenshot. For example:

  aws ec2 get-console-output --query Output --output text \
          --instance-id i-04549ed5e420eae6e

You should see output similar to:

  iPXE 1.21.1+ (gfa012) -- Open Source Network Boot Firmware -- http://ipxe.org
  Features: DNS HTTP HTTPS iSCSI TFTP SRP AoE ELF MBOOT PXE bzImage Menu PXEXT
  Amazon EC2 - iPXE boot via user-data
  CPU: GenuineIntel Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
  net0: 06:ee:8d:98:cc:67 using netfront on vif/0 (Ethernet) [closed]
    [Link:up TX:0 TXE:0 RX:0 RXE:0]
  Configuring (net0 06:ee:8d:98:cc:67)...... ok
  net0: 172.31.41.104/255.255.240.0 gw 172.31.32.1
  net0: fe80::4ee:8dff:fe98:cc67/64
  http://169.254.169.254/latest/user-data... ok

Warning

Note that there is often a time delay of several minutes in obtaining system logs or instance screenshots from EC2 - this is a longstanding problem with EC2 itself and is not related to iPXE. You may need to retry the command several times (or possibly stop the instance) in order to obtain any output.

Building from source

You can build your own version of the public iPXE AMIs using:

  make CONFIG=cloud EMBED=config/cloud/aws.ipxe bin-x86_64-pcbios/ipxe.usb
  
  make CONFIG=cloud EMBED=config/cloud/aws.ipxe \
       CROSS=aarch64-linux-gnu- bin-arm64-efi/ipxe.usb

and import them using the aws-import tool (found in the contrib directory in the iPXE source tree).

howto/ec2.txt ยท Last modified: 2023/11/07 16:19 by mcb30
Recent changes RSS feed CC Attribution-Share Alike 4.0 International Driven by DokuWiki
All uses of this content must include an attribution to the iPXE project and the URL https://ipxe.org
References to "iPXE" may not be altered or removed.