网络模式:NAT模式(共享主机的IP地址)
DHCP / TFTP IP:192.168.220.137
HTTP / FTP / NFS IP:192.168.220.137
环境搭建:
yum install -y tftp-server dhcp system-config-kickstart vsftp xinetd syslinux
1.挂载ISO文件然后把光盘中的文件拷贝至/var/ftp/pub中
mount /dev/cdrom /media/CentOS/
cp -Rf /media/CentOS/* /var/ftp/pub/
2. a.将initrd.img pxelinux.0 vmlinuz 拷贝至 /tftpboot目录中mkdir /tftpboot
chmod 777 -Rf /tfrpboot/
cp /media/CentOS/isolinux/initrd.img /tftpboot
cp /media/CentOS/isolinux/vmlinuz /tftpboot
cp /usr/share/syslinux/pxelinux.0 /tftpboot ##找到pxelinux.0 文件 (find / -name pxelinux.0)
b.将default文件放在/tftpboot/pxelinux.cfg/下
mkdir /tftpboot/pxelinux.cfg/
cp /var/ftp/pub/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
配置文件参数:
1.vi /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
subnet 192.168.220.0 netmask 255.255.255.0 {
allow booting;
allow bootp;
allow unknown-clients;
option routers 192.168.222.137;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.220.2;
option time-offset -18000; # Eastern Standard Time
# --- 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.220.140 192.168.220.150;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.220.137;
filename "pxelinux.0";
}
2.vi /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.vi /etc/vsftp/vsftpd.conf
无需改动
4.vi /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 30
label linux
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.220.137/ks.cfg
5.在桌面环境下配置Kickstart
启动X Windows 环境
startx
配置Kickstart
vim /var/ftp/ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="ftp://192.168.220.137/pub"
# Root password
rootpw --iscrypted $1$CpoBgXT7$AzEBGDew56m/vIUoIH7SU.
# 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/Chongqing
# 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=100
part swap --fstype="swap" --size=512
part / --fstype="ext4" --grow --size=1
%packages
@debugging
@legacy-unix
@network-file-system-client
@web-server
%end
测试:
servcei iptables stop
setenforce 0
service dhcpd start
service xinetd start
service vsftpd start
以上可完成PXE无人值守安装操作系统
错误:如果出现error downloading Kickstart file
解决:/var/ftp/ks.cfg 权限问题 或者 路径问题