1. DHCP服务器给需要安装的机器分发IP, 并指定ftp服务器地址和pxelinux.0
next-server 192.168.2.18;
filename "pxelinux.0";
2. 客户端连接到服务器,读取启动文件 /tftpboot/pxelinux.cfg/default
3. 根据default里面指定的ks.cfg文件的位置,打开KickStart配置文件,
4. 根据ks.cfg的ftp服务器的配置, 读取/var/ftp/pub/文件, 引导安装程序
service vsftpd status
service xinetd status
service dhcpd status
service vsftpd status
service xinetd status
service dhcpd status
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.2.0 netmask 255.255.255.0 {
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.2.1;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.2.60 192.168.2.100;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.2.18;
filename "pxelinux.0";
}
yum intall -y tftp*
tftp服务是xinetd的子服务.
[root@centos6-64 ftp]# cat /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
}
mkdir /tftpboot
mkdir /tftpboot/pxelinux.cfg
cp /usr/share/syslinux/pxelinux.0 /tftpboot/
挂载安装光盘的镜像,并拷贝以下文件:
cp /mnt/iso/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
cp /mnt/iso/images/pxeboot/initrd.img /tftpboot/
cp /mnt/iso/images/pxeboot/vmlinuz /tftpboot/
default linux
prompt 1
timeout 60
display boot.msg
label linux
kernel vmlinuz
append initrd=initrd.img text ks=ftp://192.168.2.18/ks.cfg
ks.cfg 是使用kickstart程序生成的文件.后面我们会使用KickStart生成它.
4.3.创建新的分区:
4.4.网络配置:
4.5.剩下的项目是关于防火墙,selinux的,看个人需求选择.
最后保存配置文件:
%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
@x11
mtools
pax
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
gnome-pilot
libXmu
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url=ftp://192.168.2.18/pub
# Root password
rootpw --iscrypted $1$YfhInJ/9$hqyxxL34AduJm0Zzfcl/F1
# System authorization information
auth --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
key --skip
# 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 /boot --fstype="ext4" --size=200
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=1
%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
@x11
mtools
pax
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
samba-winbind
certmonger
pam_krb5
krb5-workstation
gnome-pilot
libXmu
%end
cp ks.cfg /var/ftp/
total 8
-rw-r--r-- 1 root root 1419 Nov 20 17:58 ks.cfg
dr-xr-xr-x 7 root root 4096 Mar 6 2013 pub
total 676
-r--r--r-- 2 root root 14 Mar 6 2013 CentOS_BuildTag
dr-xr-xr-x 3 root root 2048 Mar 5 2013 EFI
-r--r--r-- 2 root root 212 Mar 3 2013 EULA
-r--r--r-- 2 root root 18009 Mar 3 2013 GPL
dr-xr-xr-x 3 root root 2048 Mar 5 2013 images
dr-xr-xr-x 2 root root 2048 Mar 5 2013 isolinux
dr-xr-xr-x 2 root root 649216 Mar 6 2013 Packages
-r--r--r-- 2 root root 1354 Mar 3 2013 RELEASE-NOTES-en-US.html
dr-xr-xr-x 2 root root 4096 Mar 6 2013 repodata
-r--r--r-- 2 root root 1706 Mar 3 2013 RPM-GPG-KEY-CentOS-6
-r--r--r-- 2 root root 1730 Mar 3 2013 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r-- 2 root root 1730 Mar 3 2013 RPM-GPG-KEY-CentOS-Security-6
-r--r--r-- 2 root root 1734 Mar 3 2013 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r-- 1 root root 3380 Mar 6 2013 TRANS.TBL
如果DHCP配置有问题,或PXE找不到安装文件的问题,
请查看/var/log/message 或仔细核对目录是否一致.
#注意如果KickStarts配置在虚拟机中,
虚拟机的网卡要设置为桥接(Bridged)模式.