1) DHCP、TFTP 安装
yum install -y dhcp* tftp*
首先配置 tftp 服务:
vi /etc/xinetd.d/tftp
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
只需要把 disable = yes 改成 disable = no 即可。
配置dhcp
vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
next-server 192.168.188.21; #Kickstart服务器地址
filename "pxelinux.0";
allow booting;
allow bootp;
subnet 192.168.188.1 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.188.1;
option subnet-mask 255.255.255.0;
# option nis-domain "domain.org";
# option domain-name "192.168.188.10";
# option domain-name-servers 192.168.188.11;
# option ntp-servers 192.168.188.1;
# option netbios-name-servers 192.168.188.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 192.168.188.100 192.168.188.200;
host ns {
hardware ethernet 00:1a:a0:2b:38:81;
fixed-address 192.168.188.101;}
}
TFTP+PXE 配置
要实现远程安装系统, 首先需要在TFTPBOOT目录指定相关PXE内核模块及相关参数。配置步骤如下:
#如果是5.x系统tftpboot目录已经自动创建到/下
#如果6.x系统tftpboot目录在/var/lib下,所以centos6.x需要做软链接到/下
ln -s /var/lib/tftpboot /
挂载光盘 mount /dev/cdrom /mnt
复制3个引导文件到/tftpboot
cd /tftpboot
cp /usr/share/syslinux/pxelinux.0 .
#如果找不到pxelinux.0
#请安装yum install syslinux -y
cp /mnt/images/pxeboot/vmlinuz .
cp /mnt/images/pxeboot/initrd.img .
mkdir pxelinux.cfg
#拷贝 isolinux.cfg 配置文件重命名, 系统安装的时候会根据这个文件的配置启动相应的选项。
cp /mnt/isolinux/isolinux.cfg default
chmod 777 default
修改 pexlinux.cfg/default 内容如下:
default linux
prompt 1
timeout 10
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinu
#ks=nfs:192.168.1.21:/data/centos/ks.cfg 必须存在
append ks=nfs:192.168.1.21:/data/centos/ks.cfg ksdevice=eth0 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 –
cd /data
mkdir centos
cd centos
nohup cp -rf /mnt/* .
cp /root/anaconda-ks.cfg ks.cfg
vim ks.cfg内容如下
install
text
nfs --server=192.168.188.21 --dir=/data/centos
key --skip
lang zh_CN.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw 000000
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
clearpart --all --initlabel
part /boot --fstype=ext4 --size=200
part / --fstype=ext4 --size=6000
part swap --size=4000
part /data --fstype=ext4 --grow --size=200
#repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
reboot
%packages
@chinese-support
@core
@server-policy
@workstation-policy
%end
把/data/centos共享出来
vim /etc/exports
/data/centos *(rw,sync)
重启dhcp xinetd ntp