Sunday, November 2, 2014

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.

No comments:

Post a Comment