PXE Tools
Requirements
Server :
DHCP (tested with 3.0)
TFTP (tested with tftp server 0.32)
NFS (only if you want to use the install portion)
Client :
A network card that boots into PXE (for more information on pxe, see link below)
All of these can reside fine on the same server
This asumes that the requirements above are already installed
* Server Setup *
=-= DHCPD =-=
Edit /etc/dhcpd.conf (this might
not exist, so create it. You
can also just copy the dhpcd.conf
file from this archive to /etc)
The file should look somthing
like this (with changes that fit
your network)
**** NOTE ****
Since writing this document the included
dhcpd.conf file has changed to somthing
other then the bellow configuration. It
should not matter. The changes will not
affect anything. I am not putting the
changes in this readme every time I change
it as it is out of the scope of this
project. Either configuration will work.
If you want to understand the configurations,
please go to the dhcp site listed at the bottem
of this readme, in the footnotes.
**** END ****
allow booting;
allow bootp;
ddns-update-style none;
Change this to your domain name
option domain-name "yourdomain.net";
option domain-name-servers 10.10.10.1;
option routers 10.10.10.1;
option dhcp-max-message-size 2048;
This IP should match the server that will be running the TFTP service
option tftp-server-name "10.10.10.90";
max-lease-time 300;
default-lease-time 300;
authoritative;
subnet 10.10.10.0 netmask 255.255.255.0 {
range dynamic-bootp 10.10.10.100 10.10.10.110;
These next 2 IP's should match the server that will be running the TFTP service
next-server 10.10.10.90;
server-name "10.10.10.90";
filename "pxelinux.0";
get-lease-hostnames true;
use-host-decl-names on;
}
=-= TFTPD =-=
Create a directory somewhere that
will hold your tftp images.
tftpd should run from xinetd
so create or edit /etc/xinet.d/tftp
as follows (alteratively, you can copy
the tftp file include in this archive
to you xinetd.d directory):
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
this should be the directory you created above
server_args = -s /created-directory
per_source = 11
cps = 100 2
flags = IPv4
}
=-= NFSD =-=
This is an optional section for doing a redhat kickstart over pxe (information about doing a kickstart can be found at the link below).
Add this line to /etc/exports (network and/or directory changes)
/opt/redhat 10.10.10.0/255.255.255.0(ro,all_squash,sync)
As an example, I created a directory called redhat under opt. The directory structure under that looks as follows:
/opt/redhat
/opt/redhat/kickstart
/opt/redhat/rhdist
/opt/redhat/rhdist/ES3.0/
/opt/redhatrhdist/7.3/
The /opt/redhat/rhdist/ES3.0/ & /opt/redhatrhdist/7.3/ directories have the contents of the redhat ES3.0 CD and the redhat 7.3 CD respectivly.
The kickstart directory holds the ks.cfg file and a perl script that is run during the post installation part of the kickstart process.
**** NOTE ****
I have included an empty directory structure for inspection
**** END ****
=-= FILES =-=
copy the contents of the files in the pxe directory from this archive into the directory that was created in the TFTPD setup section.
Included is the pxectrl.pl script. This script assumes that init scripts for the following services are located in /etc/init.d, that they are named the following and that they take the following arguments, stop & start:
portmap
nfs
dhcpd
xinetd
To start the services (and configure the files) run the pxectrl.pl script. Running this file with no arguments will display the help doc to explain the switches. Once the script is run and services started, run netstat -taup to determin if the services (portmap, nfs, dhcpd and tftp(this will be running from xinetd)) are up and move on to the client setup.
* Client Setup *
Reboot the client, and set the system
to boot PXE before harddrive
* Notes *
=-= KS.CFG=-=
Redhat kickstart install is a method
of deploying redhat installations. It
can work in unattended mode, allowing to
install multiple redhat machines with identical
configurations without having to remember what
options you choose.
When you complete a redhat install (regular or kickstart) there is a file named anaconda-ks.cfg in /root. This is all of the options chosen for the installation. A good way to get a kickstart is to simply install redhat the way you want, then take the anaconda-ks.cfg and use that as your ks.cfg file.
Two noteable parts of of kickstart are the PRE and POST kickstart sections. Commands put in the PRE section run in the installation environment before the install begins. Commands in the POST section run after the install in the newly installed environment (after the install finishes, the install then chroots into the newly installed environment) This is useful for adding extra user accounts, editing files, etc.. I personally mount a directory on the kickstart server and run a perl script (yes perl is available) that installs some extra apps, edits some files and adds some files. I have included this perl script with this archive.
=-= build.pl=-=
build.pl is a custom perl script should be run during POST install for kickstart. This is the section of the ks.cfg file that runs the build.pl script
%post
mkdir /mnt/post
mount -t nfs -o ro,nolock 10.10.10.90:/opt/redhat /mnt/post
perl /mnt/post/kickstart/build.pl
umount /mnt/post
rm -Rf /mnt/post
My repository looks like this (relative)
repository/
repository/root.crontab
repository/etc/
repository/etc/inittab.appd
repository/etc/init.d/nrpe
repository/boot/grub/grub.conf.delta
repository/opt/oracle.tgz
repository/filemap
repository/SOURCE
repository/SOURCE/install.ksh
repository/SOURCE/DBI-1.43
(this is not the whole directory)
**** NOTE ****
I have included an empty directory structure
as an example
**** END ****
the following should be noted:
files with .crontab will be appended to /etc/crontab
files with .appd will be appended to its file (the contents of repository/etc/inittab.appd will be appended to /etc/inittab)
files with tgz extention will be extracted (repository/opt/oracle.tgz will be extraced to /opt/)
files with no know extention (crontab,appd,delta,tgz) will be copied (repository/etc/init.d/nrpe will be copied to /etc/init.d/)
files with the .delta extention look like this:
#$ident kernel
#$position end
console=ttyS0,115200n8
The #$ident line is a unique identifier, in this case it looks for all lines with the word kernel in it.
The #$position line takes one of two arguments end or begining
The final line is appended to the file at the #$ident line at #$position
The variable $filemap in the configurable section of the build.pl file is a file that tells the script what directories to traverse when looking for configuration files. In mine I have the following:
## start
/etc
/etc/init.d
/opt
/boot/grub
## end
Two things to note here. First the start and end lines ARE NOT IN THIS FILE. The second is to note the space between the ## start comment and the /etc line. This is only needed if there are file changes being made in the ROOT directory. In my case, I have root.crontab in repository/root.crontab so I need the space.
The SOURCE directory holds, for me, source files. These files are already configured and compiled. I also have rpms in there. The build.pl file runs the install.ksh file, which performs the installs.
=-= initrd =-=
The initrdrc.img can be edited in the following manner:
mkdir /mnt/somedir
gunzip -c initrdrc.img
mount -oloop initrdrc.img /mnt/somedir
This is just a gentoo livecd with minor changes and some utilities added. To add a file just put it in its appropriate directory. To find what libraries are needed, you can do a
ldd filename
to see what files are needed. After adding any new libraries, you need to rebuild the cache. Edit /mnt/somedir/etc/ld.so.conf and make sure that the directory that holds the newly installed libraries is in it. Then run
ldconfig -r /mnt/somedir
If you need the image to be larger, you can create a new image by the following:
dd if=/dev/zero of=newfs bs=1M count=200 mke2fs -F -m 0 -b 1024 newfs
This would make a new image that is 200MB in size. Next mount the new image the same way that you mounted the original initrdrc.img. Mount it in a different directory though.
mkdir /mnt/someotherdir
mount -oloop newfs /mnt/someotherdir
Next copy the contents of the original initrdrc.img to the new image (this asumes that the initrdrc.img file is still mounted)
cp -dpPR /mnt/somedir/* /mnt/someotherdir
To prepare the new image for booting, unmount the image
umount /mnt/someotherdir
gzip the new image
gzip newfs
and replace the original initrdrc.img file
mv newfs.gz initrdrc.img
* My Setup *
My setup went as follows:
1 installed dhcpd
2 installed tftpd
3 installed nfs-tools
4 untar/gunzip the archive
5 copied dhcpd.conf (from this archive) to /etc
6 copied exports (from this archive) to /etc
7 copied tftp (from this archive) to /etc/xinetd.d/
8 moved pxe directory in this archive to / (/pxe)
9 moved redhat directory in this archive to /opt (/opt/redhat)
10 copied install files from ES3.0 cd to the /opt/redhat/rhdist/ES3.0
directory
11 copied install files from 7.3 cd to the /opt/redhat/rhdist/7.3
directory
12 configured generic changes in /opt/kickstart/repository/ES3.0/generic
13 configured generic changes in /opt/kickstart/repository/7.3/generic
14 configured group changes in /opt/kickstart/repository/ES3.0/groups/mds
15 configured group changes in /opt/kickstart/repository/7.3/groups/mds
** NOTE mds is just a server group for me **
16 configured server changes in /opt/kickstart/repository/ES3.0/servers/mds12
17 configured server changes in /opt/kickstart/repository/7.3/servers/mds12
** NOTE mds12 is just one of my servers **
18 ran the pxectrl script
** NOTE when running the pxectrl script, you tell it that the server is part of
X group and is specifically X server (you can give the script multiple groups
and servers or none at all.)
19 restarted the client box in pxe boot mode
** Although I have ES3.0 and 7.3, it does not matter what version(s) that you use
the script (pxectrl) is smart enough to handle it. Also, you dont have to do ANY of steps 12-17, thats just for making changes to the system after its installed. Things do get overwritten with those changes SOOOO it goes as follows:
The install installs xyz file
The build script runs and in the generic folder (for the distro) is a replacement
xyz file, this file overwrites the originally install xyz file
The build script then finds xyz file with an appd extention in the groups/mds folder
(for your distro) and appends the contents to the xyz file installed from the generic
folder
The build script then finds xyz file in servers/mds12 with no extention, it over
writes the xyz file
So it goes like this:
you run pxectl with the switches -G mds,mdb -S mds12,mds10
the build script is configures to use the configuration from groups
mds and mdb and to use the configuration from mds12 and mds10, HOWEVER
mds10, being last in the servers list, will take precedence.
Any files so far modified by other configurations that mds10 overwrites
will be overwritten. The order goes like this (with the last being the
final word)
install
generic
groups1
groups2
groups3(etc.)
servers1
servers2
servers3(etc.)
* Footnotes *
Most of this setup can be atributed to excellent online documentation.
PXE Kickstart install
http://www-03.ibm.com/support/techdocs/atsmastr.nsf/WebIndex/TD102019
DHCP
http://www.isc.org/index.pl?/sw/dhcp/
PXE Bootloader
http://syslinux.zytor.com/pxe.php
About PXE
http://pxes.sourceforge.net/pxe.html
About NFS
http://nfs.sourceforge.net/
About Kickstart
http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/ch-kickstart2.html
About creating an initrd file
http://www.faqs.org/docs/evms/x3834.html
