How can I create a PXE boot image that runs a single executable on startup?

Posted on

How can I create a PXE boot image that runs a single executable on startup? – A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about How can I create a PXE boot image that runs a single executable on startup? was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, pxe-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?

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

Leave a Reply

Your email address will not be published.