Ubuntu Server 12.04下cobbler + dnsmasq +tftpd-hpa的安裝配置(四)

4、自定義 kickstart 文件linux

Kickstart最先是RedHat公司用來自動部署RedHat操做系統的,經過Kickstart配置文件,一般安裝過程當中須要交互輸入的信息就均可以自動應答。git

經過Kickstart安裝操做系統通常是這樣幾個步驟:ruby

Create a kickstart file.網絡

建立單一的kickstart文件app

Create a boot media with the kickstart file or make the kickstart file available on the network.eclipse

建立包含kickstart文件的啓動介質,或者使kickstart文件能夠經過網絡訪問ide

Make the installation tree available.post

準備所安裝操做系統,要包括完整的目錄樹ui

Start the kickstart installation.加密

開始kickstart安裝過程

Cobbler中默認的kickstart文件目錄爲,/var/lib/cobbler/kickstarts/,默認的Ks文件爲 /var/lib/cobbler/kickstarts/sample.ks。

1. 更改配置文件

修改配置文件

語法:

# cobbler profile edit --name <cobbler profile list 中顯示的名稱> --kickstart="/var/lib/cobbler/kickstarts/<新編輯好的ks文件名稱>"

查看已修改的配置文件

語法:

# cobbler profile getks --name <cobbler profile list 中顯示的名稱>

2. 自定義範例一

這裏以CentOS操做系統的kickstart文件爲例。

2.1 配置CentOS6.4的kickstart自動安裝腳本

一般安裝程序根據在安裝過程當中的選擇建立一個簡單的kickstart文件,這個文件會被寫入到 /root/anaconda-ks.cfg,因此咱們能夠在它的基礎上作修改便可。

2.1.1 CentOS6.4kickstart範例

文件路徑和文件名:/var/lib/cobbler/kickstarts/CentOS6.4_example.ks

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.88.253/cobbler/ks_mirror/CentOS-6.4-x86_64/"
# Root password
rootpw --iscrypted $1$6.5.pvtY$78zocSFzXqL6o2RiKy7Ow0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
#graphical
# Debug
#interactive
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Hong_Kong
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
network  --bootproto=dhcp --device=eth1 --onboot=on
network  --bootproto=dhcp --device=eth2 --onboot=on
network  --bootproto=dhcp --device=eth3 --onboot=on
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --linux --drives=sda
# Partition
part /boot --fstype=ext4 --size=500
part pv.008002 --grow --size=1
volgroup VolGroup --pesize=4096 pv.008002
logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
logvol swap --name=lv_swap --vgname=VolGroup --grow --size=4000 --maxsize=4000
%packages
@additional-devel
@base
@chinese-support
@compat-libraries
@console-internet
@desktop-platform-devel
@development
@eclipse
@fedora-packager
@internet-browser
@network-file-system-client
@network-tools
@perl-runtime
@ruby-runtime
@server-platform-devel
@storage-client-iscsi
bzr
cjkuni-fonts-ghostscript
ftp
git
iptraf
lftp
mercurial
mock
mutt
nmap
screen
rpmdevtools
wireshark
-ibus-table-cangjie
-ibus-table-erbi
-ibus-table-wubi
%end

2.1.2  配置cobbler CentOS6.4安裝時使用的kickstart文件

請按照步驟 1 更改配置文件 來操做。

2.1.3  關於用戶密碼的設置

咱們能夠經過在kickstart中引用以下語句來設置你的用戶密碼:

rootpw --iscrypted $1$6.5.pvtY$78zocSFzXqL6o2RiKy7Ow0

用戶密碼的加密能夠經過以下命令來生成:

# echo "Your password" | openssl passwd -1 -stdin

$1$YybbL2kO$Z35pIGEghtr7AQwUaH7GN1

也能夠在kickstart文件中直接引用cobbler變量 $default_password_crypted,以下:

# Root password

rootpw --iscrypted $default_password_crypted

配置default_password_crypted默認值:

能夠經過 配置 /etc/cobbler/settings 中 default_password_crypted爲新值。以下:

default_password_crypted: "$1$YybbL2kO$Z35pIGEghtr7AQwUaH7GN1"

2.1.4  安裝操做系統後修改下載源配置文件

2.1.4.1 添加cobbler安裝過程當中使用的安裝源

默認安裝程序不會修改CentOS的下載源配置文件。咱們能夠經過配置 /etc/cobbler/setting 中的 yum_post_install_mirror參數爲1。

而後在kickstart文件中%post部分添加以下的行:

# Start yum configuration

$yum_config_stanza

# End yum configuration

2.1.4.2 添加其它第三方安裝源

以添加mirror.163.com的源爲例,在kickstart文件中%post部分添加以下的行:

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS6-Base-163.repo

增長其它第三方的方法也相似

這樣cobbler源就會自動添加到新安裝好的操做系統中,文件路徑和文件名爲 /etc/yum.repos.d/cobbler-config.repo。

相關文章
相關標籤/搜索