上一篇介绍了fedora无人值守安装,本文介绍redhat使用kickstart的方式进行安装。
镜像准备
从redhat官网下载ISO镜像(需要账号),与fedora大同小异,但是不需要自己准备Packages,镜像本身会自带
下载后将镜像文件解压到/var/www/html/redhat目录下
mkdir /var/www/html/redhat
mount /var/lib/tftpboot/rhel-baseos-9.1-x86_64-dvd.iso /mnt/
cp -ra /mnt/* /var/www/html/redhat
tftp内核准备
mkdir /var/lib/tftpboot/boot/
mkdir /var/lib/tftpboot/boot/redhat/
cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/boot/redhat/
cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/boot/redhat/
umount /mnt
grub文件准备
vi /var/lib/tftp/grub/grub.cfg
###
default=autoinstall
timeout=5
timeout_style=menu
d=autoinstall
menuentry 'redhat9_1 os ' --id=autoinstall {
echo 'loading redhat vmlinuz'
linux /boot/redha/vmlinuz inst.repo=http://xx.xx.xx.xx/redhat/ ip=dhcp inst.ks=http://xx.xx.xx.xx/autoinstall/redhat_serial.ks
echo 'loading initrd'
initrd /boot/redhat/initrd.img
}
}
###
ks文件准备
ks创建,与fedrora基本一样,可以根据实际情况修改成适合自己的
vi /var/www/html/autoinstall/redhat_serial.ks
#version=F32
# Use graphical install
graphical
# Keyboard layouts
keyboard --xlayouts='us (mac)','de (mac)'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=enp3s0 --ipv6=auto --activate
network --hostname=test
# X Window System configuration information
# xconfig --defaultdesktop GNOME --startxonboot
# System services
services --enabled=chronyd,sshd
clearpart --all
autopart
# System timezone
timezone Asia/Shanghai --isUtc --ntpservers=xx.xx.xx.xx
# User configuration
user --groups=wheel --name=test --password="test" --gecos="test"
# Root password
rootpw "test"
# SELinux is enabled, but only logs things that would be denied in enforcing mode.
# selinux --permissive
# No SELinux policy is loaded.
selinux --disabled
%packages
@^workstation-product-environment
smartmontools
evince # Document viewer
%end
%addon com_redhat_kdump --disable --reserve-mb='128'
%end
#%post --log=/mnt/sysimage/root/ks-post.log --interpreter=/usr/bin/sh --nochroot
%post --log=/root/ks-post.log
sed -i '6iAutomaticLoginEnable=true' /etc/gdm/custom.conf
sed -i '7iAutomaticLogin=test' /etc/gdm/custom.conf
echo -e "test ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
mount -o username=xxx,password=xxx,vers=2.0 //xx.xx.xx.xx/auto_test /mnt
cp -r /mnt/* /home/test/Desktop
%end
# Reboot After Installation
reboot --eject
最后需要在DHCP服务器内配置好tftp地址和bootfile名称,网络内电脑就可以通过pxe安装了。
本地源准备
redhat默认没有账号无法安装源,但是可以自定义repo指向镜像内的packages,就可以安装包内的工具,这部分也可以直接加进ks文件,实现自动化操作。
vi /etc/yum.repos.d/redhat_self.repo
[rhel9_base]
name=rhel9_base
baseurl=http://xx.xx.xx.xx/redhat/BaseOS/
enabled=1
gpgcheck=0
[rhel9_appstream]
name=rhel9_appstream
baseurl=http://xx.xx.xx.xx/redhat/AppStream/
enabled=1
gpgcheck=0
####
谢谢浏览。