by MichaelF on September 01, 2006 07:19pm

(Special thanks to Dan Simonton & Kyle Adams for the testing and writing of this tech tip)
Have you ever stood in front of a server you are building, feeding it install cds, and thought to yourself “it just doesn’t get any better than this…?”
Me neither.

But look at the bright side: That growing collection of CDRS that are now spilling over the top of the spindle will make an excellent conversation piece when you have guests in your facility. It also makes for an interesting makeshift “jenga” type game. Ok, maybe not. The point is, there are alternatives.

After a growing frustration with having to burn new install discs every time one got a scratch in the wrong place, misplaced, or needing them while they were currently in use, some of the other penguins and I said, “STOP THE INSANITY!!”, and then endeavored to build ourselves a PXE boot server for our lab so we could install our machines on the fly. We anticipate this being a major time saver in the future.

If you live in an IT cave or for some other reason are unfamiliar with PXE boot systems, the acronym itself stands for “Preboot Execution Environment”. It is a boot option that is built into the firmware of the bios on most modern network interface cards. Essentially it is a coupling of dhcp(bootp) and tftp. Basically, a dhcp request is sent out from the client machine, it receives an ip address and a file with instructions to complete the transaction. From here, the install process is initiated. That’s the short version. If you want the long version, look here:

We set ours up on a machine with a dhcp server, tftp server, and an apache web server. It is possible to setup the PXE system, adding it to the configuration of an existing, authoritative dhcp server, but for the sake of simplicity, we kept ours on a separate machine running RHEL4 AS. If an authoritative DHCP server already exists on the network, it is important that the following option be applied to it’s configuration under the subnet specification:

          ignore bootp;

This ensures it will not attempt to answer requests by the PXE client. Otherwise, any PXE installation you attempt may not make it very far.

On the PXE dhcp server, you will want to setup with the following options

          not authoritative;
            allow bootp;

subnet netmask {
        range dynamic-bootp;
        max-lease-time 3600;
        default-lease-time 3600;
        option routers;
        option subnetmask;
        filename "pxelinux.0";

We kept the lease time at 1 hour. Once the install is complete (which should only take a third of that time), it won’t need it anymore, so we figured this was sufficient. It is important to note the “not authoritative” option at the top, as this will prevent unintended machines from leasing non-routable ip addresses from the machine.

We then mounted the FC5 iso images on a loopback and copied all of the files over to a directory we created called FC5, under /tftpboot.

          mkdir /tmp/FC5
          mount –o loop FC-5-i386-disc1.iso /tmp/FC5
            cp –r /tmp/FC5/* /tftpboot/FC5

We repeated this process for disc 2-5.

In our /etc/httpd/conf/httpd.conf file, we’ve added the following directory options.

          <Directory /tftpboot/FC5>
  Options Indexes
  AllowOverride None
  Alias /linux /tftpboot/FC5

As the directory specification “FC5” might suggest, we’re using this to install Fedora Core 5 from the PXE server. This specification within the httpd.conf gives Anaconda access to the necessary files to install FC5 via http.

It’s worthy of mention that you can choose to do this for as many operating systems as you wish to install.  We primarily run RHEL4 and Fedora Core 5 systems for the sake of uniformity, so we’ll use RHEL4 in this example. Next we copied  initrd.img and vmlinuz files from both /tftpboot/FC5/isolinux and /tftpboot/RHEL4/isolinux into the upper /tftpboot directory and renamed them according to distribution (rhel4-initrd.img and rhel4-vmlinuz for example).
Next we have to setup the tftp server. If the file does not exist under /etc/xinetd.d, it will need to be created (but most likely, it’s already there). It should have the following options specified:

          service tftp
                        socket_type             = dgram
                        protocol                = udp
                        wait                    = yes
                        user                    = root
                        server                  = /usr/sbin/in.tftpd
                        server_args             = -s /tftpboot
                        disable                 = no
                        per_source              = 11
                        cps                     = 100 2
                        flags                   = IPv4

Next, create the directory /tftpboot/pxelinux.cfg and make it world-readable. Inside this directory, we need to create eight zero-byte files which represent (use the “touch” command).

touch C
touch C0
touch C0A
touch C0A8
touch C0A80
touch C0A800
touch C0A800F
touch C0A800FE

and lastly, a 9th file for the MAC address, with 01 pre-pended to the beginning

            touch 01-AA-BB-CC-DD-EE-FF

The AA-BB-CC-DD-EE-FF portion of course, replaced with the actual mac address of the interface you will be using.  If you do not have this information, it can be obtained via:

          $ ifconfig

            eth0      Link encap:Ethernet  HWaddr
inet addr:  Bcast:  Mask:

Next we create a file called “default” with the following added to it:

          prompt 1
default linux-fc5 ks=
timeout 100
label linux-fc5
kernel vmlinuz-fc5
append initrd=initrd-fc5.img ramdisk_size=9216 noapic acpi=off
label linux-rhel4
kernel vmlinuz-rhel4
append initrd=initrd-rhel4.img ramdisk_size=9216 noacpi acpi=off

The options are pretty much the same as you would see in a grub configuration. You can add kickstart file options here if you wish, as noted above. With this configuration, once we reach the PXE linux boot prompt, we can specify either the linux-fc5 or linux-rhel4 to begin the install. If you wish to use a kickstart file, simply specify the location next to the kernel option. As you can see, in our example, it is being taken from an http connection on a different machine. One final step, copy /usr/syslinux/pxelinux.0 into your /tftpboot directory and you should be ready to go.

The final step in the process would be to actually perform an install. On the machine intended for this, go into your bios and place PXE/Network boot in the order before harddrive (if there is an OS present on the machine already). Alternatively, if there is a key-press option (such as f12) on post, you could do that as well. You should see the dhcp client address request progress on screen. Once the address has been obtained, you will see the files specified under /tftpboot/pxelinux.cfg directory load and will get a “boot:” prompt. At this point, specify the label of the kernel you wish to boot (these were defined in your /tftpboot/pxelinux.cfg/default file).  The install process should now begin.

That’s all there is to it.