一、实验环境
系统平台:CentOS release 6.4 ,yum源服务器
二、准备工作
挂载CentOS 6.4镜像源
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# mount -o loop /usr/local/src/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom
[root@localhost ~]#
三、安装配置HTTP
安装并配置HTTP
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# yum -y install httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
base | 4.0 kB 00:00 ...
Setting up Install Process
Package httpd-2.2.15-26.el6.centos.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]#
启动http服务
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# service httpd start
正在启动 httpd:
[root@localhost ~]# service httpd status
httpd (pid 4203) 正在运行...
[root@localhost ~]#
在/var/www/html/ 下创建cdrom目录,并复制/mnt/cdrom/目录下光盘全部内容至http 的根目录/var/www/html/cdrom/下
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# mkdir /var/www/html/cdrom
[root@localhost ~]#sudo cp -rf /mnt/cdrom/* /var/www/html/cdrom
[root@localhost ~]#
四、安装配置TFTP
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# yum -y install tftp
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tftp.x86_64 0:0.49-7.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
tftp x86_64 0.49-7.el6 base 32 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 32 k
Installed size: 45 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : tftp-0.49-7.el6.x86_64 1/1
Verifying : tftp-0.49-7.el6.x86_64 1/1
Installed:
tftp.x86_64 0:0.49-7.el6
Complete!
[root@localhost ~]#
编辑tftp配置文件
[TZ@localhost xinetd.d]$ sudo gedit 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
}
将disable 设置为no
启动tftp服务
因为tftp服务是挂载在超级进程xinetd 下的,所以通过启动xinetd 来启动tftp服务
# /etc/init.d/xinetd restart[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# service xinetd start
正在启动 xinetd:
[root@localhost ~]# service xinetd status
xinetd (pid 2591) 正在运行...
[root@localhost ~]#
五、配置支持PXE的启动程序
复制pxelinux.0 文件至/var/lib/tftpboot/ 文件夹中
[root@localhost ~]#sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
复制iso 镜像中的/image/pxeboot/initrd.img 和vmlinux 至/var/lib/tftpboot/ 文件夹中
[root@localhost ~]#sudo cp /var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
复制iso 镜像中的/isolinux/*.msg 至/var/lib/tftpboot/ 文件夹中
[root@localhost ~]#sudo cp /var/www/html/cdrom/isolinux/*.msg /var/lib/tftpboot/
在/var/lib/tftpboot/ 中新建一个pxelinux.cfg目录
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
将iso 镜像中的/isolinux 目录中的isolinux.cfg复制到pxelinux.cfg目录中,同时更改文件名称为default
[root@localhost ~]#sudo cp /var/www/html/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
修改default文件
[root@localhost ~]# sudo geidt /var/lib/tftpboot/pxelinux.cfg/default
default ks
prompt 1
timeout 6
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks=http://192.168.0.1/ks.cfg initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
六、配置DHCP
安装DHCP服务
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# yum -y install dhcp
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 12:dhcp-4.1.1-34.P1.el6.centos.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]#
修改/etc/dhcp/dhcpd.conf 配置文件
[TZ@localhost dhcp]$ sudo gedit dhcpd.conf
ddns-update-style interim;
allow booting; #定义能够PXE启动
allow bootp; #定义支持bootp
next-server 192.168.0.1; #TFTP Server的IP地址
filename "pxelinux.0"; #bootstrap 文件(NBP)
ping-check true;
default-lease-time 1800;
max-lease-time 7200;
option domain-name-servers 192.168.0.1;
subnet 192.168.0.0 netmask 255.255.255.0
{
range 192.168.0.128 192.168.0.220;
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
}
启动DHCP服务
[root@localhost ~]# service dhcpd start
正在启动 dhcpd:
[root@localhost ~]# service dhcpd status
dhcpd (pid 2595) 正在运行...
[root@localhost ~]#
七、生成ks.cfg 文件
安装Kickstart
[root@localhost ~]# yum -y install system-config-kickstart
[TZ@localhost 桌面]$ sudo su - root
[root@localhost ~]# yum -y install system-config-kickstart
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package system-config-kickstart-2.8.6.5-1.el6.noarch already installed and latest version
Nothing to do
[root@localhost ~]#
在桌面环境下配置Kickstart
生成ks.cfg 文件,保存在/var/www/html/ 文件夹下
可以打开/var/www/html/ks.cfg 文件进行查看并进行修改
[TZ@localhost 桌面]$ sudo gedit /var/www/html/ks.cfg
platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=http://192.168.0.1/cdrom/
# Root password
rootpw --iscrypted $1$zqY6f769$q0FMjKGSjK4J81Q3/Vims/
# 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
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --size=8000
part /boot --fstype="ext4" --size=8000
part swap --fstype="ext4" --size=8000
part /data --fstype="ext4" --size=1
%packages
@basic-desktop
@chinese-support
@debugging
@desktop-debugging
@desktop-platform
@development
@fonts
@general-desktop
@graphical-admin-tools
@graphics
@input-methods
@internet-applications
@internet-browser
@kde-desktop
@legacy-x
@network-tools
@office-suite
@performance
@print-client
@remote-desktop-clients
@security-tools
@system-admin-tools
@system-management
@web-server
@web-servlet
@x11
crypto-utils
%end
八、测试安装
本文出自 “DOSOM” 博客,谢绝转载!