Chain Booting UEFI And Legacy PXE To WDS Via CentOS

by StackCamp Team 52 views

Setting up a PXE server that can handle both legacy BIOS and UEFI clients is a fantastic way to streamline network booting in diverse environments. When you're running a CentOS 7 PXE server and aiming to integrate Windows Deployment Services (WDS), things can get a bit tricky, but don't worry, we'll break it down. This guide will walk you through the steps to chain boot from your CentOS-based PXE server to WDS for both UEFI and legacy systems. Let's dive in and get this working, guys!

Understanding the Basics

Before we get our hands dirty with configurations, let's quickly recap some fundamental concepts. PXE (Preboot Execution Environment) is a standardized environment that allows computers to boot directly from the network. This is super useful for deploying operating systems, running diagnostics, or even disk imaging. We're talking about centralizing your boot processes, which saves a ton of time and effort.

  • UEFI (Unified Extensible Firmware Interface): This is the modern successor to BIOS. It's more flexible, supports larger hard drives, and offers improved security features. UEFI booting requires specific loaders and configurations different from legacy BIOS.
  • Legacy BIOS (Basic Input/Output System): The traditional firmware interface for booting computers. It's been around for ages, but it's gradually being replaced by UEFI. Legacy BIOS booting uses the older PXE standards and requires different boot loaders.
  • WDS (Windows Deployment Services): A Microsoft technology that allows you to deploy Windows operating systems over the network. It's a powerful tool for managing Windows installations in an enterprise environment.
  • Chain Booting: This is the process of one boot environment handing off control to another. In our case, we're chain booting from our CentOS PXE server to WDS. This is crucial for integrating WDS into an existing PXE setup.

Why Chain Boot to WDS?

So, why bother chain booting to WDS? Well, imagine you have a mixed environment with both Linux and Windows machines. Instead of maintaining separate PXE infrastructures, you can use a single CentOS PXE server to manage the initial boot process for everything. Then, for Windows deployments, you hand off control to WDS. It's efficient, simplifies management, and reduces overhead. Plus, it's a cool way to show off your network ninja skills!

Setting Up Your CentOS PXE Server

First things first, let's ensure your CentOS PXE server is up and running. I'll assume you have a basic PXE server configured. If not, there are tons of great guides out there to get you started. We need to make sure it can handle both UEFI and legacy BIOS clients.

Install Required Packages

Make sure you have the necessary packages installed on your CentOS server. We'll need tftp-server, dhcp, syslinux, and grub2-efi. Open your terminal and run:

sudo yum install -y tftp-server dhcp syslinux grub2-efi

Configure DHCP

DHCP (Dynamic Host Configuration Protocol) is essential for PXE booting. It provides IP addresses and boot file information to the clients. Let’s configure your dhcpd.conf file. Usually, it’s located at /etc/dhcp/dhcpd.conf.

  1. Backup your existing configuration:

sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup

2.  **Edit the DHCP configuration file:**

    ```bash
sudo vi /etc/dhcp/dhcpd.conf

Add the following configuration, adjusting the IP ranges and server addresses to match your network:

option domain-name "yourdomain.com";
option domain-name-servers 8.8.8.8, 8.8.4.4;

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option routers 192.168.1.1;

  # Legacy BIOS PXE
  if exists user-class and ( option user-class = "PXEClient:Arch:00000" ) {
    filename "pxelinux.0";
  }

  # UEFI PXE 32 bit
  elsif exists user-class and ( option user-class = "PXEClient:Arch:00006" ) {
    filename "efi/bootia32.efi";
  }

  # UEFI PXE 64 bit
  elsif exists user-class and ( option user-class = "PXEClient:Arch:00007" ) {
    filename "efi/bootx64.efi";
  }

  # WDS Fallback
  next-server 192.168.1.10; # Your WDS server IP
  filename "bootmgfw.efi"; # Or bootmgr.exe for legacy
}

Key points here:

  • We define different filenames based on the client's architecture. This is crucial for supporting both legacy and UEFI clients.
  • The next-server option tells the client the IP address of the WDS server.
  • filename specifies the boot file to load. For UEFI, we use bootmgfw.efi, which is the Windows Boot Manager. For legacy, you might use bootmgr.exe.
  1. Restart the DHCP service:

sudo systemctl restart dhcpd


### Configure TFTP

TFTP (Trivial File Transfer Protocol) is used to transfer the boot files to the client. Let's set it up.

1.  **Enable and start the TFTP service:**

    ```bash
sudo systemctl enable tftp-server
sudo systemctl start tftp-server
  1. Configure the TFTP server:

    Edit /etc/xinetd.d/tftp and ensure it looks something like this:

    service tftp
    {
      socket_type        = dgram
      protocol           = udp
      wait               = yes
      user               = root
      server             = /usr/sbin/in.tftpd
      server_args        = -s /var/lib/tftpboot
      disable            = no
    }
    
    • Make sure disable = no.
    • /var/lib/tftpboot is the default TFTP root directory. You might need to create it if it doesn't exist.
  2. Restart the xinetd service:

sudo systemctl restart xinetd


### Set Up Boot Files

Now, let's populate the TFTP directory with the necessary boot files.

1.  **Create the TFTP root directory (if it doesn't exist):**

    ```bash
sudo mkdir -p /var/lib/tftpboot
  1. Copy Syslinux files for legacy BIOS:

sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ sudo cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/ sudo cp /usr/share/syslinux/memtest86+/memtest.efi /var/lib/tftpboot/ sudo cp /usr/share/syslinux/ldlinux.c32 /var/lib/tftpboot/

3.  **Create the `pxelinux.cfg` directory:**

    ```bash
sudo mkdir /var/lib/tftpboot/pxelinux.cfg
  1. Create a default PXE configuration file:

    Create /var/lib/tftpboot/pxelinux.cfg/default and add the following:

    DEFAULT menu.c32
    TIMEOUT 300
    
    MENU TITLE PXE Boot Menu
    
    LABEL wds
        MENU LABEL Boot to WDS
        KERNEL chain.c32
        APPEND tftp://192.168.1.10/bootmgfw.efi # Or bootmgr.exe for legacy
    
    LABEL local
        MENU LABEL Boot from Local Drive
        LOCALBOOT 0
    
    • Adjust the IP address to match your WDS server.
    • chain.c32 is a Syslinux module that allows chain loading.
  2. Create the EFI directory structure and copy EFI bootloaders:

sudo mkdir -p /var/lib/tftpboot/efi sudo mkdir -p /var/lib/tftpboot/efi/boot

sudo cp /boot/efi/EFI/centos/grubx64.efi /var/lib/tftpboot/efi/boot/bootx64.efi

sudo cp /boot/efi/EFI/centos/grubia32.efi /var/lib/tftpboot/efi/boot/bootia32.efi

#Copy WDS bootmgfw.efi sudo cp /mnt/wdsboot/bootmgfw.efi /var/lib/tftpboot/


## Configuring WDS for PXE Chain Boot

On your WDS server, ensure that it is properly configured to respond to PXE requests. Here’s a quick checklist:

*   **WDS Role:** The Windows Deployment Services role should be installed and configured.
*   **DHCP Configuration:** Ensure WDS is not conflicting with your CentOS DHCP server. WDS can use its own DHCP service or integrate with an existing one, but for this setup, we're letting the CentOS DHCP server handle everything.
*   **Boot Images:** Make sure you have the necessary boot images (both x86 and x64) added to your WDS server. These are typically located in the `RemoteInstall\Boot` directory on your WDS server.
*   **Copy bootmgfw.efi:** You need to copy this file from your WDS server to the `/var/lib/tftpboot/` directory on your CentOS PXE server. This allows the PXE server to hand off to WDS for UEFI clients.

    ```bash
    #Mount WDS boot image
mount -o loop /path/to/your/boot.wim /mnt/wdsboot

    #Copy file to tftpboot
    cp /mnt/wdsboot/EFI/Microsoft/Boot/bootmgfw.efi /var/lib/tftpboot/

    #Unmount boot image
umount /mnt/wdsboot
    ```

## Testing the Setup

Time to put our work to the test! Here’s how to test both UEFI and legacy PXE booting to WDS.

1.  **Legacy BIOS Boot:**
    *   Boot a legacy BIOS client machine via PXE.
    *   You should see the PXELinux menu.
    *   Select the