Linux修炼之旅第七章!
本章顺着上一次的博客接着来学习Linux的新知识,介绍了kickstart自动安装脚本。
下面就开始吧
一、kickstart自动安装脚本的作用
当安装Linux操作系统时,安装过程会需要回答很多关于设定的问题
这些问题必须手动选择,否则无法进行安装
当只安装1台Linux系统,手动选择设定工作量比较轻松
当安装多台Linux,这些设定需要重复多次,这些重复动作是效率底下的操作
kickstart自动安装脚本就可以解决这个问题
用文件来记录所有安装过程中问题的答案,并让所有需要安装的主机自动读取
二、kickstart自动安装脚本的制作
1.环境搭建
做好实验前的准备
dnf install httpd -y
systemctl enable --now httpd
systemctl disable --now firewalld
2.在nodea主机中配置
模拟anaconda-ks.cfg配置属于自己的cfg文件,取名为westos.cfg
systemctl enable --now httpd
dnf install httpd -y
systemctl enable --now httpd
systemctl disable --now firewalld
cd
cp anaconda-ks.cfg /var/www/html/westos.cfg
ll /var/www/html/westos.cfg
chmod 644 /var/www/html/westos.cfg
将westos.cfg编辑为
#version=RHEL8
#ignoredisk --only-use=vda
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
text
# Use CDROM installation media
url --url=http://172.25.254.26/source
# 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 --ipv6=auto --no-activate
#network --hostname=westoslinux.westos.org
repo --name="AppStream" --baseurl=http://172.25.254.26/source/AppStream
# Root password
rootpw --iscrypted $6$JFxUdX0HAQvpxAy5$yWsZV.HbTYZV4kx9lG4odyZfbwQ13d1JGx/XmotL2F1NRMEFey9mHJY1ed5bd.FIG4QgvvS04rYnZrOBMlDKW.
# Run the Setup Agent on first boot
firstboot --disable
# Do not configure the X Window System
skipx
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
#user --name=westos --password=$6$YAe.8sw6vifDVnKA$3Og7IGTQft5nntRNgMLm0SFntVgYeF/0rU5ui54uKdAAlPv0YI3knIR41Zwvlcjli4j4vVpGVyN2YOzsLsFS91 --iscrypted --gecos="westos"
# Disk partitioning information
part / --fstype="xfs" --size=1 --grow
part swap --fstype="swap" --size=2048
part /boot --fstype="xfs" --size=1024
%packages
@base
lftp
%end
%post
touch /mnt/wesos{1..10}
%end
3.测试
在主机中打开虚拟机软件
新建虚拟机时选择Network install
然后再Provide the operating system install URL中输入本主机搭配好的网络仓库的地址
http://172.25.254.26/source
在下面的Kernel options中填入刚刚写好的配置文件路径
ks= http://172.25.254.126/westos.cfg
在下面选择系统的版本,我们用的市rhel8.2的镜像,所以选8.2
然后就可以开始安装了
安装过程中不需要手动调整任何东西,可以自动安装