Boot from Network via PXE (Eng. Version)
–THE IDEA–
- using root_fs for i386 we have made before to be able booted from network.
- root_fs can be booted from Network with Boot From Network facility in BIOS.
- We will use PXE Technology.
–UNDERSTANDING PXE–
PXE is … you can read it at http://en.wikipedia.org/wiki/Preboot_Execution_Environment.
There are several BIOS that have been supported by PXE, but there are not. If you don’t have any BIOS that is supported by PXE, you need some standard boot device such as USB FD, CF, HARDDISK etc) and it have to be configured first with gPXE, so it can handle PXE process.
Some application we need to boot with PXE :
- DHCP
- TFTP
- SYSLINUX
- gPXE (Optional)
–How Does it work ?–
- If you set your system to boot from Network, system will send broadcast message with DHCP protocol. DHCP Server will give it an IP Address dan PXE configuration to it.
- The system will start to download the configuration files for preparing booting process via tftp.
- The system is ready to boot and ready to use.
Setting BIOS to boot from network
later the system which is booted from network will be called PXEClient
–CONFIGURE gPXE–
as we mentioned above, if you don’t have any BIOS that is supported by PXE, you need some standard boot device that is configured with gPXE.
Below we will discuss about how to use gPXE.
- Install gPXE, you can get the source from http://etherboot.org/wiki/index.php
- We will use USB FD as standard boot device, so we need to copy the gpxe.usb to our device (ex: /dev/sda1). You can find gpxe.usb file in “./bin” directory at gpxe folder.
- Copy:
- dd if=bin/gpxe.usb of=/dev/sda1
- Your USB FD is ready to use.
–CONFIGURE DHCP–
We need DHCP Server to assign IP Address and send early configuration file to our PXEClient. We can adjust our dhcp configuration in /etc/dhcpd.conf.
DHCP Configuration:
Assume:
- IP Address PXEClient : 192.168.0.254/24
- MACAddress : 00:0D:48:36:0C:E4
- DHCP Server : 192.168.0.1/24
- TFTP Server : 192.168.0.1/24
- Konfigurasi file : pxelinux.0
File dhcpd.conf:
allow booting; allow bootp; # Standard configuration directives... subnet 192.168.0.0 netmask 255.255.255.0 { option domain-name "mydomain"; option subnet-mask 255.255.255.0; option broadcast-address 192.168.0.255; option domain-name-servers 192.168.0.1; option routers 192.168.0.1; # Group the PXE bootable hosts together group { # PXE-specific configuration directives... option dhcp-class-identifier "PXEClient"; next-server 192.168.0.1; filename "/pxelinux.0"; # You need an entry like this for every host # unless you're using dynamic addresses host hostname { hardware ethernet 00:0D:48:36:0C:E4; fixed-address 192.168.0.254; } }
–CONFIGURE TFTP–
We use TFTP as transfer file protocol to download neede files.
- install tftp,
- you should check the default directory of downloadable file via tftp (/var/lib/tftpboot)
- Activate tftp via inetd
–CONFIGURE SYSLINUX–
Syslinux is a Linux Operating System boot loader which operates off an MS-DOS/Windows FAT Filesystem. You can check with “man syslinux”.
Intended to boot with PXE we need PXELINUX as a derivatif of syslinux.
Files needed to boot with pxe:
- pxelinux.0
we can get it from directory:
- /usr/lib/syslinux/pxelinux.0
-STEP BY STEP-
—Preparing The Files—
Please prepare the files we needed in default directory of tftp (/var/lib/tftpboot)
All of the files would be :
- /var/lib/tftpboot/pxelinux.0
- /var/lib/tftpboot/bzImage
- /var/lib/tftpboot/root_fs_i386.gz
- /var/lib/tftpboot/pxelinux.cfg/01-00-0d-48-36-0c-e4
- /var/lib/tftpboot/pxelinux.cfg/C0A800FE
- /var/lib/tftpboot/pxelinux.cfg/C0A800
- /var/lib/tftpboot/pxelinux.cfg/C0A800
- /var/lib/tftpboot/pxelinux.cfg/C0A80
- /var/lib/tftpboot/pxelinux.cfg/C0A8
- /var/lib/tftpboot/pxelinux.cfg/C0A
- /var/lib/tftpboot/pxelinux.cfg/C0
- /var/lib/tftpboot/pxelinux.cfg/C
- /var/lib/tftpboot/pxelinux.cfg/default
You can see at point 4 to 13 are how syslinux read the configuration file. I have taken the article below from http://syslinux.zytor.com/wiki/index.php/PXELINUX:
- First, it will search for the config file using the hardware type (using its ARP type code) and address, all in lower case hexadecimal with dash separators; for example, for an Ethernet (ARP type 1) with address 00:0d:48:36:0c:e4 it would search for the filename 01-00-0d-48-36-0c-e4.
- Next, it will search for the config file using its own IP address in upper case hexadecimal, e.g. 192.168.0.254 -> C0A800FE (you can use the included progam gethostip to compute the hexadecimal IP address for any host). If that file is not found, it will remove one hex digit and try again. Ultimately, it will try looking for a file named default (in lower case). As an example, if the boot file name is /mybootdir/pxelinux.0, the Ethernet MAC address is `00:0d:48:36:0c:e4` and the IP address 192.168.0.254, it will try the files above (point 4 to 13).
The Example of Configuration for boot loader at 01-00-0d-48-36-0c-e4 file name:
- prompt 1
- default linux
- timeout 1
- label linux
- kernel bzImage
- append initrd=root_fs_i386.gz root=/dev/ram0 ramdisk_size=30000 noapic acpi=off
I often use the following configuration:
Files :
- /var/lib/tftpboot/pxelinux.0
- /var/lib/tftpboot/bzImage
- /var/lib/tftpboot/root_fs_i386.gz
- /var/lib/tftpboot/pxelinux.cfg/01-00-0d-48-36-0c-e4
–Execute DHCP Server–
Start dhcp server with the following command:
- dhcpd
Or you can execute it in foreground use :
- dhcpd -d
–Execute tftp server–
Start tftp server with the following command :
- inetd
PXEClient ready to boot from Network.
Google Tech Talk
Hope this help.