Wednesday, July 16, 2008

How to set up a PXE-Boot Server For RHEL 4.4

Automation is a hot topic for computer systems engineers, since they usually work for large service companies to frequently set-up, upgrade and migrate operating systems.It’s a good practice to have automation techniques in a fairly small company, where you only maintain ten machines, but it turns to be a must in large systems with hundreds to thousands of machines.

In this how-to we'll shed the light on the step-by-step procedures of creating a PXE server for RHEL 4.4 AS/ES/WS.


1.4 PXE-Boot and TFTP

1.4.1 What you need

A PXE enabled machine with an RHEL 4.4 recognized network interface, RHEL 4.4, Network Switch other than the corporate network since this setup incorporates a DHCP server that may conflict with the company’s DHCP server. Network Cables, Note that you can eliminate the need for network cables and other hardware client machines, if you’re using this for a virtualized environment, VMware Desktop, Server, Infrastructure and Xen.

You need to have the following packages especially if you’re usingthe WS version:

1- system-config-netboot-0.1.40-1_EL4.i386.rpm

2- system-config-kickstart-2.5.16-2.src.rpm

These packages are for RHEL 4 32 bit, you can easily have the 64 bit version from the web, I always use www.filewatcher.com for this purpose.

The first package is mandatory for the PXE process to take place, it includes the syslinux binaries by default.

The second, is the kickstart graphical configurator, I find this utility pretty much handy perfect the automation process.

1.4.2 Prepare your installation media

The installation media should be available as an NFS, FTP or HTTP image, I prefer the HTTP one, and this is the one illustrated here.

If you have the RHEL 4 DVD, it’s not necessary that you copy it’s contents to the PXE server, you can loop mount it using the:


Mount -o loop /media/cdrecorder /any/mount/point/path/you/create

However, if you have the cd’s, you have to copy them into /any/mount/point/path/you/create let’s that it’s /local_disk/RHEL4U4:


Mount /media/cdrecorder && cp --reply=no /media/cdrecoder/* /local_disk/RHEL4U4 && eject

You repeat this step for the five cd’s using the up arrow in the keyboard.

1.4.3 Setup a static network template for the PXE server

Our PXE server will be joined into a new network, since our PXE server is also a DHCP server and we don’t want it to conflict with the corporate network, the new network address is: 192.168.0.0 , our PXE server new address would be 192.168.0.2 .

We don’t want that change to be permanent, and that’s why we’re making this template:


DEVICE=eth0

BOOTPROTO=STATIC

ONBOOT=no

TYPE=Ethernet

IPADDR=192.168.0.2

NETMASK=255.255.255.0

GATEWAY=192.168.0.1

We save it with this name: ifcfg-eth0.static at: /etc/sysconfig/network-scripts

1.4.4 Setup the web server to serve this installation directory

Apache is the default web server for RHEL. To configure apache you need to edit: /etc/httpd/conf/httpd.conf and add the following:


Options Indexes

AllowOverride None

Alias /linux /local_disk/RHEL4U4

1.4.5 Setup the DHCP server

To create a Linux DHCP server you need to place this file as: /etc/dhcp.conf


ddns-update-style interim;

#ddns-update-style ad-hoc;

#authorative;

ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

# --- default gateway

option routers 192.168.0.1;

option subnet-mask 255.255.255.0;

#option nis-domain "domain.org";

option domain-name "luqmanux.net";

# You can replace the domain-name with any thing you like. In my case it’s #luqmanux.

option domain-name-servers 192.168.0.1;

option time-offset -18000; # Eastern Standard Time

# option ntp-servers 192.168.1.1;

# option netbios-name-servers 192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

# option netbios-node-type 2;

#range dynamic-bootp 192.168.0.10 192.168.0.254;

range 192.168.0.10 192.168.0.254;

default-lease-time 3600;

max-lease-time 4800;

# we want the nameserver to appear at a fixed address

#host ns {

# next-server marvin.redhat.com;

# hardware ethernet 12:34:56:78:AB:CD;

# fixed-address 207.175.42.254;

#}

allow booting;

allow bootp;

class "pxeclients" {

match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";

next-server 192.168.0.2;

filename "pxelinux.0";

}

}

1.4.6 Setup the TFTP server

Edit the /etc/xinetd.d/tftp file to make sure that TFTP is enabled. If you’re advanced enough you can look for other options to edit.


service tftp

{

disable = no

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot

per_source = 11

cps = 100 2

flags = IPv4

}

Restart the xinetd services for your changes to take place.


Service xinetd restart

A /tftpboot directory will be created with a set of default files.

1.4.7 Setup the Syslinux PXE server

The PXE/syslinux server can be setup manually, that comes handy since it provides the power to configure any Linux distribution for the PXE process, but it’s not that easy, Red hat provides us with great tools for this all included alongside with the syslinux binaries, that package is: system-config-netboot , once installed you simply apply this command:


System-config-netboot &

The network installation and diskless environment application will launch, you just need to go to Configure, then Network installation.

The network installation and diskless environment application

Network installation global option

You then click on add. Down below, you see the network installation dialog where you set you PXE server options.

The operating system identifier is how you need this image to be called in the operating system menus at the client machine that you’re going to install, the same applies for the description, this is done for RHEL 4 the Workstation edition.

The installation protocol is of course through HTTP since we’ve already configured the Apache server to serve the installation through HTTP.

It’s recommended to configure a kick-start file, but not necessary. If you’ve already your kick-start file point to it’s location in the kick-start box. Since we’ve aliased to the installation directory with /linux in the apache configuration file, we can simply put our kick-start file there: http://192.168.0.2/linux/ks.cfg

According to our template the IP Address of our server would be: 192.168.0.2

And the location of the installation directory: /linux

Now return to the main window of the network installation application and open up the file menu the click on new.



From the dialog above, you have a very powerful utility; you can either serve the installation directory to a set of specific clients or for the whole subnet.

Here we serve our installation for the whole 255.255.255.0 subnet. And we specify which operating system we’re serving, We ask our clients to generate a kick-start file and keep it, if we don’t specify any path it’ll be kept under the default path which is the home directory for the root user. Press OK.

And you’re done configuring the PXE server.

1.4.8 Final touches

Now that you have setup all the Linux servers necessary for this operation, disconnect you PXE server from the corporate network and connect it to your switch along with the client machines, after that, you need to:

1- Load the static network template:


ifdown eth0

ifup eth0.static

Verify that the new address has been set using the ifconfig tool.

2- Start the apache web server:


Chkconfig httpd on

Service httpd start

You can test that by pointing your browser to the local host:


Firefox localhost

Or


Links localhost

3- Start the DHCP server:


service dhcpd start

1.4.9 Starting the PXE installation

Now that every thing is ok and setup, boot up the client machines, you’ll find that they are booting through TFTP and displaying a menu of the available operating systems to choose from, you choose the appropriate operating system and every thing else should run automatically if you’ve configured the kick-start file.

blog comments powered by Disqus