There are many tutorials online for kickstarting a linux server, but they all cover part of the whole process. I’ll attempt to cover it all here.
First off, I’ll tell you my setup. I wanted to use PXE, kickstart and a local mirror to be able to install a lot of computers simultaniously. However, to be able to do this I tested the installation in Virtualbox with a virtual machine. Both my server and client are virtual. Second I would like to say that I’m a debian minded person. However, CentOS was required for this setup, so here we go.
One of the things I encountered was a VM which did not do any DHCP. The key here was that you need to select the right network adapter for the VM. I used the network bridge adapter which was virtualised as a PCnet-Fast III. Some others might work, but this one did it for me.
On your server you will need some software packages to be installed:
yum install httpd system-config-kickstart dhcp tftp-server syslinux
It’s possible that some are already installed. system-config-kickstart installes a gui kickstart editor. When your server doesn’t have a gui it’s useless. However, if it does, it’s easier to make a kickstart file with it.
As I also wanted a local yum repository I needed to sync a remote repository. This is not really neccesary, but when using this setup in an offline environment you’ll need it. Bear in mind that a repository for a single release is about 25GB.
rsync -avrt --delete --exclude "local*" --exclude "isos" \ rsync://mirrors.rit.edu/centos/6.2 /usr/local/share/CentOS/
This is going to take a while, but while it is syncing you can continue with the other configuration tasks.
As you’ve seen I use a directory in /usr/local/share. It’s also possible to use /var/www/html as that makes it simpler for your httpd configuration. If you use the /usr/local/share path make sure that httpd is allowed access to the directories by SELinux otherwise it’ll fail stating that the directory does not exist.
You can modify the SELinux settings using chcon -R command. Make sure it’s identical to the /var/www/html directory (view SELinux configuration with ls -la –context) I found it easier to disable SELinux entirely as you’ll run into it again later. However, if you’re building a production server it might not be te best idea to disable it.
If neccessary modify your httpd config so that it points to your mirror directory:
vim /etc/httpd/conf.d/repo.conf <VirtualHost *:80> ServerName repo.localhost ServerAlias repo DocumentRoot /usr/local/share/CentOS <Directory "/usr/local/share/CentOS"> Option Indexes FollowSymlinks Order allow,deny Allow from all </Directory> </VirtualHost>
Restart your httpd service:
service httpd restart
Now you need to configure your DHCPD. You can use your own subnet, it doesn’t really matter. Here’s mine:
option domain-name "localdomain.com";
option domain-name-servers 172.16.2.1;
option subnet-mask 255.255.255.0;
allow bootp;
allow booting;
next-server 172.16.2.1; #this one is required for PXE
filename "linux-install/pxelinux.0";
option ip-forwarding false;
option mask-supplier false;
subnet 172.16.2.0 netmask 255.255.255.0 {
option routers 172.16.2.1;
range dynamic-bootp 172.16.2.40 172.16.2.60;
}
When configured restart your DHCP server:
service dhcpd restart
Now it’s time to move some files to the tftp directory. If you’ve installed syslinux these files should be present on your system. You might be able to find them with find if they’re not on the same location as mine:
mkdir /var/lib/tftpboot/linux-install cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/linux-install cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/linux-install cp /usr/share/syslinux/memdisk /var/lib/tftpboot/linux-install cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot/linux-install cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot/linux-install
If you’ve created a yum mirror you can find the following files on your system. Otherwise you should be able to find them on your CD or on the internet:
mkdir -p /var/lib/tftpboot/linux-install/images/centos/i386/6.2 cp /usr/local/share/CentOS/6/os/i386/images/pxeboot/* \ /var/lib/tftpboot/linux-install/images/centos/i386/6.2/
Now you have to edit the xinetd superserver configuration so that it starts the tftp server. You do this by changing the line disabled = yes to disabled = no in the file /etc/xinetd/tftp. While you’re editing this file, please verify that the tftp path is the same as to which you copied all these files earlier.
Restart the xinetd superserver:
service xinetd restart
Now you can make a kickstart file. Use the kickstart editor found in the Gnome menu under system tools or edit one by hand.
Place the kickstart configuration file in the http directory. I placed it immediately in the root, but you can put it anywhere you like.
Now we’ll create the PXE configuration:
mkdir /usr/lib/tftpboot/linux-install/pxelinux.cfg/ vim /usr/lib/tftpboot/linux-install/pxelinux.cfg/default default menu.c32 prompt 0 timeout 10 MENU TITLE PXE Menu LABEL CentOS 6.2 i386 MENU LABEL CentOS 6.2 i386 KERNEL images/centos/i386/6.2/vmlinuz append initrd=images/centos/i386/6.2/initrd.img linux ks=http://172.16.2.1/ks.cfg
Now you should be able to PXE boot your new systems. Some last takeaways:
- Don’t forget your firewall. This blocks a lot by default, so you’ll have to open some ports
- SELinux might be causing some problems. You can verify by disabling SELinux temporarily using the command setenforce 0.
Preparing for a Network Installation
