RHEL85基于PXE和ks文件无人自动安装(实测正常)

VMware环境:VMware® Workstation 15 Pro
服务端:红帽8.5 内核:4.18.0-348.el8.x86_64,机器IP是静态手动配置。
服务器IP:192.168.18.122
注意把VMware的dhcp服务关闭
VMware装机截图:


1.安装dhcp、tftp-server、http这3个服务
yum install httpd* dhcp* tftp-server syslinux -y
syslinux包提供pxelinux.0文件
2.DHCP服务配置:
[root@rhel8 dhcp]# more dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.18.0 netmask 255.255.255.0 {
range 192.168.18.125 192.168.18.245;
option routers 192.168.18.2;
next-server 192.168.18.122; #找tftp
filename "pxelinux.0"; #指定预安装程序
}
3.配置http服务:
[root@rhel8 tftpboot]# cd /var/www/html/ #web发布目录
[root@rhel8 html]# ls
ks.cfg rhel8OS #ks文件和安装源
[root@rhel8 html]#
4.配置tftp服务:
把光盘目录isolinux的内核、初始化镜像文件等复制到TFTP:
cp -rp /var/www/html/rhel8OS/isolinux/* /var/lib/tftpboot/
[root@rhel8 tftpboot]# ls
boot.cat initrd.img ldlinux.c32 memtest rhel85 vesamenu.c32
boot.msg isolinux.bin libcom32.c32 pxelinux.0 splash.png vmlinuz
grub.conf isolinux.cfg libutil.c32 pxelinux.cfg TRANS.TBL
[root@rhel8 tftpboot]#
5.编辑引导菜单文件default:
[root@rhel8 dhcp]# cd /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg/
创建装机引导菜单文件default:cp -p /var/www/html/rhel8OS/isolinux/isolinux.cfg default

cat default:

点击查看default内容
default vesamenu.c32
timeout 30
display boot.msg
# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Red Hat Enterprise Linux 8.5
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none
# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none
# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none
# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none
# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none
# Help text
menu color help 0 #ffffffff #00000000 none
# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none
# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none
# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
menu tabmsg Press Tab for full configuration options on menu items.
menu separator # insert an empty line
menu separator # insert an empty line
label linux
  menu label ^Install Red Hat Enterprise Linux 8.5
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.repo=http://192.168.18.122/rhel8OS inst.ks=http://192.168.18.122/ks.cfg quiet
label check
  menu label Test this ^media & install Red Hat Enterprise Linux 8.5
  kernel vmlinuz
append initrd=initrd.img inst.repo=http://192.168.18.122/rhel8OS rd.live.check quiet
menu separator # insert an empty line
label rescue
  menu indent count 5
  menu label ^Rescue a Red Hat Enterprise Linux system
  text help
	If the system will not boot, this lets you access files
	and edit config files to try to get it booting again.
  endtext
  kernel vmlinuz
 append initrd=initrd.img inst.repo=http://192.168.18.122/rhel8OS inst.rescue quiet
menu separator # insert an empty line
label local
  menu label Boot from ^local drive
  localboot 0xffff
menu end

ks.cfg文件配置 :

点击查看文件内容
#version=RHEL8
# Use graphical install
graphical

repo --name="AppStream" --baseurl=http://192.168.18.122/rhel8OS/AppStream/
reboot
%packages
@^minimal-environment
@standard
kexec-tools

%end

# Keyboard layouts
keyboard --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=dhcp --device=ens160 --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Use network installation
url --url="http://192.168.18.122/rhel8OS/BaseOS/"

# Run the Setup Agent on first boot
firstboot --enable

ignoredisk --only-use=sda
#autopart

# Partition clearing information
clearpart --none --initlabel

# System timezone
timezone Asia/Shanghai --isUtc
auth --passalgo=sha512 --useshadow
#ignoredisk --only-use=sda
# System bootloader configuration
bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
#clearpart --none --initlabel
# Disk partitioning information 
#100G disk
part /boot/efi --fstype="efi" --ondisk=sda --size=500 --fsoptions="umask=0077,shortname=winnt"
part pv.5607 --fstype="lvmpv" --ondisk=sda --size=101399
part /boot --fstype="xfs" --ondisk=sda --size=500
volgroup rootvg --pesize=4096 pv.5607
logvol / --fstype="xfs" --size=10240 --name=root --vgname=rootvg
logvol /var --fstype="xfs" --size=10240 --name=var --vgname=rootvg
logvol /home --fstype="xfs" --size=10240 --name=home --vgname=rootvg
logvol swap --fstype="swap" --size=2000 --name=swap  --vgname=rootvg
selinux --disabled
firewall --enabled
# Root password
rootpw --iscrypted $6$jpk4NHQXAnqgyOPB$yvuTxqhhCZrWoVsE.V13cfdTpNfO4FyCRnILo0GietJF3/ENQ9JWtRAm4ZjQON5rsk0u62sxyMR/Mx4Kb.QVu1

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
posted @ 2022-07-10 21:31  笑傲运维  阅读(414)  评论(0编辑  收藏  举报