PXE (Preboot eXecution Environment) boot is a method that allows a computer to boot from a network interface, rather than a local storage device. Here's how it works for BIOS and EFI systems:
- The network interface card (NIC) initializes.
- The NIC broadcasts a DHCP request.
- A DHCP server responds with IP configuration and PXE boot server information.
- The client downloads a small network bootstrap program (NBP).
- The NBP downloads additional files needed to boot the OS.
- The process is similar, but uses the UEFI firmware instead of BIOS.
- The EFI boot manager checks for a bootable network card.
- If found, it runs the UEFI network stack and proceeds with PXE.
- The system downloads an EFI-compatible NBP.
- The NBP then loads the OS or boot manager.
- UEFI PXE boot supports more protocols (HTTP, iSCSI) in addition to TFTP.
- UEFI can boot directly from network-attached storage.
- UEFI PXE provides more secure boot options.
BIOS-based PXE boot with Linux:
- NIC initialization: The computer's BIOS detects the network card during POST (Power-On Self-Test). The BIOS checks if PXE is enabled for the NIC and initializes it.
- DHCP request: The NIC broadcasts a DHCPDISCOVER message on the network. This message includes PXE-specific options to indicate it's a PXE client.
- DHCP server response: A DHCP server responds with a DHCPOFFER message. This includes standard network configuration (IP address, subnet mask, gateway). It also provides PXE-specific information: IP address of the TFTP server Filename of the network bootstrap program (NBP)
- Downloading the NBP: The client uses TFTP to download the NBP from the specified server. For Linux, this is typically PXELINUX (part of the SYSLINUX project). PXELINUX is a small bootloader designed for network booting.
- Booting the OS: PXELINUX loads its configuration file (usually pxelinux.cfg/default). Based on this config, it downloads additional files: Linux kernel (e.g., vmlinuz) Initial RAM disk (initrd or initramfs) PXELINUX then boots the Linux kernel, passing any specified parameters. The kernel initializes, mounts the initrd, and continues the boot process.
EFI-based PXE boot with Linux:
- EFI boot manager initialization: The UEFI firmware initializes and runs the EFI boot manager. The boot manager checks for bootable devices, including network cards.
- UEFI network stack: If a bootable network card is found, the UEFI firmware loads its built-in network stack. This stack includes support for various protocols (IPv4, IPv6, TCP, HTTP).
- DHCP and server discovery: Similar to BIOS PXE, the system broadcasts a DHCPDISCOVER message. A DHCP server responds with network configuration and boot server info.
- Downloading the NBP: The EFI firmware downloads an EFI-compatible NBP. For Linux, this is often GRUB2 with EFI support. GRUB2 can be downloaded via TFTP or HTTP (an advantage over BIOS PXE).
- Booting the OS: GRUB2 loads its configuration file (grub.cfg). It then downloads the Linux kernel and initrd. GRUB2 can use more protocols (e.g., HTTP, iSCSI) to fetch these files. The bootloader executes the Linux kernel, passing control to it. The kernel initializes, mounts the initrd, and continues booting.
Key differences in the Linux boot process:
- Bootloader: BIOS systems typically use PXELINUX, while EFI systems often use GRUB2.
- Protocols: EFI PXE boot can use HTTP and other protocols, potentially speeding up the boot process.
- Security: UEFI Secure Boot can verify the bootloader and kernel signatures, providing enhanced security.
- Flexibility: EFI PXE boot can directly boot from network-attached storage, which isn't possible with BIOS PXE.