Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Referring to files in the initial RAM disk
2019-12-03, 10:01
Post: #8
RE: Referring to files in the initial RAM disk
Hi NikiZe and MultimediaMan,

I had a cursory look at the ipxe source and saw that the register_image() function uses the "image" DEBUG option to output what it is doing, so I enabled that. I also added my own debug statement in src/core/image.c:

> DBGC ( image, "IMAGE trying to execute [%s].\n", image->name );

I recompiled the ipxe.lkrn binary with my background.png embedded via EMBED=background.png and used isolinux to load my ipxe script via its INITRD directive. Here's the make command:

> EXTRA_CFLAGS=-fno-pie make DEBUG=image TRUST=config/local/quo-vadis-root-ca2.crt EMBED=/home/dug/background.png CONFIG=pcbios bin-x86_64-pcbios/ipxe.lkrn

This is my isolinux.cfg (apologies for the 8.3 names, I haven't got pycdlib Joliet working yet):

> SAY iPXE ISO boot image
> TIMEOUT 30
> DEFAULT ipxe.lkrn
> LABEL ipxe.lkrn
> KERNEL ipxe.krn
> INITRD initrd.ipx

My initrd.ipx script does a similar thing to MultimediaMan's. It displays a menu of available network interfaces, once one is chosen, it displays another menu asking if the user wants DHCP or to specify static IP details, it then brings up the chosen network interface with the desired settings and chains to my API which provides everything needed to install an arbitrary OS.

I confess I used a free online OCR site to read my VM screen output, so please allow for the odd mistake... here's what happened:

> ISOLINUX 6.03 20171017 ETCD Copyright © 1994-2014 H. Peter Anvin et al
> iPXE ISO boot
> image loading ipxe.krn... ok
> loading initrd.ipx...ok
> IMAGE background.png at [bfcef339,bfdcd7da) registered
> IMAGE background.png is not Multiboot: Exec format error (http://ipxe.org/20330001)
> IMAGE background.png is not ELF: Exec format error (http://ipxe.org/20360001)
> IMAGE background.png is not script: Exec format error (http://ipxe.org/20320001)
> IMAGE background.png is not bzImage: Exec format error (http://ipxe.org/20310001)
> IMAGE background.png is not COM32: Exec format error (http://ipxe.org/20300001)
> IMAGE background.png is not COMBOOT: Exec format error (http://ipxe.org/20370001)
> IMAGE background.png is not DER: Error 0x3e00033b (http://ipxe.org/303003310)
> IMAGE background.png is not PEM: No such file or directory (http://ipxe.org/2d09003b)
> IMAGE background.png is PNG PXE
> initialising devices...
> IMAGE <INITRD> at Ibfc4d000,bfc4e76f) registered
> IMAGE <INITRD> is not Multiboot: Exec format error (http://ipxe.org/2e838001)
> IMAGE <INITRD> is not ELF: Exec format error (http://ipxe.org/2e868001)
> IMAGE <INITRD> is script
> iPXE 1.0.0. (a4f8) -- Kicker Firmware: dscoular http://ipxe.org Features: DNS HTTP HTTPS iSCSI NFS TFTP SRP AoE ELF MBOOT PXE bzImage COMBOOT Menu PXEXT
> IMAGE trying to execute [background.png].
> An operating system wasn't found. Try disconnecting any drives that don't
> contain an operating system.
> Press Ctrl+Alt+Del to restart

We see that the embedded background.png file is being loaded, registered and recognised as a PNG file and that the ipxe script I included via isolinux' INITRD command was loaded and recognised as a script by the image_probe() function but with the weird name of <INITRD>.

However, we also see that ipxe is trying to execute the PNG file which, naturally, causes it to crash out into the BIOS.

Based on your forum responses, I think this means that I have to add an extra ipxe script to my make command's EMBED variable.

Let's I try that.

I create the following embedded.ipxe script which I hope will help me identify if it runs:

> #!ipxe
> echo Embedded.ipxe is dropping to the iPXE shell... ||
> shell

I recompile ipxe.lkrn with my new double-barrelled EMBED variable:

> EXTRA_CFLAGS=-fno-pie make DEBUG=image TRUST=config/local/quo-vadis-root-ca2.crt EMBED=embedded.ipxe,/home/dug/background.png CONFIG=pcbios bin-x86_64-pcbios/ipxe.lkrn

I reboot my VM with my new ipxe.lkrn ISO:

------------------------------------------------------------------------------
ISOLINUX 6.03 20171017 ETCD Copyright © 1994-2014 H. Peter Anvin et al
iPXE ISO boot image
Loading ipxe.krn... ok
Loading initrd.ipxe...ok
IMAGE embedded.ipxe at [bfcef349,bfcef368) registered
IMAGE embedded.ipxe is not Multiboot: Exec format error (http://ipxe.org/2eB3ti0a1)
IMAGE embedded.ipxe is not ELF: Exec format error (http://ipxe.org/2e868001)
IMAGE embedded.ipxe is script
IMAGE background.png at [bfcef368,bfdcd809) registered
IMAGE background.png is not Multiboot: Exec format error (http://ipxe.org/2e838001)
IMAGE background.png is not ELF: Exec format error (http://ipxe.org/2e868001)
IMAGE background.png is not script: Exec format error (http://ipxe.org/2e028001)
IMAGE background.png is not bzImage: Exec format error (http://ipxe.org/2e818001)
IMAGE background.png is not COM32: Exec format error (http://ipxe.org/2e888001)
IMAGE background.png is not COMBOOT: Exec format error (http://ipxe.org/2e878001)
IMAGE background.png is not DER: Error 0x3e00e03b (http://ipxe.org/3e00e03b)
IMAGE background.png is not PEM: No such file or directory (http://ipxe.org/2d09803b)
IMAGE background.png is PNG
iPXE initialising devices...
IMAGE <INITRD> at (bfc4d000,bfc4e76f) registered
IMAGE <INITRD> is not Multiboot: Exec format error (http://ipxe.org/2e838001)
IMAGE <INITRD> is not ELF: Exec format error (http://ipxe.org/2e868001)
IMAGE <INITRD> is script
ok
iPXE 1.0.0. (a4f8) -- Kicker Firmware: dscoular http://ipxe.org Features: DNS HTTP HTTPS iSCSI NFS TFTP SRP AoE ELF MBOOT PXE bzImage COMBOOT Menu PXEXT
IMAGE trying to execute [embedded.ipxe].
IMAGE embedded.ipxe unregistered
Embedded.ipxe is dropping to the iPXE shel...
iPXE> imgstat
background.png : 910497 bytes [PNG]
<INITRD> : 6022 bytes [script]
------------------------------------------------------------------------------

It works! I can see that we successfully loaded the embedded.ipxe script.
ipxe then executed and unloaded the embedded.ipxe script. imgstat shows me the background.png and <INITRD> script are available.

So, all I have to do now is see if I can chain to the magical <INITRD> image name. I modify my embedded.ipxe script to:

> #!ipxe
> chain <INITRD> || goto failed
>
> :failed
> echo Failed to load script from initial RAM disk. ||
> shell

I rebuild ipxe.lkrn, rebuild my ISO and reboot... complete success.

My isolinux.cfg loads ipxe.lkrn and the initrd script, ipxe executes and loads its embedded script and background PNG, the embedded script executes and chains to my <INITRD>script, my <INITRD> script loads the background image and my menus!

Many thanks for all the help and clues to get this working.

Cheers,

Doug
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Referring to files in the initial RAM disk - dscoular@gmail.com - 2019-12-03 10:01



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