linux 系统安装大体分为两个阶段
1,anaconda阶段(anaconda程序借助linux内核和initrd文件实现),也称配置阶段
 在这个阶段是安装配置阶段,配置语言,键盘,等信息。同时boot提示符下能够向内核传递参数.
2,安装阶段.
 安装前脚本配置
 安装软件包阶段
 安装后脚本配置

.....................................................................................
pxe无人值守网络安装redhat linux系统脚本
..................................................................................... 
要实现上面的功能,我们需要配置DHCP服务+NFS服务+TFTP服务,具体原理网上很多 ,在这我只提供一个脚本和我在实现中遇到的故障

在执行这个脚本的时候要先配置好yum源,自己主机在172.16.8.0/24网段

#!/bin/bash
myip=`ifconfig | awk -F: '/inet addr/{print $2}' |  grep -v "127.0.0.1"  |  cut -d' ' -f1 | cut -d'.' -f4`
[ ! -e /mnt/cdrom ] && mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
function setdhcp {
yum -y install dhcp
[ $? -eq 0 ] && "echo install ok ...................................."
mv  /etc/dhcpd.conf /etc/dhcpd.conf.bak
cat >> /etc/dhcpd.conf << EOF
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
next-server 172.16.8.$myip;
filename "pxelinux.0";
subnet 172.16.8.0 netmask 255.255.255.0 {

        option routers                  172.16.8.$myip;
        option subnet-mask              255.255.255.0;
        option domain-name-servers      172.16.8.$myip;
        option routers                  172.16.8.$myip;
        option subnet-mask              255.255.255.0;
        option domain-name              "domain.org";
        option domain-name-servers      172.16.8.$myip;
        option time-offset              -18000; # Eastern Standard Time
        range 172.16.8.200 172.16.8.220;
        default-lease-time 21600;
        max-lease-time 43200;
}
EOF
[ $? -eq 0 ] && echo " dhcp.conf is ok ..........................................."
service dhcpd start
[ $? -eq 0 ] && echo -e "\033[32mthe server dhcp start is ok......\033[0m" || exit 10
chkconfig dhcpd on
sync
}

function settftp {
yum -y install tftp-server
[ $? -eq 0 ] && "echo install ok ...................................."
sed -i  "s@disable[[:space:]]*= yes@disable                  = no@g" /etc/xinetd.d/tftp
service xinetd restart
mkdir /tftpboot
}

function setpxe {
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /mnt/cdrom/p_w_picpaths/pxeboot/{vmlinuz,initrd.img} /tftpboot
cp /mnt/cdrom/isolinux/*.msg /tftpboot/
[ $? -eq 0 ] && "cp vmlinuz,initrd.img is ok ..............................."
mkdir /tftpboot/pxelinux.cfg
#cp /mnt/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default####也可以直接cp,然后用sed修改部分参数
cat >> /tftpboot/pxelinux.cfg/default << EOF
default linux
prompt 1
timeout 60
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
  kernel vmlinuz
  append ks=nfs:172.16.8.$myip:/iso/ks.cfg initrd=initrd.img
label text
  kernel vmlinuz
  append initrd=initrd.img text
label ks
  kernel vmlinuz
  append ks initrd=initrd.img
label local
  localboot 1
label memtest86
  kernel memtest
  append -
EOF
chmod 755 /tftpboot/*
mkdir -pv /iso/install
cp /root/redhat5.4.iso /iso/install     #################需要镜像
echo "/iso *(ro,sync)" >> /etc/exports
service nfs restart
chkconfig nfs on
}


function setks {
#cp /root/anaconda-ks.cfg /iso/ks.cfg####也可以直接cp,然后用sed修改部分参数,感觉sed修改这些参数很麻烦所以就cat一个文件
if [ ! -e /iso/ks.cfg ];then
cat >> /iso/ks.cfg << EOF
text
nfs --server=172.16.8.$myip  --dir=/iso/install
key --skip
lang en_US.UTF-8
keyboard us
xconfig --startxonboot --resolution 1024x768 --depth 16
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$.Nwkli1d$Yr7n8.Oa0w9gl/K3Xe21/1   #########需要换成你自己设置的密码
firewall --disabled
authconfig --useshadow --enablemd5
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100
part pv.100000 --size=40960
part swap --size=512
volgroup vol0 --pesize=32768 pv.100000
logvol / --fstype ext3 --name=root --vgname=vol0 --size=29984
logvol /home --fstype ext3 --name=home --vgname=vol0 --size=1984

%packages
@GNOME Desktop Environment
@X Window System
@Printing Support
@Development Tools
elinks
openssh
openssh-server
openssh-clients
vim-enhanced
samba-common
samba-client
gimp
gimp-data-extras
enscript
libcap
ntp
coreutils
elfutils
elfutils-libelf
gimp-print-plugin
gnome-icon-theme
gstreamer
gstreamer-tools
libgnomeprint22
libgnomeprintui22
libgsf
libIDL
libraw1394
nautilus-cd-burner
openmotif
pyorbit
startup-notification
ttmkfdir
firefox
mutt
dialog
EOF
chmod +rx /iso/ks.cfg               ######################修改权限
else
echo "the file exit......................."
fi
}

setdhcp
settftp
setpxe
setks
.....................................................................................................................
说明  这个脚本有局限性,我随后有时间会加以修改,需要注意和容易犯错的地方我已经用##号备注,使用的时候可以根据自己的实际情况修改。