Ubuntu – How to PXE boot a UEFI client with NFS rootfs

nfspxeuefi

I'm trying to PXE boot UEFI clients. My current setup for BIOS clients uses pxelinux.0 with a pxelinux.cfg/default like this:

DEFAULT vmlinuz-3.8.0-25-generic
APPEND initrd=initrd.img-3.8.0-25-generic root=/dev/nfs nfsroot=10.17.76.1:/var/lib/tribble/ephemeral ip=dhcp ro nomodeset

But I'm struggling to do the same with UEFI, party because there are so many different approaches that can be taken, and there is so little good documentation out there.

Following this guide to PXE booting the netboot mini.iso on UEFI, I was able to PXE boot into the installer, but thus far I haven't figured out how to adapt those instructions to my use case.

So there are few things I'm after:

  1. What boot loader is recommended for PXE booting UEFI clients?

  2. Can you point me to a working example of using said boot loader to PXE boot a UEFI client whose rootfs is exported over NFS?

  3. I've seen many tutorials referencing the pxe and pxecmd grub modules, but those aren't present on Ubuntu 13.04… are they deprecated, and if so, what replaces them?

Options I'm considering:

In this sea of options, I'm hoping to find a low risk solution that will continue to be well supported by Ubuntu.

Best Answer

How to netboot using ELILO

How to get EFI to netboot?

You do not need any additional software to get EFI to start a netboot session. Any EFI machine can be configured to start a PXE/DHCP session IF it has a network adapter that has support for the UNDI/PXE protocol. Most modern cards do have such support.

To enable netbooting, you need to go into the EFI boot manager maintenance menu and 'Add a boot option'. On the screen you see the list of devices to boot from. At least one of them should be of the form:

Load File [Acpi(PNP0A03,0)/Pci(5|0)/Mac(00D0B7A6FC25)]

which represent Ethernet card (Mac address). If you don't have such option, it means that you either do not have a network adapter in your machine or it does not have the UNDI/PXE support in its option ROM.

You need to select this option and give it a logical name such as 'netboot', for instance. Next, you leave the maintenance menu and go back to the main menu. You now have a new boot menu option. If you select 'netboot' then EFI will start the PXE/DCHP discovery request and look for a server to get an IP address.

On the server side, you can use a standard DHCP server.

Netbooting using PXE

EFI has builtin support for PXE. In fact it first tries PXE and then default to DHCP when it does not find a valid PXE server.

There is a PXE server package available from Linux/ia32 however this package does not have the necessary extensions to talk to the EFI side.

There is no need for special options or compile time flags to get elilo to work with PXE instead of standard DHCP. When netbooted, elilo will automatically detect if it has been downloaded via PXE or DHCP and it will adujst how subsequent files are requested.

You need a special version of the DHCPD server developed by the Internet Software Consortium (http://www.isc.org) with a special patch to add the PXE extensions. Unfortunately as of version 3.0xx, the patch has not yet made it into the official tree. It is supposed to show up in version 3.1 of the dhcpd server.

In any case, the elilo package contains a simple example of how you can configure the /etc/dhcpd.conf file for a PXE-aware DHCP server using the extensions provided in the patch. You can look in examples/dhcpd-pxe.conf. The syntax is very different from a standard dhcpd server.

The key elements to keep in mind are the PXE layers used by elilo to request the different files:

Layer 0 : to get the name of the boot loader (elilo.efi)
Layer 1 : to get the name of the elilo config file
Layer 2 : to get the name of the kernel image

There is an IMPORTANT distinction between those layers. The first two (0,1) and requested systematically whereas the last one is used only when the configuration file is not found, i.e., what is the default kernel to boot. The actual files are STILL downloaded via TFTP. Therefore the TFTP server must also be configured (see previous section for more on this).

Getting the config file

In this mode, elilo use the PXE layer 1 to get the config file to use. Therefore this must be set on the server side. Elilo will use the following sequence when looking for a config file:

- use the name provide by the PXE server Layer 1 or

- elilo-ia64.conf/elilo-ia32.conf/elilo-x86_64 or

- elilo.conf

Sample elilo.conf file

chooser=textmenu
default=install
delay=20
prompt

message=boot-screens/elilo_menu.msg
f1=boot-screens/general.msg
f2=boot-screens/params.msg

relocatable

image=vmlinuz
    label=install
    description="Install"
    initrd=initrd.gz
    append="--"
    read-only

image=vmlinuz
    label=expert
    description="Install [Expert mode]"
    initrd=initrd.gz
    append="priority=low --"
    read-only

image=vmlinuz
    label=rescue
    description="Rescue"
    initrd=initrd.gz
    append="rescue/enable=true --"
    read-only

Another one

boot=/dev/sda1
delay=30
timeout=50
default=Gentoo
append="console=ttyS0,9600"
prompt

image=/vmlinuz
    label=Gentoo
    root=/dev/sda2
    read-only

image=/vmlinuz.old
    label=Gentoo.old
    root=/dev/sda2
    read-only

Also take a look at elilo.conf, and Managing EFI Boot Loaders for Linux: Using ELILO

Elilo stops at the first match. With PXE, elilo does not try to download a config file named after the assigned IP address as it does for DHCP because there is enough flexibility in the PXE server configuration to do this.

Getting the kernel image

When there is no config file, elilo will use the kernel name returned by PXE layer 2. If it is not specified there, then it default to 'vmlinux'.

Getting the initial ramdisk

The filename for the ramdisk MUST come from the config file. Elilo does not use a PXE layer to ask for a default name.

Getting IP address information

When elilo is netbooted, the network filesystem module initializes some elilo variables with the information it received from the DHCP server. At a minimum, it received the IP address.

The following information is stored in the variables indicated below:

assigned IP address -> %I
assigned netmask    -> %M
assigned domainname -> %D
assigned gateway    -> %G

These variables can be used to dynamically adjust the command line arguments passed to the kernel.

For more information See PXE Linux and Implementing PXE Boot

Source:HP