Pages

Monday 8 April 2013

Configuring PXE Boot server on RHEL 6/CentOS 6



                
Step 1: First Set the static IP address

     #vim /etc/sysconfig/network-scripts/ifcfg-eth0
     BOOTPROTO=static
     IPADDR=192.168.0.254
     NETMASK=255.255.255.0
     GATEWAY=192.168.0.254
     DNS1=192.168.0.254

:wq (save and exit)

     Now Restart the network service

     #service network restart
     #chkconfig network on

Step 2: Insert the RHEL 6 dvd into DVD ROM and mount it. 

#mount /dev/sr0 /mnt/

Now you need to configure YUM server to install packages, so use the following step to configure YUM server. for more information about package management, please visit my previous blog.

#cd /mnt/Packages/
#rpm -ivh vsftpd<tab>
#rpm -ivh deltarpm<tab>
#rpm -ivh python-deltarpm<tab>
#rpm -ivh createrepo<tab>

Note-: deltarpm, python-deltarpm both are dependencies of createrepo package.

Now copy entire RHEL 6 dvd into /var/ftp/pub/rhel6/dvd

Note-: before copying RHEL 6 DVD, first insure that, you have enough disk space in /var/ftp/pub or not.

#mkdir -p /var/ftp/pub/rhel6/dvd
#cp -rvf /mnt/* /var/ftp/pub/rhel6/dvd
Now create a repo file for yum server
#cd /etc/yum.repos.d/
#rm -rf *
#vim yum.repo
[server]
name=PXE server
baseurl=file:///var/ftp/pub/rhel6/dvd
enabled=1
gpgcheck=0

:wq (save and exit)

Now Create local repository for YUM server

#createrepo -v /var/ftp/pub/rhel6/dvd

Setp 3: Now install httpd, and kickstart, packages using yum server

#yum install httpd system-config-kickstart -y

Now create a soft link of /var/ftp/pub/ into /var/www/html/ directory, so that you can access this repository and installation tree using FTP and HTTP protocol.

#ln -s /var/ftp/pub/ /var/www/html/

Now fix your SELinux security context by using "restorecon" command

#restorecon -R /var/www/html/
#restorecon -R /var/ftp/pub/

Now restart your services of "vsftpd" and "httpd"

#service vsftpd restart
#chkconfig vsftpd on
#service httpd restart
#chkconfig httpd on

Step 4: Now create a kickstart file for unattend installation for RHEL 6 and save into /var/ftp/pub/ with the name of workstation.cfg

Step 5: Now install syslinux, xinetd, tftp-server, dhcp using yum

#yum install syslinux xinetd tftp-server dhcp -y

Now create a "pxelinux.cfg" directory in /var/lib/tftpboot/ directory

#mkdir /var/lib/tftpboot/pxelinux.cfg
 
Now copy "pxelinux.0" file from /usr/share/syslinux/pxelinux.0 to /var/lib/tftpboot/ directory

#cp  /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
 
Now enable your tftp server, because default is disable. and start the tftp server. 

#vim /etc/xinetd.d/tftp
Disable=no
#service xinetd restart
chkconfig xinetd on
 
Step 6: Configure DHCP 
 
First copy the dhcpd.conf.sample file into /etc/dhcp/dhcpd.conf

#cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
 
Now Edit dhcpd.conf file according to your network
#vim /etc/dhcp/dhcpd.conf
Allow booting;
Allow bootp;
authoritative;
#This is the very basic subnet declaration.

subnet 192.168.0.0 netmask 255.255.255.0 {
       range  192.168.0.1   192.168.0.50;
       option routers      192.168.0.254;
       option domain-name  "example.com";
       option domain-name-servers 192.168.0.254;
       default-lease-time  21600;
       max-lease-time      43200;

#PXE client IP range
       range dynamic-bootp 192.168.0.51  192.168.0.100;
       filename      "pxelinux.0";
       next-server   192.168.0.254;
}
 
:wq (save and exit)
 
#service dhcpd restart
#chkconfig dhcpd on 
 
 
Step 7: Now copy the following files from RHEL 6 DVD into /var/lib/tftpboot/ directory 
 
#cd /var/ftp/pub/rhel6/dvd/images/pxeboot/
#cp vmlinuz  /var/lib/tftpboot/
#cp initrd.img  /var/lib/tftpboot/
#cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
 
#cd /var/ftp/pub/rhel6/dvd/isolinux/
#cp -rvf * /var/lib/tftpboot/
 
Now you need to create a boot menu 

#vim /var/lib/tftpboot/pxelinux.cfg/default
       default vesamenu.c32
       #prompt 1
       timeout 600
       display boot.msg
 
       menu background splash.jpg
       menu title Welcome to the RHEL 6 PXE Installation!
       label local
       menu label boot from ^local drive
       menu default
       localboot 0xffff
 
       label ws
       menu label Install RHEL 6 ^workstation
       kernel vmlinuz
append biosdevname=0 ksdevice=link load_ramdisk=1 initrd=initrd.img network ks=http://192.168.0.254/pub/workstation.cfg noipv6
 
:wq (save and exit )


Now boot your client machine using PXE and enjoy................!

4 comments:

  1. Sir plz describe How to Setting Up A Multi boot PXE Install Server On cennos....

    ReplyDelete
    Replies
    1. Please describe your Question ?

      Delete
    2. sir,
      I want to setup a PXE server for Multiple Linux Distributions on Centos...
      For Example ..Centos, Fedora ,Ubuntu...

      Plz help...

      Delete
  2. This comment has been removed by the author.

    ReplyDelete