Centos 5.4 PXE Boot

Quick Intro

Some time ago I setup a PXE boot server at work so we could deploy different operating systems to our servers and computers quickly. I'm lazy like that. We use it to deploy Centos 5.3, Centos 4.4, and a few different versions of the Mirth Appliances. Here's how I added Centos 5.4 to our existing PXE boot environment.

A normal DVD installation might take 20 - 60 minutes, while a network installation can take under 5 minutes. I say I'm lazy because I dread downloading the discs, then burning them --or looking for a set that I might have burned months ago-- then actually popping the CD in, making sure the system boots from it, then go through the tedious process of selecting packages, settings, partitions etc; yes I hate doing this when its so repetitive. When you do this 10 - 30 times a month, it gets old.

The writeup assumes you already have a PXE Boot environment setup; I don't walk you through setting that up, but if you have problems figuring out let me know if I can help you or ask questions on the comments; I'll try to get you answers. I walked thorugh this a couple of times and I tried capturing all the important information; if you find a mistake or something isn't clear please let me know so I can correct it. If you follow this, when you're finished you should be able to install CentOS 5.4 from your network without the need for CDs or DVDs. All you need is a system that can boot from the network, usually this is called PXE and its configured through your BIOS.

Requirements

  • Existing PXE Boot environment.
  • Centos 5.4 Discs. I got the DVD instead of multiple disks. Its easier if you have just one disc.
  • Enough space in your repository to hold the contents of the DVD
  • Time. You'll need time to download the discs, and walk through this guide. Depending on your ability and experience, you could be finished in about 25 minutes.

The Nitty Gritty

Mount the DVD (iso) to a location so you can copy the sources to your repository.

[08:16 AM] netboot:/tmp # mount -o loop CentOS-5.4-x86_64-bin-DVD.iso /mnt/centos54
[08:18 AM] netboot:/tmp # ls -la /mnt/centos54/
total 619
drwxr-xr-x 7 root root   6144 Oct  1  2009 ./
drwxr-xr-x 4 root root      4 May 27 12:19 ../
drwxrwxr-x 2  500  500 544768 Oct  1  2009 CentOS/
-rw-r--r-- 1 root root    118 Oct  1  2009 .discinfo
-rw-r--r-- 1 root root    212 Sep 30  2009 EULA
-rw-r--r-- 1 root root  18009 Sep 30  2009 GPL
drwxr-xr-x 4 root root   2048 Oct  1  2009 images/
drwxr-xr-x 2 root root   2048 Oct  1  2009 isolinux/
drwxr-xr-x 2 root root  16384 Sep 30  2009 NOTES/
-rw-r--r-- 1 root root    655 Sep 30  2009 RELEASE-NOTES-cs
-rw-r--r-- 1 root root   1401 Sep 30  2009 RELEASE-NOTES-cs.html
-rw-r--r-- 1 root root    839 Sep 30  2009 RELEASE-NOTES-de
-rw-r--r-- 1 root root   1571 Sep 30  2009 RELEASE-NOTES-de.html
-rw-r--r-- 1 root root    694 Sep 30  2009 RELEASE-NOTES-en
-rw-r--r-- 1 root root   1367 Sep 30  2009 RELEASE-NOTES-en.html
-rw-r--r-- 1 root root    694 Sep 30  2009 RELEASE-NOTES-en_US
-rw-r--r-- 1 root root   1367 Sep 30  2009 RELEASE-NOTES-en_US.html
-rw-r--r-- 1 root root    788 Sep 30  2009 RELEASE-NOTES-es
-rw-r--r-- 1 root root   1619 Sep 30  2009 RELEASE-NOTES-es.html
-rw-r--r-- 1 root root    852 Sep 30  2009 RELEASE-NOTES-fr
-rw-r--r-- 1 root root   1641 Sep 30  2009 RELEASE-NOTES-fr.html
-rw-r--r-- 1 root root    766 Sep 30  2009 RELEASE-NOTES-ja
-rw-r--r-- 1 root root   1565 Sep 30  2009 RELEASE-NOTES-ja.html
-rw-r--r-- 1 root root    706 Sep 30  2009 RELEASE-NOTES-nl
-rw-r--r-- 1 root root   1433 Sep 30  2009 RELEASE-NOTES-nl.html
-rw-r--r-- 1 root root    752 Sep 30  2009 RELEASE-NOTES-pt_BR
-rw-r--r-- 1 root root   1480 Sep 30  2009 RELEASE-NOTES-pt_BR.html
-rw-r--r-- 1 root root    801 Sep 30  2009 RELEASE-NOTES-ro
-rw-r--r-- 1 root root   1473 Sep 30  2009 RELEASE-NOTES-ro.html
drwxr-xr-x 2 root root   2048 Oct  1  2009 repodata/
-rw-r--r-- 1 root root   1512 Sep 30  2009 RPM-GPG-KEY-beta
-rw-r--r-- 1 root root   1504 Sep 30  2009 RPM-GPG-KEY-CentOS-5
-r--r--r-- 1 root root   7048 Oct  1  2009 TRANS.TBL
-rw-r--r-- 1 root root    417 Oct  1  2009 .treeinfo

I already have other distros ready so I'll follow the structure I've set already in place. Keeps things neat and tidy.

[08:24 AM] netboot:/opt/mirthcorpnetboot/sources/linuxdistros/centos # tree -L 2
.
|-- x86
|   `-- 4.4
`-- x86_64
    |-- 5.2
    `-- 5.3

Notice the x86_64 directory, I'm going to create sub directory there for 5.4 and copy the contents of the DVD to it. I'll use my favorite tool for this, rsync.

[08:40 AM] netboot:/..../centos/x86_64 # rsync -P -rvvia /mnt/centos54/* ./5.4/
building file list ... 
3515 files to consider
....
....

After we copy the source files I no longer need the dvd.

Centos 5.4 boot options in menu.c32

To add Centos 5.4 as a boot option, we need to modify the tftpboot options and include the sources. We've done the sources part by placing them in the right location in the steps above. Please note that if you want, you could keep the sources on the DVD and just use the mount location; I prefer to have the sources available locally on the drive.

Next up, modifying the menu options when booting. Based on my setup, the files I need to work with next are at the root, under the tftpboot folder. Here's how things look:

[08:48 AM] netboot:/tftpboot # tree -L 2
.
|-- images
|   |-- centos
|   |-- live
|   |-- oralce
|   |-- ubuntu
|   `-- windows
|-- menu.c32
|-- pxelinux.0
`-- pxelinux.cfg
    |-- OLD
    `-- default

8 directories, 3 files

I need to edit the default file under the pxelinux.cfg folder. I also need to include the boot files under the proper folder in the images directory. The actual menu options are handled by menu.c32.

The file pxelinux.cfg has some settings in it, then we have each of the operating systems configured with four lines. Lets look at the one I have for CentOS 5.3

[08:50 AM] netboot:/tftpboot # head pxelinux.cfg/default 
default menu.c32
prompt 0
timeout 300

MENU TITLE PXE Menu
# Start of CentOS 5.3 install
LABEL CentOS 5.3 x86_64 SERVER
MENU LABEL CentOS 5.3 x86_64 Server
KERNEL images/centos/x86_64/5.3/vmlinuz 
append vga=normal initrd=images/centos/x86_64/5.3/initrd.img ramdisk_size=32768 ks=http://localhost/linuxdistros/centos/x86_64/5.3/config/appliancecfg/ks.cfg ksdevice=eth0
# End of Centos 5.3 installation 

For more information about menu.c32, refer to the official documentation.

Our new entry for CentOS 5.4 will look something like this:

LABEL CentOS 5.4 x86_64 SERVER
MENU LABEL CentOS 5.4 x86_64 Server
KERNEL images/centos/x86_64/5.4/vmlinuz 
append vga=normal initrd=images/centos/x86_64/5.4/initrd.img ramdisk_size=32768 ks=http://localhost/linuxdistros/centos/x86_64/5.4/config/appliancecfg/ks.cfg ksdevice=eth0

Notice that I've just changed the "5.3" to "5.4" everywhere, then I'm going to look at each instance where 5.4 is referenced and make sure the files that are being requested are in fact available there. Also notice that the menu entry requests a file named ks.cfg. This is a custom kickstart config file.

The LABEL lines are just that, labels. The MENU LABEL one is what will show up in our boot menu options. The first line we really have to look at is the Kernel image. We have to tell menu.c32 where to find the kernel to boot into a Centos 5.4 installation. Initially, the kernel image will be available where we left the sources after we copied them from the DVD. I found the vmlinuz file under the images/pxeboot folder.

[09:23 AM] netboot:/...../centos/x86_64/5.4/ # ls -la images/pxeboot/
total 9231
drwxr-xr-x 2 root root       6 Oct  1  2009 ./
drwxr-xr-x 4 root root      10 Oct  1  2009 ../
-rw-r--r-- 1 root root 7397850 Oct  1  2009 initrd.img
-rw-r--r-- 1 root root     265 Oct  1  2009 README
-r--r--r-- 1 root root     659 Oct  1  2009 TRANS.TBL
-rw-r--r-- 1 root root 1932284 Oct  1  2009 vmlinuz

I'm going to copy that and any other files I need into the /tftpboot/images folder under the corresponding directory. Presumably, based on my previous 5.3 pxe boot configuration, I should only need "vmlinuz" and "initrd.img". Our friendly visual utility tree should clarify things a little.

[09:27 AM] netboot:/tftpboot/images/centos # tree -L 3
.
|-- x86
|   `-- 4.4
|       |-- initrd.3ware.img
|       |-- initrd.base.img
|       |-- initrd.img
|       |-- initrd.r8168.img
|       |-- initrd.r8169.img
|       `-- vmlinuz
`-- x86_64
    |-- 5.2
    |   |-- initrd.img
    |   `-- vmlinuz
    |-- 5.3
    |   |-- initrd.img
    |   `-- vmlinuz
    `-- 5.4

6 directories, 12 files

Make sure there's a 5.4 directory ready and then copy over the two files; in our example above the directory 5.4 is there because I created it earlier, but it is empty. We'll copy over vmlinuz and initrd.img from the original sources.

[09:29 AM] netboot:/tftpboot/images/centos/x86_64/5.4 # cp /opt/mirthcorpnetboot/sources/linuxdistros/centos/x86_64/5.4/images/pxeboot/* ./
[09:29 AM] netboot:/tftpboot/images/centos/x86_64/5.4 # ls -la
total 7
drwxr-xr-x 2 root root       6 Jun  7  2010 ./
drwxr-xr-x 5 root root       5 May 27 12:16 ../
-rw-r--r-- 1 root root 7397850 Jun  7  2010 initrd.img
-rw-r--r-- 1 root root     265 Jun  7  2010 README
-r--r--r-- 1 root root     659 Jun  7  2010 TRANS.TBL
-rw-r--r-- 1 root root 1932284 Jun  7  2010 vmlinuz
[09:29 AM] netboot:/tftpboot/images/centos/x86_64/5.4 # rm -rf ./README ./TRANS.TBL

I copied everything (*) then deleted the README and TRANS.TBL files, I don't think we'll need them. This now satisifes the kernel line from our boot options.

KERNEL images/centos/x86_64/5.4/vmlinuz 

Checks and balances

Now we need to make sure the rest of the default config file is accurate. Notice that the next line calls out the initrd.img file and we've also taken care of that with the previous copy command.

Onto the actual OS sources. If you've followed my example and simply copied your previous entry in the default file, your 5.4 files should be ready to go. Since I'm using HTTP to serve the files (see entry where I call out to http://localhost....), I can simply browse to the location via my webbrowser and make sure I can see files there before I test this out.

CentOS 5.4 sources from DVD

Looking at the entries on the default file, for the menu entry I mentioned above, I talked about my custom kickstart file (ks.cfg). Kickstart files are like answer files that help you configure your installations to be more uniform by providing standardized answers to things like language options, packages, and other stuff normally presented by Anaconda. Sometimes you can also have kickstart files actually do the entire OS installation plus additional programs as I do with some of our customized installations for our appliances. In the case where you simply want a generic OS installation, you should point to the cfg file under isolinux. The line in the menu entry will then look like this:

append vga=normal initrd=images/centos/x86_64/5.4/initrd.img ramdisk_size=32768 ks=http://localhost/linuxdistros/centos/x86_64/5.4/isolinux/isolinux.cfg ksdevice=eth0

It's also worth noting that I don't really use "localhost" to serve my files over HTTP. I use the actual IP address of the server.

Closing notes

After you make changes to the /tftpboot/ files, you should restart xinetd. In some cases if you're serving HTTP you may have to restart your webserver as well. I don't have to and you shouldn't either but if you run into issues where your files aren't available via the webbrowser then you should take a look at your webserver configuration.

Following the steps I listed here, I got a generic CentOS 5.4 installation menu from PXE Boot so that I can just plug in a system to my network, choose network boot and then pick the CentOS 5.4 installation option. At this point, I'll have to go through the normal installation process as if I had inserted a DVD into the computer. Further customization and automation is possible by using a custom kickstart file instead of the built-in isolinux/isolinux.cfg file.

Similar Posts