利用PXE实现多台机子的启动自动安装(以10.1.1.0/24网段为例)

1.安装dhcpd服务yum install dhcpd

2.安装好后配置/etc/dhcpd.conf文件此文件不存在就拷贝,                                            cp    /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample    /etc/dhcpd.conf

3.配置此文件内容为

  ddns-update-style interim;

ignore client-updates;

allow booting;

allow bootp;

subnet 10.1.1.0 netmask 255.255.255.0 {

# --- default gateway

#       option routers                  192.168.0.1;

        option subnet-mask              255.255.255.0;

#       option nis-domain               "domain.org";

#       option domain-name              "domain.org";

#       option domain-name-servers      192.168.1.1;

        option time-offset              -18000; # Eastern Standard Time

#       option ntp-servers              192.168.1.1;

#       option netbios-name-servers     192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

        range dynamic-bootp 10.1.1.2 10.1.1.254;

        default-lease-time 21600;

        max-lease-time 43200;

        

        next-server 10.1.1.1;

        filename pxelinux.0;

        # we want the nameserver to appear at a fixed address

#       host ns {

#               next-server marvin.redhat.com;

#               hardware ethernet 12:34:56:78:AB:CD;

#               fixed-address 207.175.42.254;

#       }

}

4.安装tftp服务,xinetd服务

     cd /misc/cd/CentOS

 rpm -ivh xinetd-2.3.14-10.el5.i386.rpm

 rpm -ivh tftp-server-0.49-2.el5.centos.i386.rpm

 rpm -ivh tftp-0.49-2.el5.centos.i386.rpm

5.修改/etc/xinetd.d/tftp文件,将disable=no

6.启动或者重启xinetd服务

7.拷贝文件到/tftpboot/

  cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

  cd /misc/cd/p_w_picpaths

  cp pxeboot/initvd.img  /tftpboot/

  cp pxeboot/vmlinuz  /tftpboot/

8回到/tftpboot/目录下cd /tftpboot

9./tftpboot/下新建pxelinux.cfg

10.pxelinux.cfg/目录下新建default文件

11.default文件中添加内容

   default linux

   prompt 1

   timeout 60

   display boot.msg

   label linux

    kernel vmlinuz

    append initrd=initrd.img text ks=http://10.1.1.1/ks.cfg

12.拷贝cp  /root/anaconda-ks.cfg  /var/www/html/ks.cfg

13.更改  /var/www/html/ks.cfg 的内容为 

    # Kickstart file automatically generated by anaconda.

install

url --url=http://10.1.1.1

lang en_US.UTF-8

keyboard us

network --device eth0 --bootproto dhcp

rootpw --iscrypted $1$47O45whL$wMKyRmOCBCgC0DzHIdPvh/

firewall --enabled --port=22:tcp

authconfig --enableshadow --enablemd5

selinux --enforcing

timezone --utc Asia/Shanghai

bootloader --location=mbr --driveorder=sda

# 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 --linux --initlabel --drives=sda

part /boot --fstype ext3 --size=100 --ondisk=sda

part pv.2 --size=0 --grow --ondisk=sda

volgroup VolGroup00 --pesize=32768 pv.2

logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow

logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512 --grow --maxsize=1024

reboot

%packages

@base

@core

@dns-server

@dialup

@editors

@text-internet

@web-server

keyutils

trousers

fipscheck

device-mapper-multipath

14.拷贝光盘中内容到/var/www/html

15 启动 xinetdhttpddhcpd服务