Linux kickstart自动安装脚本

  • rhel7中:
  1. yum install system-config-kickstart(rhel8中目前还没有)
  • 每个系统的家目录里面都有一个文件anaconda-ks.cfg用于自动安装。可以在rhel7中利用图形工具自动生成这些脚本。

Linux kickstart自动安装脚本_第1张图片

  1. system-config-kickstart 图形制作ks文件的工具
    Linux kickstart自动安装脚本_第2张图片
    Linux kickstart自动安装脚本_第3张图片
    Linux kickstart自动安装脚本_第4张图片
    Linux kickstart自动安装脚本_第5张图片
    Linux kickstart自动安装脚本_第6张图片
    Linux kickstart自动安装脚本_第7张图片
    Linux kickstart自动安装脚本_第8张图片
    Linux kickstart自动安装脚本_第9张图片
  • 其他选项默认即可
  • 设置完之后一定要左上角save,自己任意选个路径保存,会生成一个ks.cfg文件
    在这里插入图片描述
  1. vim ks.cfg
%packages
@base ##软件组
lftp ##软件包
%end
  • 输入的时候漏掉了%end,可以通过 ksvalidator ks.cfg检测文件语法
    Linux kickstart自动安装脚本_第10张图片
    在这里插入图片描述
  1. ksvalidator /mnt/ks.cfg (检测文件语法)
  2. 发布ks文件
yum install vsftpd -y
systemctl start vsftpd 
systemctl stop firewalld 
mkdir /var/ftp/ksfile
mv ks.cfg /var/ftp/ksfile 
##将ks文件移动到ksfile目录下
  1. 检测发布
  • firefox ftp://192.168.0.10/ksfile/ks.cfg
    Linux kickstart自动安装脚本_第11张图片
  1. 使用
  • 在安装界面按

  • 输入:ks=ftp://192.168.0.10/ksfile/ks.cfg

  • 回车

  • 进入到自动安装过程

  • Linux kickstart自动安装脚本_第12张图片

  • 注意:使用kickstart安装系统时环境中必须有dhcp服务器否则网络资源访问不到

  • 如何配置dhcp

  • 安装服务 yum install dhcp.x86_64 -y

  • cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf复制模版

  • vim /etc/dhcp/dhcpd.conf开始编辑配置文件

  1 # dhcpd.conf
  2 #
  3 # Sample configuration file for ISC dhcpd
  4 #
  5 
  6 # option definitions common to all supported networks...
  7 option domain-name "example.com";
  8 option domain-name-servers 114.114.114.114;
  9 
 10 default-lease-time 600;
 11 max-lease-time 7200;
 12 
 13 # Use this to enble / disable dynamic dns updates globally.
 14 #ddns-update-style none;
 15 
 16 # If this DHCP server is the official DHCP server for the local
 17 # network, the authoritative directive should be uncommented.
 18 #authoritative;
 19 
 20 # Use this to send dhcp log messages to a different log file (you also
 21 # have to hack syslog.conf to complete the redirection).
 22 log-facility local7;
 23 
 24 # No service will be given on this subnet, but declaring it helps the 
 25 # DHCP server to understand the network topology.
 26 
 27 
 28 
 29 # This is a very basic subnet declaration.
 30 
 31 subnet 192.168.1.0 netmask 255.255.255.0 {
 32   range 192.168.1.40 192.168.1.88;
 33   option routers 192.168.1.1;
 34 }

Linux kickstart自动安装脚本_第13张图片

  • systemctl restart dhcpd重启服务
  • systemctl status dhcpd查看服务状态

Linux kickstart自动安装脚本_第14张图片

  1. 使用网络资源安装系统
  • 通过ftp服务发布景象资源到网络
  • 访问网络镜像资源ftp://192.168.1.16/rhel8.0
  • 更改ks.cfg
  • vim ks.cfg
  • #cdrom ##注释使用光盘资源
  • url --url=“ftp://192.168.1.10/rhel8.0” ##使用网络资源
    Linux kickstart自动安装脚本_第15张图片
  • 在rhel8主机中:
dnf install vsftpd -y
systemctl start vsftpd 
systemctl stop firewalld 
  • vim /etc/vsftpd/vsftpd.conf 更改配置文件,因为rhel8中默认拒绝匿名用户访问,将NO改为YES
    Linux kickstart自动安装脚本_第16张图片
  • mkdir /var/ftp/rhel8.0
  • mount /dev/cdrom /var/ftp/rhel8.0将镜像挂载到此目录中
  • 注意:如果实验的时候ftp://192.168.1.10无法访问的话,看一下本机的firewalld和selinux是否开启,把他们关掉

你可能感兴趣的:(linux)