iPXE discussion forum
iPXE and syslinux.cfg to run script - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: iPXE and syslinux.cfg to run script (/showthread.php?tid=24995)



iPXE and syslinux.cfg to run script - praines - 2020-07-17 15:21

I am creating a bootable USB image that uses iPXE built using syslinux. I have a script I want iPXE to automatically run. It works fine if I Embed it when I build the ipxe.lkrn file. But I want to have just a plain (non-embedded) ipxe.lkrn and the script on the USB key so that I can modify it a will.

My steps were:

Code:
cd ipxe/src
make bin/ipxe.lkrn
make bin-x86_64-efi/ipxe.efi

dd if=/dev/zero bs=100M count=1 of=usb.img
parted usb.img --script mktable gpt
parted usb.img --script mktable mkpart EFI fat16 1MiB 10MiB
parted usb.img --script mkpart EFI fat16 1MiB 10MiB
parted usb.img --script mkpart LEGACY fat16 10MiB 99MiB
parted usb.img --script set 2 legacy_boot on

gdisk usb.img
#(change type code on partition 1 to EF00)

kpartx -a -v -g usb.img
mkfs.vfat -n EFI /dev/mapper/loop1p1
mkfs.vfat -n LEGACY /dev/mapper/loop1p2
mkdir -p /mnt/loop/{EFI,LEGACY}
mount /dev/mapper/loop1p1 /mnt/loop/EFI
mount /dev/mapper/loop1p2 /mnt/loop/LEGACY

mkdir -p /mnt/loop/EFI/EFI/BOOT/
cp bin-x86_64-efi/ipxe.efi /mnt/loop/EFI/EFI/BOOT/BOOTX64.EFI

dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/gptmbr.bin of=/dev/loop1
syslinux --install /dev/mapper/loop1p2
cp bin/ipxe.lkrn /mnt/loop/LEGACY/ipxe
vi /mnt/loop/LEGACY/syslinux.cfg
#(see discussion below0
vi /mnt/loop/LEGACY/script
#(an ipxe script I want autorun with dhcp/menu/chain/etc.)

umount /mnt/loop/LEGACY
umount /mnt/loop/EFI
kpartx -d -v -g usb.img

For EFI I could find now docs on how to have it autorun a script on the usb image itself so I ended up creating bin-x86_64-efi/ipxe.efi with embedded script. Anyone have any ideas here I would love to know.

For LEGACY, I tried using syslinux.cfg and the first one I tried was:

Code:
default ipxeboot
label ipxeboot
  kernel /ipxe
  append /script

This just gave an error from ipxe that /script is an unknown command

I then tried

Code:
default ipxeboot
label ipxeboot
  kernel /ipxe
  append chain script

But this failed too saying the chain failed.

So I gave up and built ipxe.lkrn with the script embedded which works but makes it harder to change the script when I want

Any ideas? I am suprised ipxe does not have an "include" command for