CentOS 6 Deployment Server


This post is in the category: Guides

Posts here are mostly step-by-step guides on how to replicate something I have set up in the past. Read over my About page to see how I show commands/output and read the disclaimer.


This guide is an amendment to the Ubuntu Deployment Server. This guide assumes that you have a server similar to this setup. If you need to go through that guide first, you only need to complete up to Checkpoint Two.

To clear up any potential misleading in the title, this server is powered by Ubuntu 12.04, but will have the ability to deploy CentOS 6 to PXE clients. Why? Because I did that one first. No sense in re-inventing the wheel.

Adding the CentOS Network Installer

The goal is to match the below directory structure. If you are picking up from the last guide, only the centos folder should look new to you.

/var/lib/tftpboot/
├── centos
│   ├── i386
│   │   ├── initrd.img
│   │   └── vmlinuz
│   └── x86_64
│       ├── initrd.img
│       └── vmlinuz
├── other
│   └── memtest
├── pxelinux.0
├── pxelinux.cfg
│   └── default
├── ubuntu
│   ├── amd64
│   │   ├── initrd.gz
│   │   └── linux
│   └── i386
│       ├── initrd.gz
│       └── linux
└── vesamenu.c32

For the lazy, here is what needs to be added. These commands make use of one of the many mirrors available.

[root]$ mkdir -p /var/lib/tftpboot/centos/{x86_64,i386}
[root]$ cd /var/lib/tftpboot/centos/x86_64
[root]$ wget http://mirror.anl.gov/pub/centos/6/os/x86_64/images/pxeboot/initrd.img
[root]$ wget http://mirror.anl.gov/pub/centos/6/os/x86_64/images/pxeboot/vmlinuz
[root]$ cd /var/lib/tftpboot/centos/i386
[root]$ wget http://mirror.anl.gov/pub/centos/6/os/i386/images/pxeboot/initrd.img
[root]$ wget http://mirror.anl.gov/pub/centos/6/os/i386/images/pxeboot/vmlinuz

Yes, I know I’m not being consistent with naming the 64-bit directories between CentOS and Ubuntu. I’m following the naming scheme of the respective distro mirrors.

Next we can add the menu entry.

[root]$ vim /var/lib/tftpboot/pxelinux.cfg/default

Add this:

label centos_x86_64
        menu label ^CentOS 6 x86_64
        kernel centos/x86_64/vmlinuz
        append vga=788 initrd=centos/x86_64/initrd.img 

Before we run our first test, let’s modify the PXE menu.

[root]$ vim /etc/dnsmasq.d/pxe.conf

This is no longer just an Ubuntu deployment server, so change the line entry to only OS Deployment. For review, the entire file should look like this.

# We only want this running on the interface facing the dedicated PXE network
interface=eth1

# Adding the unique domain name allows me to see that I'm in the PXE subnet
expand-hosts
domain=pxe.example.com

# PXE Subnet
dhcp-range=192.168.15.100,192.168.15.200,12h

# PXE Boot Options
pxe-service=x86PC, "Boot from local disk"
pxe-service=x86PC, "----"
pxe-service=x86PC, "----"
pxe-service=x86PC, "OS Deployment - DATA LOSS AHEAD!!", pxelinux
pxe-service=x86PC, "----"

# TFTP Configuration
enable-tftp
tftp-root=/var/lib/tftpboot

Checkpoint One

Let’s pause a moment to verify we have not made any mistakes.
  1. Connect a test computer to the deployment network, and boot it up selecting PXE boot on the client machine. The computer may give you an F-key to hit to change boot order, or refer to your BIOS documentation.
  2. Once at the PXE menu, select OS Deployment - DATA LOSS AHEAD!!
  3. Select CentOS 6 x86_64 from the menu. The CentOS installation should then kick off.

Since we have no mirror setup yet, your only option is to use the web for installation sources. You can do that if you wish, or cancel the install and move on to configuring the local mirror.

Everything pass? Great – onward!

Kickstart – Automated Installations

One of the great features of Kickstart and the Anaconda installer is that you can find a generated Kickstart file after the OS installation. There is also a GUI tool available, which is the system-config-kickstart package.

Realistically, you should create the Kickstart file on your own based on your preferences. If you would like to start with a sample file, run through an installation and take the generated file from /root/anaconda-ks.cfg.

In case you don’t have a working CentOS install yet, here is a sample file to use. Run these commands on your deployment server.

[root]$ cd /var/www/cfg
[root]$ wget http://wellsie.net/files/265/centos.cfg

Edit the file and review some areas to be changed, noted in the file comments. You need to at least set a hostname and mirror path. What? Don’t have a local mirror to use? Sit tight, that’s next. If you are anxious to run an install, you can use a remote mirror for now.

[root]$ vim /var/www/cfg/centos.cfg

Check out these resources for Kickstart options:

http://wiki.centos.org/TipsAndTricks/KickStarthttp://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-kickstart2-options.html

Local Package Mirror

Mirroring the CentOS packages are a lot simpler than using apt-mirror. We can mirror the repository with a single command, but there is a bit of setup first.

First, choose a mirror. You will need one that supports rsync. In the command below, replace mirror.example.com with the mirror you choose to use.

Next, check the directory where they are going to be saved. Remember, Ubuntu stores mirrored archives in /var/spool/apt-mirror. If you made that a large partition, you may want to stick this someplace close by. In my case, I have a large drive mounted at /var2. I have apt-mirror archives saved to /var2/spool/apt-mirror (note the ‘2’). Because of this, I am storing my CentOS archive files to the path shown in the rsync command below. This is just a long-winded statement telling you that your destination path will be different. Change accordingly.

Modify this command to fit your needs, and run the sync.

[root]$ rsync -avSHP --delete --exclude "local*" --exclude "isos" --exclude "/2*" --exclude "/3*" --exclude "/4*" --exclude "/5*" --stats --bwlimit=2048 mirror.example.com::centos/ /var2/spool/centos/

Make the mirror available over HTTP. Change /var2/spool/centos to the destination directory of the previous rsync command.

[root]$ ln -s /var/www/mirrors/centos /var2/spool/centos

Checkpoint Two

Let’s pause a moment to verify we have not made any mistakes.
  1. Connect a test computer to the deployment network, and boot it up selecting PXE boot on the client machine.
  2. Once at the PXE menu, select OS Deployment - DATA LOSS AHEAD!!
  3. Select CentOS 6 x86_64 from the menu. The CentOS installation should then kick off.
  4. When prompted for an Installation Method, select URL.
  5. Configure network settings accordingly. I disable IPv6.
  6. Type in this URL, adjusting for your hostname: http://dev-deploy/mirrors/centos/6/os/x86_64/

At this point, the installation image should load, and you should see the GUI installer. Continue through with the installation. You can choose a minimal install to go faster.

Everything pass? Great!

Conclusion

You now have a working deployment server. Where do you go from here? Start building your own customized Kickstart files, and add them to your grub boot menu. Note that these Kickstart files are served up by Apache, and the file extensions do not matter. You can surely build your Kickstart files dynamically using PHP/Python/etc. You have several options on how to build your own deployment environment. Have fun!

If you clinged closely to this guide and don’t feel comfortable venturing out on your own yet, read up on how the Grub menu works as well as dnsmasq and PXE in general. Or post a comment on where you are stuck. I will do my best to respond.

This entry was posted in Guides on by .

About Andrew Wells

I have been developing on the LAMP stack since about 2006. I run Ubuntu XFCE on my desktop and have a history of managing Ubuntu and CentOS servers. I code web applications mostly in PHP but have experience with other languages as well.

When I’m not working, I can be found working in my home lab or out snowboarding, hiking, camping, or biking depending on the season.

Leave a Reply

Your email address will not be published. Required fields are marked *