接下来准备ksdir目录下的安装引导文件ks#.cfg。ks#.cfg文件的获取方法有两种,一种是通过工具来生成。不过这个工具需要自己安装:
[ root@vinsent ~ ]#yum install -y system-config-kickstart
[ root@vinsent ~ ]#system-config-kickstart
另外这一种是复制/root目录下的anaconda-ks.cfg文件加以修改。我们选择后者。
[ root@vinsent html ]#cp /root/anaconda-ks.cfg ksdir/ks7.cfg
[ root@vinsent html ]#vim ksdir/ks7.cfg
....
[ root@vinsent html ]#chmod +r ksdir/ks7.cfg # "这里的文件需要加读权限,非常重要"
[ root@vinsent html ]#cat ksdir/ks7.cfg # centos 7的kickstart文件
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url= # 指明yum源的路径
# Use graphical install
text # 将cdrom修改为text,我们不是基于光盘安装的,我们是基于字符界面安装
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activate # --bootproto必须是dhcp获取,--onboot=on
network --hostname=centos7.magedu.com
# Root password
rootpw --iscrypted $6$Z7LBEUpwj3iQdYZ3$olYQ.Lj1xV2VAGS1UiNflKF0oMGip3b6tU9QFcp0i2JBjwKlY/Yaexul57NHpIJc.Y2V1hWAOueaqwjuWDGMk0
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
user --name=wang --password=$6$v.VphW/puRblcrFB$uaSrdEhGAwMXap27WIKTn5lyOOfoFyB/SNxyyL3og6s9/VQoAKoL2KQjKmeYFmoYTuYkSNL7BBxgbJzeryKr9. --iscrypted --gecos="wang"
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
zerombr # 添加zerombr ,表示清除旧磁盘上原有的mbr,新磁盘安装可不写
clearpart --all # 清除所有分区信息,新磁盘安装可不写
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=2048 # 分区表信息,如果你想添加分区,可按照该格式添加
part /app --fstype="xfs" --ondisk=sda --size=51200
part / --fstype="xfs" --ondisk=sda --size=51200
part /boot --fstype="xfs" --ondisk=sda --size=1024
reboot # 安装完成之后重启
%packages # 安装软件包
@^graphical-server-environment
@base
@core
@desktop-debugging
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11
kexec-tools
autofs # 安装autofs服务包
%end
%addon com_RedHat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end
%post # 安装后脚本,我们配置了yum源
systemctl enable autofs
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<eof
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
eof
%end
************下面是CentOS 6的kickstart文件*************
*******方法同上,这里你到别的主机上复制一份过来*******
[ root@vinsent html ]#cat ksdir/ks6.cfg
#version=DEVEL
install
text # 基于字符界面安装
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted $6$hfb25YOYZDU3YZTl$VxTkHGGJGGBbr59OPnY5kTJzvJ9hb9NRwrh5FMHLIAlXh9VQ74PYoK7QzPWYN0zaJrm3mv/IP0fDkHxFglNi6/
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
url --url= # yum源的路径
selinux --disabled # 关闭selinux
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
zerombr # 清除mbr
clearpart --all # 清除分区信息
reboot # 安装完成后重启
part /boot --fstype=ext4 --size=1000 # 分区信息
part / --fstype=ext4 --size=50000
part /app --fstype=ext4 --size=40000
part swap --size=2048
#repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 # 注释掉此行
%packages
@base
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@input-methods
@internet-applications
@internet-browser
@Java-platform
@kde-desktop
@legacy-x
@network-file-system-client
@office-suite
@print-client
@remote-desktop-clients
@server-platform
@server-policy
@workstation-policy
@x11
mtools
pax
Python-dmidecode
oddjob
wodim
sgpio
genisoimage
device-mapper-persistent-data
abrt-gui
qt-mysql
samba-winbind
certmonger
pam_krb5
krb5-workstation
xterm
xorg-x11-xdm
libXmu
rdesktop
%end
%post # 安装后脚本,安装完系统后向做什么配置,都可以写在%post...%end中间
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<eof
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
eof
%end
5.6准备内核文件菜单文件