Browsed by
分类:PXELinux

How to build ipxelinux.0

How to build ipxelinux.0

I’ve recently been asked by people using gpxelinux.0 how they can build it with the newer iPXE instead of the stagnant gPXE. ipxelinux.0 is basically iPXE with an embedded boot script that starts an embedded version of pxelinux.0.

Then install the required dependencies using your distribution’s packaging tools. Chances are high you already have everything you need installed except git.

# On Ubuntu or Debian-based systems this should work
sudo apt-get install build-essential binutils perl git nasm

Then clone the iPXE git repo as described on the iPXE download page and the SYSLINUX git repo as described on the SYSLINUX development page side-by-side.

#!/bin/sh
git clone git://git.ipxe.org/ipxe.git
git clone git://git.kernel.org/pub/scm/boot/syslinux/syslinux.git

Next up is to build pxelinux.0, which is part of syslinux, so we can embed it into iPXE:

cd syslinux
make

Verify that the file named core/pxelinux.0 exists and is approx. 26KB. Then you should change directory to the ipxe checkout and create a file named ipxelinux.ipxe with this content:

#!ipxe
dhcp
chain pxelinux.0

Finally we can build a chainloadable version of iPXE with the above script and pxelinux.0 embedded:

cd src
make bin/undionly.kkkpxe EMBED=../ipxelinux.ipxe,../../syslinux/core/pxelinux.0

The last thing to do is to install it onto your TFTP server.

sudo install -v -m 0644 -g root -o root bin/undionly.kkkpxe /srv/tftp/ipxelinux.0

If you haven’t already set up your ISC DHCP server for network booting, make sure you include this snippet in your subnet declaration. If you already have an entry for pxelinux.0 in there, you can just rename the file. The file name is not magical and can be anything you like. Calling it something.0 is just a convention.

next-server 1.2.3.4;
filename "ipxelinux.0";

You’re done!

I also want to tell you that iPXE has had a text-based menu system since March 2012, so if you’re not too invested in your PXELINUX setup, you might want to look into how things can be done without PXELINUX. Take a look at the iPXE menu documentation and my iPXE menu example that shows the menu I use in my home network.

If this made you curious, please join us on #ipxe on irc.freenode.net to learn more.

iPXE: Boot iPXE Linux kernel via PXELinux

iPXE: Boot iPXE Linux kernel via PXELinux

iPXE Linux kernel (ipxe.lkrn) may chain loaded by PXELinux:

default boot

label boot
        kernel ipxe.lkrn

Both iPXE firmware (undionly.kpxe) or iPXE kernel image (ipxe.lkrn) has same functions.  All usage of iPXE commands / scripts remain the same for both firmware and kernel.

Problem with Dell Vostro notebook

All the time I use PC with iPXE firmware (undionly.kpxe) with WinPE and SanBoot without problem.  If I boot Dell Vostro notebook with the same booting steps as PC, the WinPE or SanBoot doesn’t work at all.  The reason remain unknown.  Here are my booting steps:

Scenario A

  1. Switch on machine
  2. DHCP –> undionly.kpxe (undionly.0)
  3. Chain to load WinPE image
  4. Show blank screen after WinPE image

Scenario B

  1. Switch on machine
  2. DHCP –> undionly.kpxe (undionly.0)
  3. sanboot iSCSI target
  4. Machine hang while booting

Both scenario A and B works fine on PC but doesn’t work on Dell Vostro notebook.

I suspect the problem is related to:

  1. iPXE firmware
  2. Notebook network card’s firmware doesn’t work well with iPXE firmware.

Dell Vostro notebook work with iPXE kernel

While trying to find solution solving the mystery problem with Dell Vostro notebook, I found that iPXE kernel works.  I may load WinPE image or SanBoot a Windows ISCSI target with iPXE kernel chain loaded by PXELinux.

  1. Prepare ipxe.lkrn
    -bash-4.1$ git clone git://git.ipxe.org/ipxe.git
    -bash-4.1$ cd ipxe
    -bash-4.1$ make src/bin/ipxe.lkrn
  2. Copy src/bin/ipxe.lkrn to TFTP boot directory.
    # cp src/bin/ipxe.lkrn /var/lib/tftpboot
  3. Update dhcp configuration file: /etc/dhcp/dhcpd.conf to prevent infinite iPXE boot when ipxe.lkrn boot:
            if exists user-class and option user-class = "iPXE" {
                    filename "http://<ip-address>/boot.ipxe";
            } else {
                    filename "pxelinux.0";
            }
  4. Load ipxe.lkrn after PXELinux boot:
    # cat pxelinux.cfg/default
    default boot
    
    label boot
            kernel ipxe.lkrn
  5. iPXE kernel will query DHCP server again, DHCP will send boot.ipxe script file via HTTP to the machine:
    #!ipxe
    set 209:string pxelinux.cfg/boot
    set 210:string http://<ip-address>/
    chain ${210:string}pxelinux.0
  6. boot.ipxe will chain load pxelinux.0 with new configuration file: pxelinux.cfg/boot:
    # cat pxelinux.cfg/boot
    default menu.c32
    prompt 0
    
    LABEL boot_local
            menu label ^Boot Local System
            menu default
            localboot 0
            timeout 50
    
    LABEL boot_san
            menu label Boot ^Storage Area Network
            com32 syslinux/gpxecmd.c32
            append sanboot iscsi:<iscsi-host>::::iqn.example.com:win7
    
    LABEL WINDOWS_PE
            menu label ^Windows Preinstallation Exnvironment
            kernel windows.pe/pxeboot.0
  7. Both SanBoot and Window PE image works with Dell Vostro notebook now.