如何配置Kickstart脚本以便更好的安装系统


  我们都知道,kickstart可用来自动化安装Linux系统,比手动安装速度更快,但是为了更好的安装系统,需要对kickstart脚本进行配置,下面小编就给大家介绍下配置kickstart脚本的方法,一起来学习下吧。

  配置kickstart脚本的方法

  ###############################################################

  #

  # Sample Kickstart Configuration File

  #

  ###############################################################

  ###############################################################

  #

  # point to a local installation server, or use “cdrom”

  #

  ###############################################################

  url --url http://rha-server/pub/rhel5/

  #cdrom

  rootpw RedHat

  bootloader --location=mbr --password=redhat

  ###############################################################

  #

  # partitioning

  #

  ###############################################################

  zerombr yes

  clearpart --all --initlabel

  part /boot --fstype ext3 --size 128

  part / --fstype ext3 --size 1 --grow

  part swap --recommended

  ###############################################################

  #

  # network configuration

  # - the following is for the “recommended solution” outlined

  # in the Red Hat Academy Instructor‘s Guide

  #

  ###############################################################

  network --bootproto=dhcp --device=eth0

  firewall --disabled

  #network --bootproto=static --ip=192.168.0.254 --netmask=255.255.255.0

  --device=eth0

  #firewall --medium --http --port=https:tcp

  ###############################################################

  #

  # environment

  #

  ###############################################################

  lang zh_CN.UTF-8

  timezone Asia/Shanghai

  ###############################################################

  #

  # hardware

  #

  ###############################################################

  keyboard us

  xconfig --startxonboot

  ###############################################################

  # misc

  ###############################################################

  key --skip # skip install number

  authconfig --enableshadow --enablemd5

  reboot # reboot automatically when done

  install # instead of “upgrade”

  ###############################################################

  #

  # Software

  #

  ###############################################################

  %packages --resolvedeps

  @admin-tools

  @editors

  @text-internet

  @gnome-desktop

  @core

  @base

  @base-x

  @chinese-support

  @sound-and-video

  @graphical-internet

  emacs

  kexec-tools

  device-mapper-multipath

  xorg-x11-utils

  xorg-x11-server-Xnest

  -sysreport

  %post

  ###############################################################

  #

  # Post Script - the following script runs on the newly

  # installed machine, immediately after installation

  #

  ###############################################################

  echo “nameserver 192.168.0.254” 》》 /etc/resolv.conf

  rpm -ivh ftp://rha-server/rha/autoupdate/rha-base*.rpm

  #rpm -Fvh ftp://Kickstart.example.com/pub/9/i386/updates/*.rpm

  #curl http://rha-server/rha/xorg.conf 》 /etc/X11/xorg.conf

  #curl http://rha-server/rha/station.cfg | tar xvzf -

  for i in elvis blondie prince madonna; do

  useradd $i

  echo redhat | passwd --stdin $i

  done

  Kickstart 脚本设计

  Kickstart 脚本通常有三个不同的部分。

  :   命令部分

  :   软件包部分

  :   安装后脚本部分

  Anaconda 会忽略Kickstart 脚本中所有以“#”开始的行和空行。

  命令部分

  从文件的最开始直到出现以%packages 开始的行,这一部分都属于命令部分。命令行必须以可识别的关键字开始,并且所有与该关键字有关的参数都必须出现在同一行中。命令部分是用来指定安装程序需要的除软件选项外的所有标准信息。关键字在命令部分可以以任意次序出现。

  软件包部分(%packages)

  软件包部分是用来指定需要安装的软件。这部分从以%packages 开头的行开始,直到下

  一个以“%”字符开始的行为止。这一部分通常采用以下两种格式之一。

  :   @Component Name

  :   package-name

  第一种格式是用软件组来指定软件,在这里一定要注意正确拼写软件组名称,并注意大小写。

  第二种格式是用来指定要安装的软件包的具体名称。如果%packages 行包含额外的--resolvedeps 参数,那么也会安装解决相依性的软件包。

  安装后脚本部分(%post)

  后处理部分是在没有 Anaconda 安装程序参与下,执行所有新安装系统的机器的自定义过程。执行这部分内容与在新安装系统的机器的环境下运行 Bash Shell 脚本的效果是一样的。如果是网络安装,那么执行前面提到作为实例的脚本也可以激活网络配置。

  上面就是kickstart脚本配置的方法介绍了,可以知道,kickstart脚本主要分为三个部分,需要对命令、软件包、安装后脚本这三个部分进行处理。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3