一、kickstart脚本作用
当安装Linux操作系统时,安装过程会需要回答很多关于设定的问题。这些问题必须手动选择,否则无法进行安装。当安装多台Linux,这些设定需要重复多次,效率很低。
我们用一个文件来记录所有安装过程中问题的答案,并让所有需要安装的主机自动读取,提高安装效率。这个文件叫kickstart脚本。
二、实验前提
火墙 selinux关闭,httpd服务开启,配置软件仓库能正常工作
三、共享资源和文件模板
1.共享文件
dnf install httpd -y
systemctl enable --now httpd
systemctl disable --now firewalld
setenforce 0 ##selinux调整为警告模式
mkdir /var/www/html/westos
mount /iso/rhel-8.2-x86_64-dvd.iso /var/www/html/westos
2.复制模板
cp /root/anaconda-ks.cfg /var/www/html/westos.cfg
chmod 644 /var/www/html/westos.cfg
四、修改脚本
vim /var/www/html/westos.cfg
#version=RHEL8
#ignoredisk --only-use=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel ##把sda硬盘的所有内容删掉
# Reboot after installation
reboot
# Use graphical install
#graphical ##安装过程开启图形
text ##安装过程不开图形
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us' ##键盘布局为美式键盘
# System language
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8 ##系统支持的语言
# Network information
network --bootproto=dhcp --onboot=on
repo --name="AppStream" --baseurl=http://172.25.254.44/westos/AppStream ##软件安装资源
# Use network installation
url --url="http://172.25.254.44/westos" ##系统安装资源
# Root password
rootpw --iscrypted ##超级用户密码 $6$iA8BEMxp3UGo7L73$elGvXDf8yZfvrzhlZPY6KeFpkPBAvyBOH306.k7oUQWl2pb9nO4zJ9ayj.obVnJDPVvKFyMavgcz13wtwbrAK1
# X Window System configuration information
xconfig --startxonboot ##安装完成后开机启动图形
firstboot --disable ##首次启动初始化禁止
# System services
#services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai ##选择时区
# Disk partitioning information
part / --fstype="xfs" --size=1 --grow ##让/分区使用全部空闲磁盘空间
part swap --fstype="swap" --size=500 ##swap分区大小为500M
part /boot --fstype="xfs" --size=500 ##/boot分区大小为500M
%packages
@^graphical-server-environment
ibus-libpinyin.x86_64
%end
测试:
安装虚拟机系统界面
Install Red Hat Enterprise Linux 8.0.0 <---- <TAB>键
ks=http://172.25.254.44/westos.cfg <----<ENTER>键
开始安装。