Wednesday, February 10, 2016

PXE Continuous Reboot using iPXE


Hi,

In this post, I will be explaining how to put a machine on PXE continuous reboot using iPXE. I am assuming that you are having the basic knowledge PXE functionality.


PXE continuous reboot works with the simple steps which I mentioned below.


1. First we will include a reboot script in PXE boot image.

2. Server boots from a pxe device and download the PXE boot image.
3. PXE boot image got executed and server will be rebooted
4. Server will reboot continuously as it follows the steps 1 to 3.

I will be using iPXE image for this task. iPXE is an extension to the PXE and it has more advantages like scripting which helps us in accomplish our task easily.


You need the below stuff to configure a iPXE server.


1. One Linux system which is having DHCP and TFTP configured.

2. IPXE ROM image and script files.

1. Configure DHCP server: 

Configuring DHCP server in linux is simple. Assign a static IP for one of the Linux system's port on which you want to configure DHCP server. 

Static IP: 172.20.10.20

Netmast: 255.255.255.0

Copy the below content to your dhcpd.conf in /etc/dhcp folder.


ddns-update-style interim;
option space ipxe;
option ipxe-encap-opts code 175 = encapsulate ipxe;
option ipxe.bus-id code 177 = string;

subnet 172.20.10.0 netmask 255.255.255.0 {

        default-lease-time 3600;
        max-lease-time 4800;
        option routers 172.20.10.20;
        option subnet-mask 255.255.255.0;
        range dynamic-bootp 172.20.10.21 172.20.10.254;
        option time-offset -8;
if not exists ipxe.bus-id {
next-server 172.20.10.20;
filename "undionly.kpxe";
}
else {
next-server 172.20.10.20;
filename "ipxe/menu.ipxe";      #Provide configuration file path
}
server-name "pxe_reboot_server";
server-identifier 172.20.10.20;
}

After editing the dhcpd.conf file, restart the dhcpd server and check for errors.

Configure IPXE:

Configure the tftp folder in the same linux server. You can get many online tutorials to configure a tftp folder so I am assuming that you have configured tftp server and make sure that tftp service is running.

I have my tftpserver share is pointing to /var/lib/tftpboot folder. Now I will place "undionly.kpxe" file directly in tftpboot folder. Now create a folder named "ipxe" in tftpboot folder and create a menu.ipxe file in "ipxe" folder.


We are having the file hierarchy as below. 

/tftpboot/undionly.kpxe
/tftpboot/ipxe/menu.ipxe

Now add the below code to menu.ipxe file.


#!ipxe

echo Server will reboot in 60 seconds
sleep 60
reboot

Now reboot the DHCP and TFTP services and check for errors. If you find any errors please leave comment explaining the error so that I can help.

Now enable PXE for the adapter and make sure to bring the PXE device up in the Boot order list to make sure that server will boot PXE first. Disable harddisk or any other boot-able device if required.  Reboot the server and you can see that server is going for continuous reboot after pxe boot.


No comments:

Post a Comment