++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
安装依赖环境
yum install syslinux -y
yum install httpd -y
yum install tftp-server -y
yum install tftp -y
yum install dhcp -y
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
查看tftp是否安装
rpm -qa | egrep 'tftp|xinetd
tftp-0.49-7.el6.x86_64
xinetd-2.3.14-33.el6.x86_64
tftp-server-0.49-7.el6.x86_64
创建iso挂载目录
[root@pxe ~]# mkdir -p /var/pxe/centos6
创建启动存放目录
[root@pxe ~]# mkdir -p /var/lib/tftpboot/centos6
拷贝ISO文件到
[root@pxe ~]# cp -rf /media/CentOS_6.5_Final/* /var/pxe/centos6
配置启动文件
[root@pxe ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg/
[root@pxe ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@pxe ~]# cp /var/pxe/centos6/isolinux/initrd.img /var/lib/tftpboot/
[root@pxe ~]# cp /var/pxe/centos6/isolinux/vmlinuz /var/lib/tftpboot/
[root@pxe ~]# cp /var/pxe/centos6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
查看启动配置
[root@pxe ~]# ls -R /var/lib/tftpboot/
boot.msg initrd.img pxelinux.0 pxelinux.cfg vmlinuz
添加Http启动脚本配置
[root@pxe ~]# cd /var/lib/tftpboot/pxelinux.cfg/
备份一份,防止出错无法恢复
[root@pxe ~]# cp default default.bak
手动安装系统
[root@pxe ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
# create new
timeout 100
default menu.c32
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img method=http://192.168.31.67/centos6 devfs=nomount
label 2
menu label ^2) Boot from local drive
localboot
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
的示例显示CentOS 6 ISO图像/家/ ISO目录下
[root@pxe ~]# cp /var/pxe/centos6/images/pxeboot/vmlinuz /var/lib/tftpboot/centos6/
[root@pxe ~]# cp /var/pxe/centos6/images/pxeboot/initrd.img /var/lib/tftpboot/centos6/
[root@pxe ~]# cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
配置http
[root@pxe ~]# vi /etc/httpd/conf.d/pxeboot.conf
# create new
Alias /centos6 /var/pxe/centos6
Options Indexes FollowSymLinks
Order Deny,Allow
Deny from all
# Ip address you allow to access
Allow from 127.0.0.1 192.168.31.0/24
重启http 服务
service httpd restart
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
配置DHCP
vi /etc/dhcp/dhcpd.conf
subnet 192.168.31.0 netmask 255.255.255.0 {
option routers 192.168.31.1;
option subnet-mask 255.255.255.0;
option domain-name "benet.com";
option domain-name-servers 8.8.8.8,61.134.1.5;
default-lease-time 21600;
max-lease-time 43200;
range 192.168.31.30 192.168.31.35;
next-server 192.168.31.66;
filename "pxelinux.0";
}
启动DHCP
service dhcpd start
开机启动DHCP
chkconfig dhcpd on
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
配置tftp 服务
#将disable 设置为no
vi /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
}
开机启动xinetd
chkconfig xinetd on
启动xinetd
service xinetd start
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
配置启动设置
[root@pxe ~]# openssl passwd -1
ks.cfg 配置文件
[root@pxe ~]# vi /var/www/html/ks/centos6-ks.cfg
# Kickstart file automatically generated by anaconda.
#version=RHEL6
install
# add: automatically proceed
autostep
# add: reboot after finishing installation
reboot
# add: install source
url --url=http://192.168.31.66/centos6/
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
# change to the root 1234.com you generated above
# change to the root 1234.com you generated above
rootpw --iscrypted $1$BYJeffer$VIg4D3TgI/ate3mP8bZio0
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# if the client is KVM virtual machine, make the line above comment and add the line below (uncomment it)
# bootloader --location=mbr --driveorder=vda --append="console=ttyS0,115200n8 crashkernel=auto"
# add: delete all partitions in all disks
zerombr
clearpart --all --initlabel
# 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 --all --drives=sda
#volgroup VolGroup --pesize=4096 pv.008002
#logvol /home --fstype=ext4 --name=lv_home --vgname=VolGroup --grow --size=100
#logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
#logvol swap --name=lv_swap --vgname=VolGroup --grow --size=4032 --maxsize=4032
#part /boot --fstype=ext4 --size=500
#part pv.008002 --grow --size=1
#repo --name="Scientific Linux" --baseurl=file:///mnt/source --cost=100
%packages
@base
@chinese-support
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@java-platform
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
mtools
pax
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
cjkuni-fonts-ghostscript
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
cjkuni-fonts-ghostscript
libXmu
@core
%end
--------------------------------------------------------------------------------------------------------------------------
自启动配置
[root@pxe ~]# vi /var/lib/tftpboot/pxelinux.cfg/default
timeout 100
default menu.c32
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 6
kernel centos6/vmlinuz
# change like follows: specify kick-start-file
append initrd=centos6/initrd.img ks=http://192.168.31.66/ks/centos6-ks.cfg ksdevice=eth0
label 2
menu label ^2) Boot from local drive
localboot
---------------------------------------------------------------------------------------------------------------------------
|
Installation proceeds automatically, nothing to do at all. After finishing installation, the system will reboot automatically. |