上一篇介绍了ubuntu无人值守安装,本文介绍fedora使用kickstart的方式进行安装。
镜像准备
Fedora
从清华源下载操作系统iso文件;
准备repodata和packages,也可以从清华源下载,需要把2个文件夹全部下载下来(大概会有80G左右,推荐使用wget下载)
下载后将镜像文件解压到/var/www/html/fedora目录下
mkdir /var/www/html/fedora
mount /var/lib/tftpboot/Fedora-Workstation-Live-x86_64-37-1.7.iso /mnt/
cp -ra /mnt/* /var/www/html/fedora
把repodata和packages两个文件夹也放在/var/www/html/fedora目录下
tftp内核准备
mkdir /var/lib/tftpboot/boot/
mkdir /var/lib/tftpboot/boot/fedora/
cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/boot/fedora/
cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/boot/fedora/
umount /mnt
grub文件准备
vi /var/lib/tftp/grub/grub.cfg
###
default=autoinstall
timeout=5
timeout_style=menu
d=autoinstall
menuentry 'fedora ws 37' --class fedora --class gnu-linux --class gnu --class os --id=autoinstall {
echo 'loading frdora vmlinuz'
linux /boot/fedora/vmlinuz ip=dhcp inst.repo=http://xx.xx.xx.xx/fedora/ inst.ks=http://xx.xx.xx.xx/autoinstall/fedora_serial.ks
echo 'loading initrd'
initrd /boot/fedora/initrd.img
}
###
ks文件准备
网上有通用模板,可以根据实际需要进行定制化更改
vi /var/www/html/autoinstall/fedora_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
#应为前面下载了packages,这里可以直接添加需要安装的工具
#crontabs
%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
#如果有需要可以把系统内repo路径指向刚下载的packages的http路径,这样就实现了内网源的搭建0.0
%end
# Reboot After Installation
reboot --eject
最后需要在DHCP服务器内配置好tftp地址和bootfile名称,网络内电脑就可以通过pxe安装了。