Tuesday, July 6, 2010

PXE(Preboot eXecution Environment) Installation and Configuration

Red Hat Enterprise Linux supports network installation using the NFS, FTP, or HTTP protocols. A network installation can be started from a boot CD-ROM or Red Hat Enterprise Linux CD #1, a bootable flash memory drive. Alternatively, Pre-Execution Environment (PXE) can also be used to install RHEL, if the system to be installed contains a network interface card (NIC) with Pre-Execution Environment (PXE) support.

How PXE works:

The client's NIC with PXE support sends out a broadcast request for DHCP information and the DHCP server provides the client with an IP address, name server information, the hostname or IP address of the tftp server and the location of the installation files on the tftp server.

Basic steps required for preparation of PXE server

  1. Configure the network (either NFS or FTP or  HTTP) server to export the installation tree.
  2. Configure the files on the tftp server necessary for PXE booting.
  3. Configure DHCP.

Note:---
  • We can configure our nfs or ftp or http installation server to pxe installation server.
  • Here we will use ftp server for our pxe installation server.

configuring vsftpd for PXE

Setting up vsftpd for basic use require just two steps. Installation of vsftpd rpm and starting the vsftpd service. We also need to chkconfig vsftpd so that vsftpd starts automatically when system reboots.

Step 1:
install vsftpd, if is not installed.

Step 2:
Starting vsftpd service as:

service vsftpd start
chkconfig --level 345 vsftpd on
Our next step is to copy all the CDs on to /var/ftp/pub/

PXE Installation - Copying CDs to /var/ftp/pub

Copying CDs to /var/ftp/pub

 /var/ftp/pub directory path is automatically created when we install vsftpd rpm. So, now we need to copy all the cds in /var/ftp/pub/rhel5.3

There are various steps to copy RPMs in /var/ftp/pub/rhel5.3.
1) if I have iso images of the cds
2) if X server is not running and cd fails to automount.

here I will explain, how to work at CLI mode in all the three conditions.

I have iso images of the CDs

Step 1:
move to /media/ directory and create directory iso-1, iso-2, iso- 3, iso-4, and iso-5 as

cd /media
mkdir iso-1 iso-2 iso- 3 iso-4 iso-5 
Step 2:
All the iso images are present on one DVD. if your DVD fails to mount automatically, you first need to mount your DVD. I assume that the DVD fail to mount. First I will make directory named dvd  in /media/ and will move into it as:
mkdir /media/dvd
mount /dev/hdc /media/dvd
cd /media/dvd
 
Note:
If you are not sure if the your device is hdc type mount /dev/h and press Tab, you will get the clue.
This directory /media/dvd will contain all the 5 ISOs. Now you need to mount all the respective iso images which are present on one dvd, into their respective directories as:
mount -o loop rhel-server-5.3-i386-disc1.iso /media/iso-1/
mount -o loop rhel-server-5.3-i386-disc2.iso /media/iso-2/
mount -o loop rhel-server-5.3-i386-disc3.iso /media/iso-3/
mount -o loop rhel-server-5.3-i386-disc4.iso /media/iso-4/
mount -o loop rhel-server-5.3-i386-disc5.iso /media/iso-5/
Here rhel-server-5.3-i386-disc<>.iso represents the name of my iso files.

At this point iso-1, iso-2, iso- 3, iso-4, iso-5 will contain data of respective CDs.
Step 3:
Copy all the RHEL-5 cd as:
cp -rvf /media/iso-1/* /var/ftp/pub/rhel5.3/
cp -rvf /media/iso-2/* /var/ftp/pub/rhel5.3/
cp -rvf /media/iso-3/* /var/ftp/pub/rhel5.3/
cp -rvf /media/iso-4/* /var/ftp/pub/rhel5.3/
cp -rvf /media/iso-5/* /var/ftp/pub/rhel5.3/
step 4:
You also need to copy the following two files from iso-1 as:
cp -rvf /media/iso-1/.diskinfo /var/ftp/pub/rhel5.3/
cp -rvf /media/iso-1/.treeinfo /var/ftp/pub/rhel5.3/

At this stage all the CDs are being dumped on to /var/ft/pub/rhel5.3/ directory.
 

X server is not running and cd fails to automount

Step 1:
Create a directory named rom in /media, where you will mount all the CDs one by one.

mkdir /media/rom
mount /dev/hdc /media/rhel5.3

Step 2:

Insert the CD1 in the CD-ROM and execute the following command:
mount /dev/hdc /media/rom
cp -ivf /media/rhel5.3/ /var/ftp/pub/
eject
Repeat step 2 for all the remaining 4 CDs.

At this stage all the CDs are being dumped on to /var/ft/pub/rhel5.3/ directory.

Our next step is to install and configure our tftp-server.

tftp Server Configuration:
  Step 1:
You need to install tftp, as it is not installed when you install your Linux box with "Customize Later" option selected. On  RHEL5 it is present on CD-2 or CD-3 depending upon the version of RHEL5 you are using:

tftp-server-0.42-3.1.i386.rpm
 
NOTE:
tftp-server is a xinetd dependent, if xinetd is not installed, you need to install xinetd rpm (which is present on CD-2) before can can successfully install tftp-server.
Step 2:
tftp is an xinetd based service, and requires to be started manually as:
chkconfig --level 345 tftp on

Our next step is to install and configure dhcp Server.

DHCP Server Configuration:

DHCP (Dynamic Host Configuration Protocol), is a network protocol for automatically assigning TCP/IP information to client machines, which includes, IP address, gateway, and DNS Server information.

You need to install dhcp rpm, as it is not installed, when you install you system by selecting the option "Customize Later".

Configuration File:

By default the dhcpd.conf file is not present in /etc/. The sample file is present at /usr/share/doc/dhcp/dhcp.conf.sample which can be copied to /etc/ for use.

/etc/dhcpd.conf                ;main configuration file

/var/lib/dhcp/dhcpd.leases     ;store the client lease database
 

Server Side configuration:

 dhcpd.conf should be something like the given file:

[root@server2 pxelinux.cfg]# cat /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;

allow booting;
allow bootp;
class "pxeclients" {
      match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
      next-server 192.168.1.12;
      filename "linux-install/pxelinux.0";
}

subnet 192.168.1.0 netmask 255.255.255.0 {

# --- default gateway
      option routers            192.168.1.1;
      option subnet-mask        255.255.255.0;

     range dynamic-bootp 192.168.1.10 192.168.1.200; #assign IP address from the range
      default-lease-time 21600;                        #seconds till expire
      max-lease-time 43200;                            #maximum lease time
}

where 192.168.1.12 is my PXE server's IP address.

# service dhcpd restart

#chkconfig dhcpd on

The next step is to configure PXE boot configuration, so that tftp-server can serve client requests. This configuration can be done either through GUI tool system-config-netboot or through CLI using pxeos command.

  • system-config-netboot is available if system-config-netboot-0.1.45.1-1.el5.noarch.rpm is installed.
  • pxeos and pxeboot commands are available if system-config-netboot-cmd-0.1.45.1-1.el5.noarch.rpm is installed.
  • Both system-config-netboot-0.1.45.1-1.el5.noarch.rpm and system-config-netboot-cmd-0.1.45.1-1.el5.noarch.rpm are present on CD-2.
  • In this post I have mentioned how to use cmd tool to configure PXE boot, so, installation of system-config-netboot-0.1.45.1-1.el5.noarch.rpm is not required. Installation of system-config-netboot-cmd-0.1.45.1-1.el5.noarch.rpm will serve our purpose.

PXE Boot configuration

We need to execute the following command to configure PXE configuration as:  

# pxeos -a -i "Redhat 5.3" -p FTP -D 0 -s 192.168.1.12 -L /pub/rhel5.3/ redhat-el5.3

Where:

-a
add a new Operating System description

-i 
set short description associated with the Operating System.

-p
specify protocol used to access the Operating System

-D <1|0>
specify whether the configuration is diskless or not, zero specifies that it is not a diskless configuration

-s
specify the machine containing the Operating System

-L
specify the directory on the sever machine containing the Operating System.

Specify the unique Operating System identifier, which is used as the directory name in the /tftpboot/linux-install/directory.

 At this stage, you can boot your PXE enabled system to install redhat 5.3. But we will like to add  two more OS, CentOS 5.3 and Fedora 11, so that user can select, which one to install. For this we will have to opt the same procedure, as we opted in case of redhat 5.3. We will create two directories centos5.3 and fedora11 in /var/ftp/pub and copy the respective OS in their respective directories. Then we will execute the following command which will add these two OS in the list:

pxeos -a -i "centOS 5.3" -p FTP -D 0 -s 192.168.1.100 -L /pub/centos5.3/ centos5.3
pxeos -a -i "Fedora 11" -p FTP -D 0 -s 192.168.1.100 -L /pub/fedora11/ fedora11
 
At this stage our pxe server is ready to server any pxe clients. Now we can install Linux on any machine which supports pxe booting. You need to connect your PXE Server and client though a network cable. 

 
 
The available OS will be displayed as shown above. You will have to press1, 2 or 3 depending upon what you want to select.
Note :-
pxeos -l command can be used on the PXE Server to see the list of OS configured for PXE installation.
pxeos -d can be used to delete the OS entry from the list.

Integrate Jenkins with Azure Key Vault

Jenkins has been one of the most used CI/CD tools. For every tool which we are using in our daily life, it becomes really challenges when ...