PXE+DHCP+TFTP+HTTP+KS
系统Centos 6.3 x86_64
vim /etc/sysconfig/i18n
LANG=" zh_CN.utf-8"
export.utf-8
测试所需设备:
1.DHCP 服务器
2.TFTP 服务器
3.KickStart所生成的ks.cfg配置文件
4.一台存放系统安装文件的服务器,如 NFS、HTTP 或 FTP 服务器,本文选择HTTP进行
5.带有一个 PXE 支持网卡的将安装的主机
1、安装相应的软件包
yum -y install httpd* tftp-server system-config-kickstart dhcp syslinux
挂载CentOS6.3的DVD光盘,并复制第一张光盘下的所有内容到/var/www/html/centos6/
mkdir -p /var/www/html/centos6
mount /dev/sr0 /mnt
cp -rf /mnt/* /var/www/html/centos6
2、配置tftp,启动http、tftp服务
vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#protocol.The tftp protocol is often used to boot diskless \
#workstations, download configuration files to network-aware printers, \
#and to start the installation process for some operating systems.
service tftp
{
socket_type= dgram
protocol= udp
wait= yes
user= root
server= /usr/sbin/in.tftpd
server_args= -s /tftpboot
disable= no
per_source= 11
cps= 100 2
flags= IPv4
}
3、配置dhcp
vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
next-server 192.168.205.128;#PXE服务器IP地址
filename "/pxelinux.0";
subnet 192.168.205.0 netmask 255.255.255.0 {
# --- default gateway
option routers192.168.205.2;#网关
option subnet-mask255.255.255.0;#子网掩码
#option nis-domain"domain.org";
#option domain-name"domain.org";
option domain-name-servers1.2.4.8;#DNS服务器
option time-offset-18000; # Eastern Standard Time
#option ntp-servers192.168.1.1;
#option netbios-name-servers192.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 192.168.205.80 192.168.205.90;#DHCP下放地址段
default-lease-time 21600;
max-lease-time 43200;
# 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、配置支持PXE启动
mkdir -p /tftpboot/pxelinux.cfg
cp /usr/share/syslinux/pxelinux.0 /tftpboot
cd /mnt/images/pxeboot/;cp initrd.img vmlinuz /tftpboot
cp /mnt/isolinux/*.msg /tftpboot
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
service dhcpd restart
service xinetd restart
service httpd restart
chkconfig --level 35 httpd on
chkconfig --level 35 dhcpd on
chkconfig --level 35 xinetd on
关闭SELINUX
sed -i 's/\(SELINUX=\)\(.*\)/\1disabled/' /etc/selinux/config
vim /tftpboot/pxelinux.cfg/default
default linux
#prompt 1
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.3!
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.205.128/centos6/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 -
vim /var/www/html/centos6/ks.cfg
#version=DEVEL
install
url --url=http://192.168.205.128/centos6###HTTP的方式
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw--iscrypted $6$KrqfuSH.BwjSGN3v$ffPvhCETN6KSNl2hGI48YIea2o4p6581yvW4H33zzDutowAruWGpYClPBJiJSuukm3etksqwNfBq7TO05ZYSn.
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
zerombr#注意此处,清空MBR
clearpart --all --initlabel #重新初始化硬盘分区
#part /boot --fstype=ext4 --size=500#/boot分区,200M
#part swap --size=1024#swap 分区,1024M
#part / --fstype=ext4 --grow --size=1 #根分区/,意为剩下所有的空闲空间都留给/
#Disk partitioning information
##part /boot --fstype ext4 --size=500
##part swap --size=1024
##part pv.01 --size=1 --grow
##volgroup vg_root pv.01
##logvol / --vgname=vg_root --size=8192 --name=lv_root
##logvol /var --vgname=vg_root --size=4096 --name=lv_var
##logvol /tmp --vgname=vg_root --size=2048 --name=lv_tmp
##logvol /spare --vgname=vg_root --size=1 --grow --name=lv_spare
part /boot --fstype=ext4 --size=500
part pv.001 --size=1 --grow
volgroup VolGroup --pesize=4096 pv.001
logvol swap --name=lv_swap --vgname=VolGroup --grow --size=2016 --maxsize=2016
logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1
reboot#安装完成后自动重启
%packages
@additional-devel
@base
@chinese-support
@client-mgmt-tools
@compat-libraries
@console-internet
@core
@debugging
@development
@directory-client
@hardware-monitoring
@large-systems
@legacy-unix
@network-file-system-client
@performance
@perl-runtime
@server-platform
@server-platform-devel
@server-policy
certmonger
gnutls-devel
jpackage-utils
krb5-workstation
libXau-devel
libXinerama-devel
libXrandr-devel
libbonobo-devel
libgcrypt-devel
libglade2-devel
libgnomeui-devel
libxslt-devel
mtools
oddjob
pam_krb5
pax
perl-DBD-SQLite
popt-devel
sgpio
startup-notification-devel
systemtap-client
tcp_wrappers
xorg-x11-proto-devel
%end