PXE Boot – How to Create a PXE Boot Image Running a Single Executable

linuxpxe-boot

I'm in the process of setting up a compute cluster with the intent of using it for some parallel computing experiments. I have a single executable which I'd like to run on this cluster.

Due to operational constraints on said cluster I can only deploy this executable as a PXE boot image. Unfortunately, the only "ready-made" images I've been able to find are installation ones intended to install a particular distro. They don't particularly appear easy to modify.

Can someone perhaps provide some pointers as to how I could go about creating a pxelinux image that loads the linux kernel and subsequently run an executable?

Best Answer

Using ubuntu-18-x86_64-initrd.gz:

wget http://archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64/initrd.gz
gzip -d initrd.gz
mkdir image
cd image
cpio -idmv < ../initrd

Now copy your executable, required shared libraries, and other files needed by your executable into image/. Edit etc/inittab. You probably want to remove ::sysinit:. Change ::respawn: to be an invocation of your executable.

find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initrd-bionic-foo.gz

Copy initrd-bionic-foo.gz to your tftp server. Sample pxelinux.cfg entry:

default foo
label foo
kernel boot/Ubuntu-18.04-x86_64-linux
append initrd=boot/initrd-bionic-foo.gz
Related Topic