7.Linux中的无人职守安装脚本kickstart

 

在企业中安装多台操作系统时面临的问题

当安装Linux操作系统时,安装过程会需要回答很多关于设定的问题
这些问题必须手动选择,否则无法进行安装
当只安装1台Linux系统,手动选择设定工作量比较轻松
当安装多台Linux,这些设定需要重复多次,这些重复动作是效率底下的操作

如何解决以上问题

用文件来记录所有安装过程中问题的答案,并让所有需要安装的主机自动读取

kickstart作用

以上解决方案中记录系统安装过程中所有问题答案的文件叫kickstart脚本

二.实验环境
1.主机名称: westos_nodea
2.ip: 172.25.254.73
3.火墙,selinux关闭
4.httpd服务开启
5.配置软件仓库能正常工作

三.kickstart自动安装脚本的制作

在rhel7系统中提供图形的kickstart制作方式
在rhel8中已经把图形的工具取消,并添加到rhn网络中
在rhel8中如果无法通过rhn网络制作kickstart,可以使用模板生成

通过模板生成kickstart文件

在已经装好的rhel8中,/root/anaconda-ks.cfg 就是安装当前系统时回答的所有问题的答案
生成的kickstart,此文件为kickstart模板

操作步骤:

软件网络仓库配好之后

dnf install  dhcp-server -y

rpm -qc  dhcp-server

cat  /etc/dhcp/dhcpd.conf

cp  /usr/share/doc/dhcp-server/dhcpd.conf.example   /etc/dhcp/dhcpd.conf

vim /etc/dhcp/dhcpd.conf

编辑内容为:

# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
option domain-name "westos.org";
option domain-name-servers 114.114.114.114;

default-lease-time 600;
max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet,: but declaring it helps the
# DHCP server to understand the network topology.

# subnet 10.152.187.0 netmask 255.255.255.0 {
#}      注释

# This is a very basic subnet declaration.

subnet 172.25.254.0 netmask 255.255.255.0 {
  range 172.25.254.100 172.25.254.200;
  option routers 172.25.254.73;
}

systemctl enable --now dhcpd

systemctl status dhcpd

cd /root

 vim  /root/anaconda-ks.cfg

编辑内容:

#version=RHEL8
# ignoredisk --only-use=sda,sdb
# Partition clearing information
clearpart --all --initlabel
# 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 --ipv6=auto --no-activate
network  --hostname=westoslinux.westos.org

repo --name="AppStream" --baseurl=http://172.25.254.73/grr/AppStream
# Use network installation
url --url="http://172.25.254.73/grr"
# Root password
rootpw --iscrypted $6$iA6/aztHWD3D.lnh$mDfHzq4b5/EuUHoUfX41OGOq6C.5tsix4OiGXqQVqy.f5RPobTY7x6UcIk21W6sLD3q01CD/XA4LgPwK8r5aT.

# X Window System configuration information
# xconfig  --startxonboot
firstboot --disable
skipx
# System services
 services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# Disk partitioning information
part swap --fstype="swap" --size=500
part / --fstype="xfs" --size=1 --grow
part /boot --fstype="xfs" --size=1024


%packages
@base
gcc


%end

%post
touch  /mnt/file{1..10}
%end

mkdir  /var/www/html/ks/

cp /root/anaconda-ks.cfg /var/www/html/ks/westos.ks

ls  /var/www/html/ks/

vim /var/www/html/ks/westos.ks     检查一遍

ll    /var/www/html/ks/westos.ks

chmod   644   /var/www/html/ks/westos.ks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值