蓝色:输入的命令部分
红色:修改的配置文件
1、挂载系统安装光盘到Kickstart服务器
[root@localhost ~]# mkdir /kickstart
[root@localhost ~]# mkdir /linuxinstall
[root@localhost ~]# mkdir /tftpboot
[root@localhost ~]# mkdir /tftpboot/pxelinux.cfg
[root@localhost /]# mount /dev/cdrom /linuxinstall
[root@localhost /]# vim /etc/fstab
......
/dev/cdrom /linuxinstall iso9660 defaults 0 0
......
2、设置yum仓库源
[root@localhost ~]# cp /etc/yum.repos.d/CentOS-Media.repo /etc/yum.repos.d/kickstart.repo
[root@localhost ~]# vim /etc/yum.repos.d/kickstart.repo
......
[kickstart]
name=CentOS-$releasever - Media
baseurl=file:///linuxinstall
gpgcheck=0
enabled=1
......
3、安装Kickstart需要的组件
[root@localhost ~]# yum install nfs* dhcp tftp* system-config-kickstart –y
4、设置nfs
[root@localhost ~]# vim /etc/exports
......
/linuxinstall *(ro,sync)
/kickstart *(ro,sync)
/tftpboot *(ro,sync)
......
[root@localhost /]# exportfs -rv
exporting *:/linuxinstall
exporting *:/kickstart
exporting *:/tftpboot
5、设置tftp
[root@localhost /]# vim /etc/xinetd.d/tftp
......
disable = no(yes改成no)
......
6、配置DHCP
[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
[root@localhost ~]# vim /etc/dhcpd.conf
......
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.159.0 netmask 255.255.255.0 {
option routers 192.168.159.2;
option subnet-mask 255.255.255.0;
next-server 192.168.159.10;
filename "pxelinux.0";
range dynamic-bootp 192.168.159.128 192.168.159.254;
default-lease-time 21600;
max-lease-time 43200;
}
......
7、配置ks.cfg文件
#platform=x86, AMD64, 或 Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use NFS installation media
nfs --server=192.168.159.10 --dir=/linuxinstall
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$9G/AkkmG$NtrFgqOQ4nAP.EUMXmxTP0
# SELinux configuration
selinux --enforcing
# Do not configure the X Window System
skipx
# System timezone
timezone America/New_York
# Install OS instead of upgrade
install
# Disk partitioning information
part / --bytes-per-inode=4096 --fstype="ext3" --size=6000
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=600
part swap --bytes-per-inode=4096 --fstype="swap" --size=1000
%packages
@base
@chinese-support
@core
@dialup
@editors
@gnome-desktop
@games
@graphical-internet
@graphics
@office
@printing
@sound-and-video
@text-internet
@base-x
keyutils
trousers
fipscheck
device-mapper-multipath
libsane-hpaio
xorg-x11-server-Xnest
8、配置支持pxe启动
[root@localhost ~]# cp ks.cfg /kickstart/
[root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
[root@localhost ~]# cp /linuxinstall/images/pxeboot/vmlinuz /tftpboot/
[root@localhost ~]# cp /linuxinstall/images/pxeboot/initrd.img /tftpboot/
[root@localhost ~]# cp /linuxinstall/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@localhost ~]# chmod a+r /tftpboot/pxelinux.cfg/default
[root@localhost ~]# vim /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 60
display boot.msg
label linux
kernel vmlinuz
append ks=nfs:192.168.159.10://kickstart/ks.cfg initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
9、启动服务
[root@localhost /]# service dhcpd restart
[root@localhost /]# chkconfig dhcpd on
[root@localhost /]# service nfs restart
[root@localhost /]# chkconfig nfs on
[root@localhost /]# service xinetd restart
[root@localhost /]# chkconfig xinetd on
10、测试