Kickstart

詳見: RED HAT - KICKSTART INSTALLATIONS



 

how do you perform a kickstart installation?

若要使用 Kickstart 安裝方式,你必須:

 1. 建立一個 Kickstart 檔案

 2. 將 Kickstart 放置在一個可用的卸除式媒介、硬碟或是網路位置上

 3. 建立開機媒介(boot media),這將會被使用來起始安裝程序

 4. 準備好安裝來源

 5. 開始進行 Kickstart 安裝
 

creating a kickstart file

The kickstart file is a simple text file, containing a list of items, each identified by a keyword.

其實在我們平常安裝作業系統之後,kickstart 也會存放在這 /root/anaconda-ks.cfg

當我們在建立一個 kickstart 檔案的時候,有幾件事請放在心上

  • section 之間是要按照順序的,而在 section 內的 item 則沒有此限制,除非另有說明
    1. Command section
    2. %packages section
    3. %pre, %post sections (這些section無順序要求,可加可不加)
  • %packages, %pre and %post 結尾的地方必須加上 %end。
  • item 為非必要的,你可以省略
  • 如果省略了一些 item,安裝程式將會提示使用者提供相關項目的回應,就像你平常安裝作業系統那樣
  • 以井字號(#)為起始的一行將會被視為是註解,並且將會被忽略

 

verifying the kickstart file

yum install pykickstart
ksvalidator /path/to/kickstart.ks

注意這支程式也有它的極限,它可以幫你檢查 syntax 是否正確,是否有 deprecated options
但是它沒辦法保證你的安裝一定會成功,並且它是不會驗證%pre, %post 以及 %packages 區段
 
 
Making the kickstart file/installation source available
Boot method Installation source
Full installation media (DVD or USB) The boot media itself
Minimal boot media (CD or USB) Full installation DVD ISO image or the installation tree extracted from this image, placed in a network location or on a hard drive
Network boot (PXE) Full installation DVD ISO image or the installation tree extracted from this image, placed in a network location

Kickstart installations can be performed using a local CD-ROM, a local hard drive, or via NFS, FTP, or HTTP

 

kickstart commands and options

這邊僅列出 required 必要的選項
詳見:Kickstart Commands and Options
 


 
Command section

▨ bootloader

Specifies how the boot loader should be installed

 
▨ keyboard
Sets one or more available keyboard layouts for the system

 
▨ lang
Sets the language to use during installation and the default language to use on the installed system

 
▨ part
Creates a partition on the system
Red Hat recommends that you create the following partitions on AMD64 and Intel 64 systems:
 ‧ /boot partition - recommended size at least 500 MB
 ‧ / partition - recommended size of 10 GB
 ‧ /home partition - recommended size at least 1 GB
 ‧ swap partition - recommended size at least 1 GB

 
▨ rootpw
Sets the system's root password to the password argument

 
▨ timezone
Sets the system time zone to timezone

 

 
%packages

describes the software packages to be installed.

You can specify packages by environment, group, or by their package names

想知道一個 group 裡面包含哪些 package 嗎?
http://*/repodata/*-x86_64-comps.xml
 
例子:

%packages
@base
@core
sqlite
curl
aspell
docbook*
-autofs
-ipa*fonts
%end

 
或是像這樣指定一個外部清單
%include /home/ricky-dev-ks/add_pkg_list.txt
%include http://140.92.26.52/mirror/cake-specific-centos7-other/add_pkg_list.txt

 

 
%pre

%pre --interpreter=/usr/bin/python
--- Python script omitted --
%end

Unlike the post-installation script, the pre-installation script is not run in the chroot environment

 


 
%post

%pre --interpreter=/usr/bin/python
--- Python script omitted --
%end

 

installing into a disk image

Automatic disk image installation

  • Overview of livemedia-creator
  • Installing livemedia-creator
  • Sample kickstart files
  • Creating custom image

 


 
Overview of livemedia-creator

通常有兩個階段,
 ‧ 第一階段藉由 Anaconda 根據 kickstart file 裡面的參數設定,在 temporary disk image 上安裝系統
 ‧ 第二階段藉由 livemedia-creator 使用這個 temporary 建立一個最終、可開機的映像檔 (bootable image)
 


 
Installing livemedia-creator

yum install lorax
# additional packages (not dependent)
yum install virt-install libvirt qemu-kvm libvirt-client virsh anaconda

 

 
Sample kickstart files

稍微整理了一下,如下

CentOS sig-core-livemedia (produce CentOS LiveCD/DVD)

Scientific Linux Live CD and DVD

Fedora – How to create and use a Live CD

或是

位於目錄 /usr/share/doc/lorax-version/

  • rhel7-minimal.ks
  • rhel7-livemedia.ks

 


 
Creating custom image

使用 Anaconda 建立自訂映像檔前,將 SELinux 設定為「permissive」(或「disabled」)模式。

vim /etc/sysconfig/selinux

 
livecd-creator --config=/path/to/kickstart.ks --fslabel=Target.iso

 

 

- TBD -
 
 

create own package groups

you need to generate a new hdlist.

This is done by running a command that comes with anaconda-runtime called genhdlist.

You also need to edit the comps file.

The comps file is the file that lists all the packages that should get installed based on a particular profile.

For example, when you do an interactive install and select Networked Workstation, that is a package group listed in the comps file.

If you want to create your own package groups or make some new packages part of an existing package group then you would list those packages in the comps file.

The comps file is located in the base directory.
 

TBD

TBD - boot options

 

TBD

echo PREFERRED=icewm » /etc/sysconfig/desktop
 

附錄一 流程

以下是我開始製作kickstart的詳細過程
 


 
首先,一開始的ks是參考下面這個範例來的
CentOS sig-core-livemedia (produce CentOS LiveCD/DVD)

包含Command section,以及post section都是從這邊當參考再開始修改
 

Command section

主要修改了repo的路徑,改成自行架設的yum server,讓安裝套件時可以花較少的時間
 

Packages section

此外,為了確定系統升級後,CAKE總共裝了哪些套件
我們將範例ks產生出的iso,拿來跟系統升級後的CAKE作比較 (透過`yum list installed`)
把缺少的套件統整到一個清單並且在此階段加入

%include http://140.92.26.52/mirror/cake-specific-centos7/add_pkg_list.txt

將缺少的套件安裝起來

但有些額外的、或是上述方法無法找到的套件,則是透過新增一個cake-specific repo將剩下的套件裝齊
所以必須將所需的rpm先準備好 (http://140.92.26.52/mirror/cake-specific-centos7/)
 

Post section

當初利用pip所安裝的python套件(http://140.92.26.52/mirror/pyPackage/centos7-pypi/)
還有openvswitch套件,則在此階段安裝

此外,下載了一些config檔 (http://140.92.26.52/mirror/rc/)

  • .screenrc
  • .tmux.conf
  • .vimrc

 

Post section (in no-chroot)

這邊主要是將gnome desktop改成icewm
並且修改grub.cfg
 

emit iso image
./1_build.sh

 
./2_iso.sh <NAME> <ISO>
除非特別註明,本頁內容採用以下授權方式: Creative Commons Attribution-ShareAlike 3.0 License