kickstart简单使用说明

 

一、什么是kickstart

二、kickstart文件组成

三、安装方法

四、图形化程序编辑kickstart配置(kickstart文件包含截图中所注明的相关配置)

 

 

一、什么是kickstart

 

    kickstart是一个定义了Linux安装过程的配置文件,比如要在系统中使用的时区、如何对驱动器进行分区、或者应该安装哪些软件包。有了这个文件可以解放双手,让Linux安装过程按照我们预先定义的要求进行自动化安装,同时部署大量主机时十分有用。一般centos系统安装后,会在root目录下生成一个名为anaconda-ks.cfg的kickstart配置文件。

 

1、一个简单的kickstart文件内容

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --enabled --service=ssh
# Install OS instead of upgrade
install
# Use network installation
url --url="ftp://10.1.1.112/pub/centos6.5"
repo --name="CentOS" --baseurl=ftp://10.1.1.112/pub/centos6.5
# Root password
rootpw --iscrypted $1$xeWzG1j.$0BShQNl1hglHb7I.06ziC.
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# Network information
network  --bootproto=static --device=eth0 --gateway=10.1.1.1 --ip=10.1.1.113 --nameserver=120.196.165.24 --netmask=255.255.255.0 --onboot=on
# System bootloader configuration
bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
#part /boot --fstype="ext4" --size=256
#part /usr --fstype="ext4" --size=1024
#part / --fstype="ext4" --size=5120
#part /home --fstype="ext4" --size=5120
#part swap --fstype="swap" --size=2048
clearpart --all --drives=sda

part /boot --fstype=ext4 --size=500
part pv.008002 --grow --size=1

volgroup vg_test3 --pesize=4096 pv.008002
logvol / --fstype=ext4 --name=lv_root --vgname=vg_test3 --grow --size=1024 --maxsize=51200
logvol swap --name=lv_swap --vgname=vg_test3 --grow --size=1984 --maxsize=1984

%packages --nobase
@core
%end

2、关于kickstart的详细信息、选项及参数,参考红帽官方文档https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-kickstart-syntax.html

二、kickstart文件组成

 

1、命令段:用于配置系统

    例如:

install
cdrom    #安装介质
lang zh_CN.UTF-8    #安装语言
keyboard us    #键盘类型
selinux --enforcing    #是否开启selinux
timezone --utc Asia/Shanghai    #时区、系统时钟是否使用UTC时间
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

2、软件包段:选择要安装的软件包组及软件包

    例如:

@core    #安装
@base    #安装
lftp    #安装
-zsh    #这里说明不安装,但如果有其他安装的文件需要依赖其时,也会安装

 

3、脚本段:

%pre    #安装过程开始之前执行的脚本;所能够执行的操作较少,因为是简洁版的shell环境;
%post    #所有软件包安装完成之后执行的脚本;由于是此时系统已安装完成,所以是完整的shell环境;

 

三、安装方法

当编辑好kickstart配置文件后,我们就可以利用它快速安装系统了。

在boot提示符指定本机的网络参数和kickstart配置文件,配置文件中又设定了安装源(一般我们自建了http、ftp服务器和yum源),执行下面的命令后,系统会自动结合kickstart文件,就能实现快速安装系统。

 

1、经过光盘引导后,在boot提示符下输入安装命令:

#boot:linux ip=10.1.1.106 netmask=255.255.255.0 gateway=10.1.1.1 dns=10.1.1.1 ks=http://10.1.1.100/centos6.5-x86_64.cfg

 

如何进入boot提示符,在下图界面中,敲击一下ESC键即可

p_w_picpath

p_w_picpath

 

2、指定kickstart配置文件对应格式如下:

kickstart资源           选项格式

CD                       ks=cdrom:/directory/ks.cfg

硬盘驱动器               ks=hd:device/directory/ks.cfg 

FTP服务器                ks=ftp://server.mydomain.com/directory/ks.cfg

HTTP服务器               ks=http://server.mydomain.com/directory/ks.cfg

HTTPS服务器              ks=https://server.mydomain.com/directory/ks.cfg

NFS服务器                ks=nfs:server.mydomain.com:/directory/ks.cfg

其它设备                 ks=file:/device/directory/ks.cfg

 

四、图形化程序编辑kickstart配置

    程序名称为 system-config-kickstart,我们可以利用它编辑kickstart文件。注意,该程序需要安装有图形化界面程序。

    使用yum install system-config-kickstart即可安装。

    程序配置界面,一个kickstart文件就包含了下图中相关配置信息。

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

p_w_picpath

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章