kickstart文件示例(CentOS6+CentOS7)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nplbnb12/article/details/81075513

本文简单介绍centos-6中kickstart文件中的有用部分,centos-7版本的大同小异,并附上centos-6和centos-7的kickstart文件示例,都是测试过的,拿来修改下就可以用。

kickstart文件简析

文件由三部分组成:
1.选项指令段,用于应答图形界面安装时除包选择外的所有手动操作
2.package选择段,使用%package引导该功能
3.脚本段,可有可无,分为%pre和%post,前者是预安装脚本,后者是系统安装完成后脚本

指令段说明:
1.验证选项,启用shadow文件验证,使用sha512算法
authconfig --enableshadow --passalgo=sha512
2.指定引导程序位置,默认mbr,指定grub安装在哪个分区,指定内核参数
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
3.指定语言,指定使用美式键盘,设定时区
lang en_US.UTF-8
keyboard us
timezone Asia/Shanghai
4.设置root密码,--iscrypted是可选加密项,后面必须跟已经加密过的密码,centos6上可以使用grub-crypt --sha-512生成
rootpw  --iscrypted $6$hfb25YOYZDU3YZTl$VxTkHGGJGGBbr59OPnY5kTJzvJ9hb9NRwrh5FMHLIAlXh9VQ74PYoK7QzPWYN0zaJrm3mv/IP0fDkHxFglNi6/
下面的是可选项:
5.设置selinux
selinux=disabled
6.设置使用文本模式(默认是graphical模式),根据kickstart进行安装,
text
7.设置安装完成后重启,默认halt
reboot
8.指定安装或者升级,对于指定安装,必须指定cdrom、harddirve、nfs、url几种安装方式之一
install
url --url ftp://192.168.11.19/iso1
9.配置网络信息,并激活网络设备,可以多次使用network命令
示例1:
network --onboot yes --device eth0 --bootproto dhcp --noipv6
示例2:
        network --bootproto=static --ip=192.168.100.2 --netmask=255.255.255.0 --gateway=192.168.100.254 --nameserver=8.8.8.8
        network --bootproto=dhcp --device=eth0 --noipv6
        network --hostname=node1.xuexi.com
10.清除磁盘mbr、清除分区、创建分区
zerombr             
clearpart --all
part
        
11.开启ssh服务
firewall --service=ssh

# kickstart软件包或包组选项:

使用"%packages"表示该段内容,@表示选择的包组,最前面使用横杠表示取反,即不选择的包或包组。
@base和@core两个包组总是被默认选择,所以不必在%packages中指定它们

CentOS-6 kickstart示例

#version=DEVEL
install
text
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  newpassword
firewall --service=ssh
url --url=http://192.168.11.19/iso1
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
zerombr
clearpart --all
reboot
part /boot --fstype=ext4 --size=400
part swap  --size=4000
part / --fstype=ext4 --grow --size=200

%packages --nobase
@core
%post
%end

CentOS-7 kickstart示例

#version=DEVEL
install
auth --enableshadow --passalgo=sha512
text
lang en_US.UTF-8
keyboard --vckeymap=us --xlayouts='us'
network --onboot=on --device=ens33  --bootproto=dhcp --activate --ipv6=auto
rootpw newpassword
firewall --service=ssh
url --url=http://192.168.11.100/yum
selinux --disabled
timezone Asia/Shanghai --isUtc
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto"
zerombr
clearpart --none --initlabel
reboot
part /boot --fstype=ext4 --ondisk=sda --size=400
part swap  --ondisk=sda --size=4000
part / --fstype=ext4 --ondisk=sda --grow --size=200

%packages
@^minimal
@core
%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

猜你喜欢

转载自blog.csdn.net/nplbnb12/article/details/81075513