原因:全自动安装的需要从网络获取所有需要的所以需要搭建一个DHCP服务
原因:dhcp可以指向引导文件位置
默认是 tftp服务
配置选项:filename: 指明引导文件名称
next-server:提供引导文件的服务器IP地址
原因:安装包源位置;也可以使用ftp
原因:Kickstart位置;也可以使用httpd
1.dhcp配置IP --->指向PXE引导文件所在
2.PXE进行引导:
4.需要vmlinux和initrd等文件启动内核;
3.Kickstart安装策略文件
4.安装包文件
yum -y install dhcp tftp-server httpd vsftpd
#设为开机启动
centos7:
systemctl enable dhcpd.service tftp.socket httpd.service vsftpd.service
centos6:
chkconfig dhcpd tftp httpd vsftpd on
开启相应服务
#dhcp服务不能正常开启;因为配置文件是空的
centos7:
systemctl start dhcpd.service tftp.socket httpd.service vsftpd.service
centos6:
service dhcpd start
service httpd start
service xinet start
service vsftpd start
前提:为主机分配一个没有dhcp分配IP的网段;并配置ip地址
nmcli con delete Wired\ connection\ 1
nmcli con add type ethernet con-name con-eth1 ifname eth1 ipv4.method manual ipv4.addresses 192.168.255.16/24
编辑dhcp配置文件
#dhcp的配置文件/etc/dhcp/dhcpd.conf文件是空的;使用/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example 模板文件进行修改
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
subnet 192.168.255.0 netmask 255.255.255.0 {
range 192.168.255.20 192.168.255.100;
filename "pxelinux.0";
next-server 192.168.255.16;
}
systemctl start dhcpd
mkdir /var/www/html/centos{6,7}/
安装路径指向上个步骤的包源
url --url=http://…
mkdir /var/ftp/pub/ksdir/
touch ks6_mbr.cfg ks7_lvm.cfg ks7_mbr.cfg
centos7——LVM版本的ks文件
ksvalidator ks7_lvm.cfg 检查语法
vim /var/ftp/pub/ksdir/ks7_lvm.cfg
#以下是 /var/ftp/pub/ksdir/ks7_lvm.cfg修改后内容
#version=DEVEL
install
# System authorization information
auth --enableshadow --passalgo=sha512
# Use installation media
url --url=http://192.168.255.16/centos7/
# Use text install
text
#install after reboot
reboot
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$SHC.PoZeamLqg41i$LtQkG86MkRof9krJb4UKvY4dZ73.xh1MmqVD980d53o8H1QqwzDvMAyqRMRXcHMVIg9/lJxfcjyAMKk5StR090
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --name=li --password=$6$dyIUjt13suMegL3S$/t7e8jmqs.syNo/ydaP4hXu3F5RZgKLbB6r5juBE2tz.sMzZiE6Y3qhEjwvwxbK.VTK5yoizE0D8y4yZW.2Sv1 --iscrypted --gecos="li"
# X Window System configuration information
skipx
# System bootloader configuration
zerombr
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel
%packages
@base
@core
@dial-up
@directory-client
@fonts
@guest-agents
@multimedia
@network-file-system-client
@networkmanager-submodules
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end
%post
#yum
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo < /root/.ssh/authorized_keys <eth0
sed -r -i.bak '/^GRUB_CMDLINE_LINUX/s/"[[:space:]]*$/net.ifnames=0 "/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
%end
centos7——MBR分区版本的ks文件
ksvalidator ks7_mbr.cfg 检查此文件语法
#version=DEVEL
install
# System authorization information
auth --enableshadow --passalgo=sha512
# Use installation media
url --url=http://192.168.255.16/centos7/
# Use text install
text
reboot
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network --bootproto=dhcp --device=ens34 --ipv6=auto --activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$/BVcMpadhqgy0l4J$FQ1fqYddKm1zqjxEkXn3XctFXiJ2LLWnVfRPi1u1oF6Wx5ebfKwe.8W0wHfF7oxeqDLJbkJJYTnry7W9o/6KP/
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# X Window System configuration information
skipx
# System bootloader configuration
zerombr
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /app --fstype="xfs" --ondisk=sda --size=47683
part / --fstype="xfs" --ondisk=sda --size=47683
part /boot --fstype="xfs" --ondisk=sda --size=953
part swap --fstype="swap" --ondisk=sda --size=3814
skipx
%packages
@base
@core
@dial-up
@fonts
@guest-agents
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end
%post
#yum
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo < /root/.ssh/authorized_keys <eth0
sed -r -i.bak '/^GRUB_CMDLINE_LINUX/s/"[[:space:]]*$/net.ifnames=0 "/' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
%end
centos6——MBR分区版本的ks文件
ksvalidator ks6_mbr.cfg 检查此文件语法
#version=DEVEL
install
url --url=http://192.168.255.16/centos6/
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted $6$CxpwSUg0oCIQZX52$0yfD8CXU4Q.60uYDqSHWz5.1enxwnhrv9esPRYSix4U1cWoaN.hOpgSLqCd22yjRdEhAwwUdxAIbn.mxMn.kx/
firewall --disable
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# 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
zerombr
clearpart --all
reboot
text
part /boot --fstype=ext4 --size=1000
part / --fstype=ext4 --size=100000
part /app --fstype=ext4 --size=50000
part swap --size=2048
%packages
@base
@core
@fonts
@network-file-system-client
@remote-desktop-clients
@server-policy
@workstation-policy
%end
%post
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo < /root/.ssh/authorized_keys <
cp /var/www/html/centos7/isolinux/vmlinuz /var/www/html/centos7/isolinux/initrd.img /var/lib/tftpboot/centos7/
cp /var/www/html/centos6/isolinux/vmlinuz /var/www/html/centos6/isolinux/initrd.img /var/lib/tftpboot/centos6/
在PXE文件中指向步骤3内核文件位置 和步骤2 ks文件位置
pxe需要的文件在 syslinux文件中(centos7中)
在syslinux-nonlinux 包中(centos6)
yum -y install syslinux
#菜单风格和pxelinux
cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
菜单启动文件
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /var/www/html/centos6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
修改菜单启动文件
指向ks文件位置
vim /var/lib/tftpboot/pxelinux.cfg/default
文件内容
default menu.c32
#prompt 1
timeout 600
menu title Welcome to CentOS 6.9!
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 Install CentOS_7.3 ^LVM system
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=ftp://192.168.255.16/pub/ks7_lvm.cfg
label linux
menu label Install CentOS_7.3 ^MBR system
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=ftp://192.168.255.16/pub/ks7_mbr.cfg
label linux
menu label Install CentOS_6.9 ^MBR system
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=ftp://192.168.255.16/pub/ks6_mbr.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
filename "pxelinux.0";
next-server 192.168.255.16;
原因是:
在/var/ftp/pub/ 的ks文件需要 other有r权限
原因是:自动安装的ks文件的脚本中应该加上 install
前面的脚本已经改过了
但是:centos7还是有同样的错误提示!应该是ks文件的问题。
可是搞了很久,还是不行。