RHEL5 Kickstart+PXE+dhcp+tftp
一.所需相关包:
Httpd
NFS-utils
Syslinux
System-config-kickstart
Tftp-server
二.配置 tftp
#chkconfig xinetd on
#vim /etc/xinetd.d/tftp
将 disable = yes 改成 disable = no
#mkdri /tftpbroot
#mkdir /tftpbroot/pxelinux.cfg
#mkdir /tftpbroot/rhel5
[root@server ~]# cat /tftpboot/boot.msg
RH401 PXE Menu
Choose a boot option from the list below:
install - kickstart RHEL5
rescue - Rescue
quit - abandon PXE and boot normally
[root@server ~]# cat /tftpboot/pxelinux.cfg/default
display boot.msg
prompt 1
timeout 600
default quit
label quit
localboot 0
label install
kernel rhel5/vmlinuz
append initrd=rhel5/initrd.img ks=http://10.10.10.1/ks.cfg
label rescue
kernel rhel5/vmlinuz
append rescue initrd=rhel5/initrd.img ks=http://10.10.10.1/ks.cfg
[root@server ~]# cp /mnt/rhel5/images/pxeboot/* /tftpboot/rhel5/
三. Kickstart 配置
[root@server ~]# cat /var/www/virtual/rhca/ks.cfg
#platform=x86, AMD64, or 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 text mode install
text
# Firewall configuration
firewall --enabled --ssh
# Run the Setup Agent on first boot
firstboot --disable
key --skip
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use NFS installation media
nfs --server=10.10.10.1 --dir=/mnt/rhel5
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$N7slsMWl$FxW6teLk6y6IaZKUhD1wb1
# SELinux configuration
selinux --permissive
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=512
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%post 这个是安装完后要执行的命令
mkdir /mnt/rhel5.2
cat >>/etc/fstab << EOF
10.10.10.1:/mnt/rhel5 /mnt/rhel5.2 nfs defaults 0 0
EOF
mount -a
cat >> /etc/yum.repos.d/rhel-debuginfo.repo << EOF
[NFS Server]
name=RHEL 5.2
baseurl=file:///mnt/rhel5/Server
enabled=1
gpgcheck=0
EOF
%packages
vim-enhanced 单独安装某个包
@gnome-desktop 安装某个组件包
以上配置可以使用图形工具 system-config-kickstart 来配置
注意将这个文件 ks.cfg 复制到 /var/www/virtual/rhca 目录下
四. http 配置
在 /etc/httpd/conf/httpd.conf 里添加以下内容
NameVirtualHost *:80
<VirtualHost *:80>
ServerName rhca.com
DocumentRoot /var/www/virtual/rhca
</VirtualHost>
#chkconfig httpd on
#/etc/init.d/httpd restart
五. Syslinux
#yum install syslinux –y
[root@server ~]# rpm -ql syslinux |grep pxe
/usr/lib/syslinux/pxelinux.0
/usr/share/doc/syslinux-3.11/pxelinux.doc
#cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
六 .DHCP 配置
#chkconfig dhcpd on
[root@server ~]# cat /etc/dhcpd.conf
authoritative;
ddns-update-style interim;
ignore client-updates;
subnet 10.10.10.0 netmask 255.255.255.0 {
# --- default gateway
option routers 10.10.10.1;
option subnet-mask 255.255.255.0;
option domain-name "rhca.com";
option domain-name-servers 10.10.10.1;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 10.10.10.100 10.10.10.200;
default-lease-time 600;
max-lease-time 3600;
next-server 10.10.10.1;
filename "pxelinux.0";
# # we want the nameserver to appear at a fixed address
# host ns {
# next-server marvin.redhat.com;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address 207.175.42.254;
# }
}
#/etc/init.d/dhcpd restart
七. NFS 配置
#chkconfig nfs on
#/etc/init.d/portmap restart
[root@server ~]# cat /etc/exports
/mnt/rhel5 10.10.10.*(ro,sync)
#/etc/init.d/nfs restart
八.收尾
将 RHEL5.ISO 镜像里的所有文件复制到 /mnt/rhel5 目录下
九 . 启动客户机,使其用网络启动。。