The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 807 - File: showthread.php PHP 7.3.15 (Linux)
File Line Function
/showthread.php 807 errorHandler->error





Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
iPXE and syslinux.cfg to run script
2020-07-17, 15:21
Post: #1
iPXE and syslinux.cfg to run script
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
Find all posts by this user
Quote this message in a reply
Post Reply 


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



User(s) browsing this thread: 2 Guest(s)