centos 6.2 +PXE +httpd + system-config-kickstart 网络无人自动安装
注意:因为dhcpd 和tftp 的 某几个选项和配置文件在centos 5.x 和centos 6.x的版本有出入所以请慎重。
yum install tftp*
yum install dhcp*
yum install httpd*
yum install system-config-kickstart
-----------------------------------------------------------------------------------------------------------
复制配置文件:
创建TFTP文件夹:
mkdir -p /tftpboot
挂载光驱:
mount -t iso9660 /dev/cdrom /mnt/
复制光盘里的文件:
cp /mnt/image/pxeboot/ *
/tftpboot
复制光盘里的isolinux
cp /mnt/isolinux/*.msg /tftpboot
复制pxelinux.0
cp /usr/lib/system/pxelinux.0 /tftp
创建文件夹:
mkdir -p /tftpboot/pxelinux.cfg
复制配置文件:
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
dhcp配置文件:
# centos5.X 版本为/etc/dhcpd.conf
cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcpd/dhcpd.conf
复制光盘所有内容到/var/www/html #此地址可以更具httpd 主目录自行修改
cp -rf /mnt/* /var/www/html/
--------------------------------------------------------------------------------------------------------------
tftp 配置:
vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
# 注意此处tftp的路径,我们改成/tftpboot centos 6.0 默认位置不一样
disable = no
# 此处将yes 改成 no 开启tftp 服务
per_source = 11
cps = 100 2
flags = IPv4
}
重启服务:
service xinetd restart
-------------------------------------------------------------------------------------------------------------------
dhcpd 配置:
[root@dbs dhcp]#cd /etc/dhcpd # 注意配置文件的位置 5.x 在/etc/dhcpd.conf
[root@dbs dhcp]# vim dhcpd.conf
ddns-update-style none;
#改成 none
ignore client-updates;
next-server 192.168.1.155;
#dhcp服务器地址
filename "/pxelinux.0"; # 手动添加这行 否则不能启动安装
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option nis-domain "fantong.com";
option domain-name "fantong.com";
option domain-name-servers 192.168.1.254;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.1.180 192.168.1.188;
# 可分配地址空间
default-lease-time 21600;
max-lease-time 43200;
}
重启服务:
service dhcpd restart
-------------------------------------------------------------------------------------------------------------------
system-config-kickstart 配置:
[root@dbs /]system-config-kickstart
1 弹出kickstart的 自动应答文件配置器:根据需要 自行定制。里面有影响自动安装的地方。红色的这2个不能选择

2 : 安装方式的选择

3: 选择boot安装类型

4:分区部分

注意这个分区部分

swap 空间的分配

/ 根分区全部分配

网络配置部分:

校验部分(这部分最好什么都不要动)
selinux 和 iptables 的开启和关闭:

显示配置

安装包的选择:(开发工具 和 内核开发包尽量不要一起安装,容易产生错误)

安装前要执行的

安装后要执行的 (我安装完毕后添加一个user 用户)

配置完成 选择界面 file --- save --- 保存到httpd的主目录 。我的默认在/var/www/html/ 下 名称为ks.cfg

至此 system-config-kickstart 配置完成。
-------------------------------------------------------------------------------------------------------------------------------------
修改/tftpboot/pxelinux.cfg/default
vim /tftpboot/pxelinux.cfg/default
[root@dbs etc]# vim /tftpboot/pxelinux.cfg/default
#default text ks=http://192.168.1.155/ks.cfg
default vesamenu.c32
prompt 1
timeout 1
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.2!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img
append
ks=http://192.168.1.234
/ks.cfg initrd=initrd.img #修改这行添加ks的地址,添加之前确认地址能浏览到ks.cfg的内容
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
--------------------------------------------------------------------------------------------------------------------------------
test 客户端

正常启动安装开始。

使用一下ifconfig

至此 安装完成。
------------------------------------------------------------------------------------------------------------------------------------
贴出自己的ks.cfg 文件内容
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.1.234/"
# Root password
rootpw --iscrypted $1$3hKLu8iK$HwzgLtIn3F.Dh20C08ID71
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network --bootproto=static --device=eth0 --gateway=192.168.1.254 --ip=192.168.1.195 --nameserver=202.106.0.20 --netmask=255.255.255.0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=100
part swap --fstype="swap" --size=2000
part / --fstype="ext4" --grow --size=1
%post
useradd user1
%end
%packages
@base
@console-internet
@emacs
@technical-writing
@tex
%end
--------------------------------------------------------------------------------------------------