iPXE in Google Cloud

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

Launching

The GCE iPXE images are published from the ipxe-images project.

CPU architecture Project name Image family name
x86_64 ipxe-images ipxe
x86_64 (UEFI) ipxe-images ipxe-uefi-x86-64
arm64 (UEFI) ipxe-images ipxe-uefi-arm64

You can launch an instance using a command such as

  gcloud compute instances create \
         --image-project ipxe-images --image-family ipxe \
         ...

You can use any compatible GCE instance type (including instance types with the Google Virtual NIC (gVNIC) enabled).

Configuring

iPXE GCE instances are controlled via an iPXE script stored as instance metadata using the key name ipxeboot. The iPXE image 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://metadata.google.internal/computeMetadata/v1/instance/attributes/ipxeboot.

You can set the ipxeboot metadata using the --metadata-from-file option when creating the instance. For example:

  gcloud compute instances create \
         --image-project ipxe-images --image-family ipxe \
         --metadata-from-file=ipxeboot=my-ipxe-boot-script.ipxe \
         ...

You can use this metadata 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 ipxeboot metadata 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

GCE iPXE boot

Congratulations on successfully booting a Google Cloud instance using iPXE!

Success

Troubleshooting

You can view the iPXE output via the GCE serial port output. For example:

  gcloud compute instances get-serial-port-output <name>

You should see output similar to:

  iPXE 1.21.1+ -- Open Source Network Boot Firmware -- https://ipxe.org
  Features: DNS HTTP HTTPS iSCSI TFTP SRP AoE ELF MBOOT PXE bzImage Menu PXEXT
  Google Compute Engine - iPXE boot via metadata
  CPU: GenuineIntel            Intel(R) Xeon(R) CPU @ 2.20GHz
  net0: 42:01:0a:9a:00:25 using gve on 0000:00:04.0 (Ethernet) [closed]
    [Link:down, TX:0 TXE:0 RX:0 RXE:0]
    [Link status: Unknown (https://ipxe.org/1a086101)]
  Waiting for link-up on net0... ok
  Configuring (net0 42:01:0a:9a:00:25)...... ok
  net0: 10.154.0.37/255.255.255.255 gw 10.154.0.1
  net0: fe80::4001:aff:fe9a:25/64
  http://metadata.google.internal/computeMetadata/v1/instance/attributes/ipxeboot... ok

Building from source

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

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

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

howto/gce.txt ยท Last modified: 2024/07/24 21:05 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.