PXE+NFS+FTP+kickstarter无人值守安装linux系统

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. ddns-update-style interim;

  4. ignore client-updates;

  5. filename "/pxelinux.0";

  6. next-server 192.168.11.5;

  7. allow booting;

  8. allow bootp;


  9. subnet 192.168.11.0 netmask 255.255.255.0 {


  10. # --- default gateway

  11.        option routers                  192.168.11.1;

  12.        option subnet-mask              255.255.255.0;


  13.        option nis-domain               "domain.org";

  14.        option domain-name              "domain.org";

  15.        option domain-name-servers      192.168.11.1;


  16.        option time-offset              -18000; # Eastern Standard Time

  17. #       option ntp-servers              192.168.1.1;

  18. #       option netbios-name-servers     192.168.1.1;

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

  20. # -- you understand Netbios very well

  21. #       option netbios-node-type 2;


  22.        range dynamic-bootp 192.168.11.128 192.168.11.254;

  23.        default-lease-time 21600;

  24.        max-lease-time 43200;


  25.        # we want the nameserver to appear at a fixed address

  26.        host ns {

  27.                next-server marvin.redhat.com;

  28.                hardware ethernet 12:34:56:78:AB:CD;

  29.                fixed-address 207.175.42.254;

  30.        }

  31. }

4、配置tftp服务器

  
  
  
  
  1. [root@localhost tftpboot]# vi /etc/xinetd.d/tftp  


  2. # default: off

  3. # description: The tftp server serves files using the trivial file transfer \

  4. #       protocol.  The tftp protocol is often used to boot diskless \

  5. #       workstations, download configuration files to network-aware printers, \

  6. #       and to start the installation process for some operating systems.

  7. service tftp

  8. {

  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. ~                                                                                                          

  24. "/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/images/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. %packages

  26. @core

  27. @base

  28. device-mapper-multipath

  29. imake

  30. *******************************************************************************

8、启动服务

  
  
  
  
  1. service dhcpd start

  2. service xinetd start

  3. service portmap start  

  4. service nfslock start

  5. service nfs start

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

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


你可能感兴趣的:(cnetos)