Technology Encyclopedia Home >How to boot from bootloader to network boot in Linux?

How to boot from bootloader to network boot in Linux?

To boot from a bootloader to network boot in Linux, you typically use a process called PXE (Preboot eXecution Environment). Here’s how you can set it up:

  1. Ensure Network Connectivity: Make sure the machine has network connectivity and that DHCP is configured to assign IP addresses.

  2. Configure DHCP Server: Set up a DHCP server to hand out IP addresses and direct clients to the TFTP server for boot files. The DHCP options should include:

    • Option 66: TFTP server name or IP address.
    • Option 67: Boot file name (e.g., pxelinux.0 for PXE).
  3. Set Up TFTP Server: Install and configure a TFTP server to serve the boot files. Common boot files include pxelinux.0, vmlinuz (the Linux kernel), and initrd.img (the initial RAM disk).

  4. Configure PXE Bootloader: Place the PXE bootloader (pxelinux.0) in the TFTP root directory. Configure pxelinux.cfg/default to specify the kernel and initrd files to load.

Example configuration in pxelinux.cfg/default:

DEFAULT linux
LABEL linux
  KERNEL vmlinuz
  APPEND initrd=initrd.img root=/dev/nfs nfsroot=192.168.1.1:/path/to/nfs/rootfs ip=dhcp
  1. Set Up NFS or HTTP Server: Depending on your setup, you might use NFS or HTTP to serve the root filesystem. Ensure the server is configured and accessible from the client.

  2. Boot the Client: Restart the client machine and enter the BIOS/UEFI settings to change the boot order, setting the network interface as the first boot device.

Example with Tencent Cloud:
If you are looking for a managed service to simplify this setup, consider using Tencent Cloud's CVM (Cloud Virtual Machine) service. You can easily set up a virtual machine with the necessary configurations for PXE booting. Additionally, Tencent Cloud offers Cloud Load Balancer and Cloud Storage services that can be integrated into your PXE boot setup for scalability and reliability.

By following these steps, you can configure a Linux system to boot over the network using PXE, allowing for centralized management and deployment of operating systems.