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

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