In this tutorial we are going to be making some assumptions that you can tune if you need to. In my case we are going to start with a clean install of CentOS 6.2 with the minimal package option. The server will have (2) NICs one public facing the other is private facing.
Here is a diagram of what that could look like.
What we want at the end of the day is for clients on the eth1 network to call out to the DHCP server, PXE boot and get a menu for install options. I'll also cover at the end how you can spruce this up with a kick start file to automate the process.
We are going to create a centos image that we are going to pxe boot, but you can append what ever distro you want as well.
OK let's get started, first lets grab all of the packages we are going to use:
Let's do the smart thing and make sure that all loads at boot
Disable SeLinux which will cause issues with Apache
DHCP server config
Lets start by configuring the DHCP server first.
Start by using vi or your favorite editor on the following file: /etc/dhcpd/dhcpd.conf
Read this! The above assumes that eth1 is 192.168.21.1, so replace that value with what ever value is either assigned to your NIC or that you want assigned to your NIC.
next-server is used to tell the clients where to go for the pxe-boot process. So if you wanted to stand up a DHCP server separate from your TFTP/PXE server, you would change "next-server" to the IP address of the TFPT/PXE server. In our case, we are using them on the same machine.
Notice that in domain-name-servers I used 8.8.8.8 first, that is googles DNS, so you can update those values to reflect your internal DNS servers if you like.
TFTP/PXE server config
CentOS installs the TFPT server in /var/lib/tftpboot/ so head over there. We also need to mount a CentOS 6.2 cd to grab some files off it, if you have not already mounted a CDrom with the CentOS 6 installer, you can just mount an ISO of it with the following command (assumes that you coped the ISO file to /tmp):
Now we need to prep that folder:
Now we need to edit the PXE file so it gives you a menu and options:
Configure Apache
What we want is the clients that are going to boot to be able to call up the full installer ISO, so we are going to use apache to provide the files. In order to do that, we need to make the following updates to apache's config.
An important difference between debian and Centos is that Cent requires the 00 prefix in the file name, where as debian does not
So what that is doing is making an alias for Apache to use. In our case, we are putting the ISO files in /boot-images/.
If your setup is / is one partition, make sure you have enough space, otherwise, add a disc and mount it in /boot-images
The last command makes sure that apache can read those files, if you want tighter security, you can use:
Allow the network to work
In my example, we have (2) NICs, so I want clients to connect to the DHCP server and have it act as a gateway, so I need to enable some features to allow that.
Lets modify iptables:
Now enable IP forwarding
Test
Make sure the following value is NO
Now start the stack up…
Now try to boot a host in PXE, mode. You should now get the menu that you created above and be able to boot that installer image.
Next steps
So that gets you PXE booting, but now you want to take it to the next level, you want automatic installs!
No problem, you can script your machine installs with a kick-start file.
There is a ton of info out there on how to make a kickstart file, so I am not going to cover that. I am going to show you how to just jump in though with no knowledge of the kickstart file creation process.
First, make a clean install on a machine and configure the options as you want them. After the install is complete, in the root users home folder you will see a file called "anaconda-ks.cfg "
That file is a clone of the options that you made when you ran the install, go ahead and copy that file to your PXE server and place it in /var/www/html
Lets rename that file to centos62.ks and make a folder for ks
The only change that you "should" make for sure is the disk partition section unless each machine you are going to install this on will have EXACTLY the same disc and capacity drive.
If not, comment out the line that starts with "#part /boot --fstype=ext4 --size=500" and keep commenting out until you get to the last line in that section which normally is "logvol swap --name=lv_swap --vgname=vg_name --grow --size=1024 --maxsize=8016"
In order to offer the kick start option, you just need to make two changes to the above config.
Update apache
We are going to add another alias
Reload apache
Update your menu options
We need to include an option now for the kick start installer version.
Test
Reboot a PXE node and PXE boot again, this time when you load the menu, you should see you new kickstart line. When you boot, the installer will only prompt you about the disc layout information, the rest will all be done automatically!
I hope this helped you, if so please leave a comment below and let others know what did and didn't work for you.