Automated Installation of Red Hat Linux 7, 8 and AS 2.1 via PXE

This document discusses the automated installation of Red Hat Linux 7.2, 7.3, 8.0, and AS 2.1 via PXE.

Overview of kickstart:
An automated installation of Red Hat Linux is performed through a process called kickstart. A kickstart file is a collection of instructions and keywords that the Red Hat Linux installer, called anaconda, uses to perform an unattended install.

Often a kickstart file is created by using the program called redhat-config-kickstart or ksconfig which is used by older versions of Red Hat Linux. The installer, called anaconda, will also place a kickstart file in the /root directory once installation is complete.

A kickstart file, commonly labeled ks.cfg, may be placed in several locations so that anaconda may find it. These locations include being placed on an nfs server, ftp server, http server, floppy, cdrom, or hard drive.

This method assumes you will be using the syslinux/pxelinux server on Red Hat Linux 8.0 to allow the clients to boot to pxe.

A sample dhcpd.conf file has been included in the appendix. In this example we are assigning fixed addresses to individual clients:

	host 00080246e75d {
		hardware ethernet 00:08:02:46:e7:5d;
		fixed-address 172.48.1.253;
		# PXE-specific configuration directives - client specific section
		next-server 172.48.0.1;
		filename "pxelinux.0";
	}

After modifying /etc/dhcpd.conf, the dhcpd server must be notified of the changes. One such method is to use “service dhcpd restart”.

The tftp server should be installed and running on the pxe server. It is enabled by editing /etc/xinetd.d/tftp and changing the line disabled = yes to disabled = no. Then notify the xinetd service of the change. One such method is “service xinetd restart”.

The tftp server should be populated with the following files:

pxelinux.0 from syslinux 2.00 or later should be placed in the tftpboot directory as: /tftpboot/pxelinux.0

The linux boot files, initrd.img and vmlinuz, should be placed into /tftpboot and named appropriately. These files can be located either on a bootnet.img floppy or from CD #1 of the Red Hat Linux installation media in the directory of /images/pxeboot/. The difference is that /images/pxeboot/initrd.img contain more driver files than does the initrd.img from the bootnet.img floppy:

cp -a /mnt/floppy/initrd.img /tftpboot/rhl80-initrd.img
cp -a /mnt/floppy/vmlinuz /tftpboot/rhl80-vmlinuz

You may also populate /tftpboot with the .msg files from bootnet.img as well:

cd /mnt/floppy
for X in *.msg; do cp -a $X /tftpboot/rhl80-$X; done

syslinux.cfg (from the bootnet.img floppy) should be placed in the /tftpboot/pxelinux.cfg directory and named appropriately.

cp -a /mnt/floppy/syslinux.cfg /tftpboot/pxelinux.cfg/rhl80-syslinux.cfg

As an example we will create a soft link from the syslinux.cfg file to the ip address of our client server converted to HEX. Another acceptable soft link is to link the syslinux.cfg file to default. Our client server, 172.48.1.253, converted to hex is: AC3001FD

cd /tftpboot/pxelinux.cfg
ln -s rhl80-syslinux.cfg AC3001FD

A sample syslinux.cfg is included in the appendix. To automate the kickstart process, a rhl80-ks.cfg is created and placed on the nfs or ftp server and the syslinux.cfg is modified so that it points to the location of the rhl80-ks.cfg file. In this example the nfs and ftp server is the same as the pxe server (172.48.0.1) and will have the kickstart files stored in /var/ftp/pub/kickstart. The syslinux.cfg file is modified with the following pointer to the rhl80-ks.cfg file.

label ks
  kernel rhl80-bootnet.img-vmlinuz
  append ks=nfs:172.48.0.1:/var/ftp/pub/kickstart/rhl80-ks.cfg initrd=rhl80-bootnet.img-initrd.img lang= devfs=nomount ramdisk_size=9216 ksdevice=eth0

For the kickstart installation to be completely automated we have the installatin CD-Roms stored on the network in the form of ISO images. Red Hat Linux 7.2 and AS 2.1 cannot use ISO images so the contents of their CD-Roms will be unpacked to a directory called i386. The ISO images are located in the following directories on the nfs/ftp server (which is this example case is the same server as the pxe server):
/var/ftp/pub/rhl73
/var/ftp/pub/rhl80
And the 7.2 and AS 2.1 contents are unpacked into:
/var/ftp/pub/rhl72/i386
/var/ftp/pub/as21/i386

Note: ISO images may be mounted and following process can be performed to unpack the ISO images without the need for physical CD-Rom media:

# cd /var/ftp/pub/rhl72
# ls
enigma-i386-disc1.iso
enigma-i386-disc2.iso
enigma-SRPMS-disc1.iso
enigma-SRPMS-disc2.iso
enigma-docs.iso
MD5SUM
# mkdir i386
# for X in enigma-i386-disc*.iso; do mkdir $X.dir;
mount $X $X.dir -o loop;
(cd $X.dir && tar -cf – .)|(cd i386 && tar -xvf -);
umount $X.dir
rmdir $X.dir
done

The appendix contains a sample kickstart file. This kickstart file will work on Red Hat Linux versions 7.2 through version 9. The following line has to be modified to match the directory that contains the version of Red Hat Linux that should be installed:

#Use NFS installation media
nfs –server 172.48.0.1 –dir /var/ftp/pub/rh73

Now boot the client server to pxe to begin the kickstart installation.

Pxe is often the 4th choice in the boot order list. If no bootable media is found in the floppy, CD-Rom drive, or hard drive, then it will fall through to pxe. If the hard drive has been partitioned then it may no longer fall through to pxe even though the hard drive is not bootable. In some large cluster farms “boot to pxe” is moved to become first in the boot order, then the pxe server, through the use of soft links in the /tftpboot/pxelinux.cfg directory, controls when a new operating system is loaded or if the client is able to boot to its hard drive.

The other method for booting to pxe is often to press F12 during POST.


# Sample syslinux.cfg file from Red Hat Linux 8.0
default ks
prompt 1
timeout 20
display rhl80-bootnet.img-boot.msg
F1 rhl80-bootnet.img-boot.msg
F2 rhl80-bootnet.img-options.msg
F3 rhl80-bootnet.img-general.msg
F4 rhl80-bootnet.img-param.msg
F5 rhl80-bootnet.img-rescue.msg
F7 rhl80-bootnet.img-snake.msg
label linux
  kernel rhl80-bootnet.img-vmlinuz
  append initrd=rhl80-bootnet.img-initrd.img lang= devfs=nomount ramdisk_size=9216
label text
  kernel rhl80-bootnet.img-vmlinuz
  append initrd=rhl80-bootnet.img-initrd.img lang= text devfs=nomount ramdisk_size=9216
label expert
  kernel rhl80-bootnet.img-vmlinuz
  append expert initrd=rhl80-bootnet.img-initrd.img lang= devfs=nomount ramdisk_size=9216
label ks
  kernel rhl80-bootnet.img-vmlinuz
  append ks=nfs:172.48.0.1:/var/ftp/pub/kickstart/rhl80-ks.cfg initrd=rhl80-bootnet.img-initrd.img lang= devfs=nomount ramdisk_size=9216 ksdevice=eth0
label nofb
  kernel rhl80-bootnet.img-vmlinuz
  append initrd=rhl80-bootnet.img-initrd.img lang= devfs=nomount nofb ramdisk_size=9216
label lowres
  kernel rhl80-bootnet.img-vmlinuz
  append initrd=rhl80-bootnet.img-initrd.img lang= lowres devfs=nomount ramdisk_size=9216
# Perform a boot to local media - i.e. exit pxe
label localboot
        localboot 0
# Boot to an image file such as a boot floppy
label rhl80-bootnet.img
        kernel memdisk
        append initrd=rhl80-bootnet.img

#Sample Kickstart file generated by Kickstart Configurator
#Merged from Red Hat Linux versions: 7.2, AS 2.1, 7.3, 8.0, 9
#Change the line nfs --server 172.48.0.1 --dir /var/ftp/pub/rh73
#to reflect the correct installation directory for the OS version being installed
#Also may need to update the %packages section

#System language
lang en_US

#Language modules to install
langsupport  --default=en_US
langsupport en_US

#System keyboard
keyboard us

#System mouse
mouse --emulthree genericps/2

#System timezone
timezone --utc America/Chicago

#Root password
rootpw password

#Reboot after installation
reboot

#Use text mode install
text

#Install Red Hat Linux instead of upgrade
install

#Use NFS installation media
nfs --server 172.48.0.1 --dir /var/ftp/pub/rh73

#System bootloader configuration
bootloader --location=mbr

#Clear the Master Boot Record
zerombr yes

#Clear all partitions from the disk
clearpart --all --initlabel

#Disk partitioning information
part /boot --fstype ext3 --size 75 --asprimary
part  swap --recommended
part / --fstype ext3 --size 2700 --grow

#Use DHCP networking
network --bootproto=dhcp --device=eth0

#System authorization information
auth  --useshadow  --enablemd5

#Firewall configuration
firewall --disabled

#Do not configure the X Window System
skipx

#Package install information
%packages --resolvedeps
wget
openssh
openssh-clients
openssh-server
nfs-utils
portmap
#@Everything

%post

# Sample dhcpd.conf file from Red Hat Linux 8.0
ddns-update-style interim;
ignore client-updates;

# Upstream network  required entry for multiple networks
subnet 10.10.20.0 netmask 255.255.255.0 {
}

# Pxe Network
subnet 172.48.0.0 netmask 255.255.0.0 {

# --- default gateway
	option routers		172.48.0.1;
	option subnet-mask		255.255.0.0;

	option nis-domain		"domain.org";
	option domain-name		"domain.org";
	option domain-name-servers	172.48.0.1,10.10.20.242;

	# PXE-specific configuration directives -- global section
	# next-server 172.48.0.1;
	# filename "pxelinux.0";

	option time-offset		-21600;	# Central Standard Time
	option ntp-servers		172.48.0.1;
#	option netbios-name-servers	172.48.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 172.48.0.128 172.48.0.255;
	default-lease-time 21600;
	max-lease-time 43200;

	host 00080246e75d {
		hardware ethernet 00:08:02:46:e7:5d;
		fixed-address 172.48.1.253;
		# PXE-specific configuration directives -- client specific section
		next-server 172.48.0.1;
		filename "pxelinux.0";
	}
	host 00508bea8000 {
		hardware ethernet 00:50:8b:ea:80:00;
		fixed-address 172.48.1.254;
		# etherboot-specific configuration directives
		next-server 172.48.0.1;
		filename "etherboot.img";
	}

Leave a Comment