1)安装DHCP软件包

yum install dhcpd -y

配置dhcpd.conf


ddns-update-style none;

ignore client-updates;

allow booting;

allow bootp;


subnet 192.168.18.0 netmask 255.255.255.0 {

range 192.168.18.20 192.168.18.40;

option subnet-mask 255.255.255.0;

default-lease-time 21600;

max-lease-time 43200;

next-server 192.168.18.8;

filename "pxelinux.0";

}


2)安装配置TFTP服务器

yum install tftp-server -y 

配置/etc/xinetd.d/tftp


service tftp

{

socket_type= dgram

protocol= udp

wait= yes

user= root

server= /usr/sbin/in.tftpd

server_args= -s /var/lib/tftpboot

disable= no

per_source= 11

cps= 100 2

flags= IPv4

}


3)拷贝启动引导文件到FTP

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

mount /dev/cdrom /mnt

cp /mnt/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/

mkdir -p /var/lib/tftpboot/pxelinux.cfg

cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default


配置default

default linux

#prompt 1

timeout 600


display boot.msg


menu background splash.jpg

menu title Welcome to CentOS 6.6!

menu color border 0 #ffffffff #00000000

menu color sel 7 #ffffffff #ff000000

menu color title 0 #ffffffff #00000000

menu color tabmsg 0 #ffffffff #00000000

menu color unsel 0 #ffffffff #00000000

menu color hotsel 0 #ff000000 #ffffffff

menu color hotkey 7 #ffffffff #ff000000

menu color scrollbar 0 #ffffffff #00000000


label linux

  menu label ^Install or upgrade an existing system

  menu default

  kernel vmlinuz

  append initrd=initrd.img ks=http://192.168.18.8/ks.cfg

label vesa

  menu label Install system with ^basic video driver

  kernel vmlinuz

  append initrd=initrd.img xdriver=vesa nomodeset

label rescue

  menu label ^Rescue installed system

  kernel vmlinuz

  append initrd=initrd.img rescue

label local

  menu label Boot from ^local drive

  localboot 0xffff

label memtest86

  menu label ^Memory test

  kernel memtest

  append -


4)安装配置http

yum install httpd -y


[root@kickstart conf]# grep ServerName httpd.conf |grep -v "#"

ServerName 192.168.18.8


5)拷贝安装介质

mount /dev/cdrom /mnt

cp -fr /mnt/* /var/www/html/


6)制作ks.cfg

yum install system-config-kickstart -y

system-config-kickstart  图形配置保存ks.cfg到/var/www/html/


ks.cfg配置文件(最小化安装系统)

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use network installation

url --url="http://192.168.18.8/"

# Root password

rootpw --iscrypted $1$8vZrwtUd$U8im.4WyqS5AoDreuwmui0

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use graphical install

graphical

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone  Asia/Shanghai

# System bootloader configuration

bootloader --location=mbr

# Partition clearing information

clearpart --all --initlabel 

# Disk partitioning information

part /boot --fstype="ext4" --size=200

part swap --fstype="swap" --size=2000

part / --fstype="ext4" --grow  --size=1


%packages --nobase


ks.cfg保存到/var/www/html/



7)启动服务

/etc/init.d/dhcpd start

/etc/init.d/xinetd start

/etc/init.d/httpd start


8)测试,安装一台新的虚拟机,配置BIOS启动引导为pxe方式