How to install CentOS 5.2 via a Preboot Execution Environment

An understanding of a Preboot Execution Environment (PXE) server can be helpful when installing an operating system. A systems and networking expert explains how to use a PXE server to install CentOS 5.2 remotely in this tip.

Using a Preboot Execution Environment (PXE) server to install an operating system (OS) improves the OS installation experience. We all know how tedious OS installs can be -- wouldn't it be great to do them remotely? Imagine sitting at a desk instead of swapping CDs at a server chassis somewhere inside a data center while listening to the sound of HVACs. In this article, we'll learn how to install CentOS 5.2 via PXE.

Experience with trivial file transfer protocol (TFTP), hypertext transfer protocol (HTTP) and dynamic host configuration protocol (DHCP) will come in handy for this process. Experience with a network file system (NFS) and other types of PXE systems will enhance the experience.

Pre-install setup for PXE server
PXE is a stage that a computer goes into just after booting BIOS. It's booted using a network interface. It is completely separate from any internal devices (such as a hard-disk or CD-ROM). It's like booting into a temporary OS via the network.

The client machine will need to have the BIOS set up. Ensure that the Onboard BootROM is set to Enabled and that the first boot device shows as Network. This will ensure that the system boots up and uses the onboard BootROM/Network interface to boot to the network.

To set up on the PXE server, you'll need DHCP, HTTP and TFTP. NFS is optional. Here's how PXE operates:

  1. System boots up and requests DHCP.

  2. PXE server (DHCP server) replies back negotiating an IP address between server/client.

  3. Once the IP address is settled, the DHCP server replies back with a file called pxelinux.0. That tells the server to boot a temporary kernel and driver disk in a specific directory. In our case, it will be /tftp/pxelinux.cfgYes, even though it says .cfg, it's still a directory, not a file.

  4. The system looks under /tftp/pxelinux.cfgvia the TFTP server for a file named 01-11-22-33-44-55-66 (or whatever its MAC address is).

The file's example contents are:

DEFAULT centos5.2_ x86_64_linux

LABEL centos5.2_ x86_64_linux
  kernel centos/5.2/x86_64/vmlinuz
    append initrd=centos/5.2/
      x86_64/initrd.img text ks=http://172.22.0.2/kickstart/BLAHBLAH.ks 
        headless ksdevice=auto

In this file, it tells the system to boot to the temporary kernel located at /tftp/centos/5.2/x86_64/vmlinuzand the driver disk located at /tftp/centos/5.2/x86_64/initrd.img

The PXE server also communicates that it wants to install CentOS via text mode (no graphics). Graphics tend to use more RAM, which slows down the installation process. It tells the system where the kickstart file is going to be. The kickstart file tells Anaconda's or Red Hat's or CentOS's installer what to install and which partitions to set up. Next, you must configure the DHCP server. Here's an example of a DHCP server configuration:

The kickstart file tells Anaconda's or Red Hat's or CentOS's installer what to install and which partitions to set up.


,

subnet 172.22.0.0 netmask 255.255.255.0 {
 range 172.22.0.50 172.22.0.254;
 next-server 172.22.0.2;
 filename "pxelinux.0";}

This DHCP configuration allows subnets 172.22.0.50 to 172.22.0.254 to be given to clients. It also directs the clients to the file pxelinux.0, as previously stated.

Earlier, I showed you that the bootloader file directs the Anaconda installer to a kickstart file. This file directs the installer through a series of questions. Here is an example of a kickstart file, followed by an explanation:

text
### Installation Language
lang en_US
### Installed Languages
langsupport --default en_US
keyboard us

network --gateway=192.168.1.1 --hostname=yourhost.yourdomain.com
network --device=eth0 --bootproto=static --ip=192.168.1.100 
   --netmask=255.255.255.0

nfs --server 172.22.0.2 --dir / centos/5.2/os/x86_64

zerombr yes
clearpart --all
autopart

install
firewall --enabled --ssh
selinux --disabled
firstboot --disable
timezone US/Central
skipx
rootpw swordfish
bootloader --location=mbr
reboot

%packages --resolvedeps
@ Administration Tools
@ Development Libraries
@ Development Tools
@ Editors
@ System Tools
@ Text-based Internet
  • Instructs the client to install using "text" mode.
  • Install in English (U.S.).
  • The network lines simply configure the interface(s) for the IP information. Erasing both of those lines will enable DHCP by default.
  • The NFS line tells the system to install from an NFS mount, which I'll address later in this tip.
  • It also tells it to install by clearing all master boot records (zerombr yes), to clear all partitions currently existing on the hard-disk (clearpart –all) and to install using the default partitioning scheme (autopart).
  • It tells the installer to install iptables (firewall) but to enable SSH.
  • Disable SELinux, and set the time zone to its proper place.
  • Then set the "rootpw" line to whatever you'd like. I used swordfish.
  • Everything past the %packages –resolvedeps line tells the system which specific packages to install.

Now, let's go back to the NFS option I mentioned earlier. This line simply represents how the installer will obtain the CentOS media -- whether it's from an NFS mount, a CentOS mirror, a CD or an FTP server. In order to utilize an NFS mount, you can use the line in the kickstart example above. However, if you don't have the experience to properly set up an NFS daemon/server, then I strongly suggest that you use a Red Hat/CentOS media mirror and simply replace the line nfs --server 172.22.0.2 --dir / centos/5.2/os/x86_64 with url –url http://mirrors.kernel.org/centos/5.2/os/x86_64/

Installing CentOS 5.2
Once you have ensured that the BIOS isset up, DHCP is configured, TFTP is sharing the /tftp/pxelinux.cfg directory and that HTTP is configured to hand out the kickstart file, then you should be able to reboot the machine and watch the install process.

While the installation runs, you can use two tty's (terminal windows) to make sure everything is going according to plan. To view them, hold down ALT and hit F1 or F3.

TTY3 (ALT+F3) will show more back-end things going on, such as "parsing kickstart." TTY1 (ALT+F1), on the other hand, will feed you more eye candy and give you status bars.

Was this tip helpful? Email the editors and let them know what you think.

ABOUT THE AUTHOR: Austin Jorden is a systems and network administrator for a large wireless Internet service provider located in Dallas, Texas. He has a genuine love for Linux, networking and wireless technologies.

This was first published in January 2009
This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataCenter

SearchServerVirtualization

SearchCloudComputing

SearchEnterpriseDesktop

Close