1、系统环境

Centos 5.5

IP:192.168.11.5,  Gateway: 192.168.11.1

2 、使用yum方式安装软件包

 
  
  1. yum install -y tftp* xinetd dhcpd 

3 、配置dhcp服务器

 
  
  1. cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf  
  2. [root@localhost tftpboot]# vi /etc/dhcpd.conf  
  3.  
  4. ddns-update-style interim; 
  5. ignore client-updates; 
  6. filename "/pxelinux.0"; 
  7. next-server 192.168.11.5; 
  8. allow booting; 
  9. allow bootp; 
  10.  
  11. subnet 192.168.11.0 netmask 255.255.255.0 { 
  12.  
  13. # --- default gateway 
  14.         option routers                  192.168.11.1; 
  15.         option subnet-mask              255.255.255.0; 
  16.  
  17.         option nis-domain               "domain.org"; 
  18.         option domain-name              "domain.org"; 
  19.         option domain-name-servers      192.168.11.1; 
  20.  
  21.         option time-offset              -18000; # Eastern Standard Time 
  22. #       option ntp-servers              192.168.1.1; 
  23. #       option netbios-name-servers     192.168.1.1; 
  24. # --- Selects point-to-point node (default is hybrid). Don't change this unless 
  25. # -- you understand Netbios very well 
  26. #       option netbios-node-type 2; 
  27.  
  28.         range dynamic-bootp 192.168.11.128 192.168.11.254; 
  29.         default-lease-time 21600; 
  30.         max-lease-time 43200; 
  31.  
  32.         # we want the nameserver to appear at a fixed address 
  33.         host ns { 
  34.                 next-server marvin.redhat.com; 
  35.                 hardware ethernet 12:34:56:78:AB:CD; 
  36.                 fixed-address 207.175.42.254; 
  37.         } 

4、配置tftp服务器

 
  
  1. [root@localhost tftpboot]# vi /etc/xinetd.d/tftp  
  2.  
  3. # default: off 
  4. # description: The tftp server serves files using the trivial file transfer \ 
  5. #       protocol.  The tftp protocol is often used to boot diskless \ 
  6. #       workstations, download configuration files to network-aware printers, \ 
  7. #       and to start the installation process for some operating systems. 
  8. service tftp 
  9.         socket_type             = dgram 
  10.         protocol                = udp 
  11.         wait                    = yes 
  12.         user                    = root 
  13.         server                  = /usr/sbin/in.tftpd 
  14.         server_args             = -u nobody -s /tftpboot #指定目录

  15.         disable                 = no  #将yes改为no
  16.         per_source              = 11 
  17.         cps                     = 100 2 
  18.         flags                   = IPv4 
  19. ~                                                                                                           
  20. ~                                                                                                           
  21. ~                                                                                                           
  22. ~                                                                                                           
  23. "/etc/xinetd.d/tftp" 18L, 519C 

5、配置NFS服务器,添加共享目录

 
  
  1. [root@localhost ~]# vi /etc/exports  
  2. /mnt *(ro,sync) 
  3. /tftpboot *(ro,sync) 

6、复制pxelinux.0、initrd.img、vmlinuz、isolinux/*.msg

 
  
  1. mount /dev/cdrom /mnt 
  2. cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ 
  3. cp /mnt/p_w_picpaths/pxeboot/{initrd.img,vmlinuz} /tftpboot/ 
  4. mkdir /tftpboot/pxelinux.cfg 
  5. touch /tftpboot/pxelinux.cfg/default 
  6. vi /tftpboot/pxelinux.cfg/default 
  7. default linux 
  8. prompt 1 
  9. timeout 600 
  10. display boot.msg 
  11. F1 boot.msg 
  12. F2 options.msg 
  13. F3 general.msg 
  14. F4 param.msg 
  15. F5 rescue.msg 
  16. label linux 
  17.   kernel vmlinuz 
  18. #  append initrdinitrd=initrd.img 
  19.   append initrdinitrd=initrd.img   ks=nfs:192.168.11.5:/tftpboot/ks.cfg 
  20. label text 
  21.   kernel vmlinuz 
  22.   append initrdinitrd=initrd.img text  以文本模式安装 
  23. label ks 
  24.   kernel vmlinuz 
  25.   append ks initrdinitrd=initrd.img 
  26. label local 
  27.   localboot 1 
  28. label memtest86 
  29.   kernel memtest 
  30.   append - 

Pxe已经完成了,想用ks完成全自动安装的可以往下看。

7、使用kickstarter配置无人值守。
 
  
  1. [root@localhost tftpboot]# pwd 
  2. /tftpboot 
  3. [root@localhost tftpboot]# ls 
  4. initrd.img  ks.cfg  pxelinux.0  pxelinux.cfg  vmlinuz 
  5.  [root@localhost tftpboot]# vi ks.cfg  
  6. install 
  7. nfs --server=192.168.11.5 --dir=/mnt 
  8. lang en_US.UTF-8 
  9. keyboard us 
  10. network --device eth0 --bootproto dhcp --hostname localhost 
  11. rootpw --iscrypted $1$kE50pGl1$imqt12NcqN6KiJGToKNZo0 
  12. firewall --disable 
  13. authconfig --enableshadow --enablemd5 
  14. selinux --enforcing 
  15. timezone Asia/Shanghai 
  16. bootloader --location=mbr --driveorder=sda 
  17. # The following is the partition information you requested 
  18. # Note that any partitions you deleted are not expressed 
  19. # here so unless you clear all partitions first, this is 
  20. # not guaranteed to work 
  21. clearpart --all --initlabel 
  22. part /boot --fstype ext3 --size=100 
  23. part swap --size=2048 
  24. part / --fstype ext3 --size=1 --grow 
  25.  
  26. %packages 
  27. @core 
  28. @base 
  29. device-mapper-multipath 
  30. imake 
  31. ******************************************************************************* 

8、启动服务

 
  
  1. service dhcpd start 
  2. service xinetd start 
  3. service portmap start  
  4. service nfslock start 
  5. service nfs start 

9、被安装服务器上安装测试(选择pxe启动方式)

到这一步说明我们配置的dhcp服务器起作用了,我们直接回撤,系统开始查找系统文件自动安装