kickstart文件的组成部分:
命令段:用于配置系统
软件包:指定要安装的程序包及程序包组
%packages 标识
@Base:使用@指定包组
lftp:直接写程序包名
注意:软件包段每个软件包和包组每行只能写一个
注意:在程序包前加-,不安装相关包
%end :软件包结束
脚本段:
%pre:安装过程开始前的预备脚本
所能执行的操作较小,它是一个首先的环境,因为其是仅有简装版的shell环境
%post:所有的软件完成之后执行的脚本
此时,具有完整意义上的shell环境,但并非所有命令都安装,先确保所有的程序包已经安装
%end :结束
示例文件:
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Use text mode install
text
# Firewall configuration
firewall --disable
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
#url --url="http://172.16.65.222/cobbler/ks_mirror/centos6.5-x86-64/"
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
#network --bootproto=dhcp --device=eth0 --onboot=on
network --bootproto=static --device=eth0 --ip=172.16.65.111 --netmask=255.255.255.0 --gateway=172.16.65.1 --nameserver=8.8.8.8 --hostname=mycentos --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
key --skip
# Installation logging level
logging --level=info
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
#autopart
%include /tmp/partition.ks
%pre
#!/bin/sh
act_mem=`cat /proc/meminfo | grep MemTotal | awk '{printf("%d",$2/1024)}'`
cat >> /tmp/partition.ks << END
clearpart --all
part swap --bytes-per-inode=4096 --fstype="swap" --size=${act_mem}
part /boot --bytes-per-inode=4096 --asprimary --fstype="ext4" --size=200
part / --bytes-per-inode=4096 --fstype="ext4" --grow --size=1
END
%end
%packages
@base
@core
@chinese-support
@development
@ruby-runtime
git
ntp
lrzsz
%end
%post
ntpdate cn.pool.ntp.org
hwclock --systohc
chkconfig acpid off
chkconfig atd off
chkconfig autofs off
chkconfig bluetooth off
chkconfig cpuspeed off
chkconfig firstboot off
chkconfig gpm off
chkconfig haldaemon off
chkconfig hidd off
chkconfig ip6tables off
chkconfig iptables off
chkconfig isdn off
chkconfig messagebus off
chkconfig nfslock off
chkconfig pcscd off
chkconfig portmap off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig yum-updatesd off
chkconfig sendmail off
#cd /root
#wget http://172.16.65.222/cobbler/ks_mirror/config/autoip.sh
#sh /root/autoip.sh
%end