Wednesday, November 23, 2011

PXE Boot Server on Linux


-->

How to configure PXE Boot Server on Linux

This notes will be helpful for linux admins who frequently installs different linux os. PXE boot is one of the best option to start linux installation and for rescue of the other failed systems. We are using RHEL5 as PXE boot server.

Use IP = 192.168.1.1
Hostname = server.anup.co.in

NOTE : Here I am using the IP address 192.168.1.1 you can edit it as per your network.

1] Install syslinux & tftp-server
[root@server ~]# yum install tftp-server -y

2] Enable syslinux at boot time
[root@server ~]# vim /etc/xinetd.d/tftp
edit the line no. 14
disable = no
:wq

3] Restart service
[root@server ~]# service xinetd restart
[root@server ~]# chkconfig xientd on

4] Mount CD/DVD and copy it to rhel folder

[root@server ~]# mount /dev/cdrom /mnt
[root@server ~]# mkdir -p /var/ftp/pub/rhel
[root@server ~]# cp -rvp /mnt/* /var/ftp/pub/rhel

5] Copy the needed files from syslinux to the tftpboot directory

[root@server ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot
[root@server ~]# cp /usr/lib/syslinux/menu.c32 /tftpboot
[root@server ~]# cp /usr/lib/syslinux/mboot.c32 /tftpboot
[root@server ~]# cp /usr/lib/syslinux/chain.c32 /tftpboot

6] Create the base directory for image. Create directories for each RHEL release you supporting.

[root@server ~]# mkdir -p /tftpboot/images/rhel
[root@server ~]# cp /var/ftp/pub/rhel/images/pxeboot/vmlinuz /tftpboot/images/rhel/
[root@server ~]# cp /var/ftp/pub/rhel/images/pxeboot/initrd.img /tftpboot/images/rhel/

7] Install DHCP server.

[root@server ~]# yum install dhcp -y

8] Configure DHCP server. Add following lines to your /etc/dhcp/dhcpd.conf make suitable changes for your network.

[root@server ~]# vi /etc/dhcpd.conf

option domain-name "anup.co.in";
option domain-name-servers 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;

allow booting;
allow bootp;
next-server 192.168.1.1;
filename “/pxelinux.0”;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range dynamic-bootp 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
}
:wq

10] Start dhcp service
[root@server ~]# service dhcpd start

11] Create the directory for your PXE menus
[root@server ~]# mkdir -p /tftpboot/pxelinux.cfg

12] Sample config file
[root@server ~]# vi /tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 50

MENU TITLE ANUP PXE Menu

LABEL Red Hat Enterprise Linux 5.4
MENU LABEL RHEL 5.4
KERNEL images/rhel/vmlinuz
append vga=normal initrd=images/rhel/initrd.img ramdisk_size=32768
method=ftp://192.168.1.1/pub/rhel
:wq

Test the PXE server:
* Make changes in the BIOS settings and boot client machine from network. OR just press F12 to boot from network.

8 comments:

Anonymous said...

Great Anup D.
Successfully completed my practical.

George Jebaraj - Cloud Architect said...

Change these line
allow booting;
allow bootp;
next-server 192.168.1.1
filename “pxelinux.0”

to

allow booting;
allow bootp;
next-server 192.168.1.1;
filename “pxelinux.0”;


and


KENREL images/rhel/vmlinuz

to

KERNEL images/rhel/vmlinuz


and


cp /var/ftp/pub/rhel/images/pxeboot/vmlinux /tftpboot/images/rhel/

to

cp /var/ftp/pub/rhel/images/pxeboot/vmlinuz /tftpboot/images/rhel/


Regards
George
geje2005@gmail.com

Anup Dubbewar said...

Thanks George

Anonymous said...

Thanks anup...
can you also explain how to use kickstart file to automate installation

Unknown said...

DOne this but kernel not found

Unknown said...

Could not find kernel image: Linux that is the error after all

Unknown said...

Could not find kernel: Linux

Anup Dubbewar said...

@Unknown check kernel path in default file and make sure that kernel file (vmlinuz) is present under /tftpboot/images/rhel/