5,PXE 其实不是一个服务,而是需要客户机的主板支持,即支持网络启动,否则,接下来的实验皆无法进行
1.1安装DHCP服务器
rpm -ivh dhcp-3.0.5-23.el5_5.2.x86_64.rpm dhcp-devel-3.0.5-23.el5_5.2.x86_64.rpm
warning: dhcp-3.0.5-23.el5_5.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcp ########################################### [ 50%]
2:dhcp-devel ########################################### [100%]
1.2,更改DHCP配置文件
cd /etc/
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample .
修改 /etc/dhcpd.conf 文件,指定 IP 地址等信息。
在 '''/etc/dhcpd.conf''' 中增加 tftp-server 需要推送给客户端的启动文件(bootstrap):filename "pxelinux.0";因为 tftp 的默认目录是 /tftpboot,所以文件的绝对路径就是: /tftpboot/pxelinux.0";当然也可以指定为其它的路径。
另外需要指定 next-server 参数,告诉客户端在获取到 pxelinux.0 文件之后去哪里获取其余的启动文件:
配置文件更改如下:
ddns-update-style interim;
#ignore client-updates;
allow booting; #定义能够PXE启动
allow bootp; #定义支持bootp
next-server 192.168.0.247; #TFTP Server 地址
filename "pxelinux.0"; #pxelinux 启动文件位置
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
# option routers 192.168.0.1;
# option subnet-mask 255.255.255.0;
# option nis-domain "domain.org";
# option domain-name "domain.org";
option domain-name-servers 192.168.0.247;
option subnet-mask 255.255.255.0;
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 192.168.0.200 192.168.0.220; #这里的IP地址段根据机器的多少来增加和减少
default-lease-time 21600;
max-lease-time 43200;
# 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;
# }
}
1.3设置DHCP 服务
chkconfig dhcpd on
service dhcpd start
rpm -ivh tftp-server-0.49-2.x86_64.rpm
配置
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
启动
/etc/init.d/xinetd restart
2.1PXE引导配置(bootstrap)
cd /usr/lib/syslinux/
cp pxelinux.0 /tftpboot/
2.2用于网络启动的内核文件
cp images/pxeboot/{vmlinuz,initrd.img} /tftpboot/
cp isolinux/*.msg /tftpboot/
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
修改默认系统加载的配置文件
vim /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append ks=nfs:192.168.0.247:/mnt/install/ks.cfg initrd=initrd.img #指定ks.cfg安装文件
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 -
3.NFS 配置
mount -o loop /usr/local/src/rhel-server-5.6-x86_64-dvd.iso /media/
mkdir /mnt/install
cp -R /media/* /mnt/install/
3.2设置NFS
cat /etc/exports
/mnt/install * (ro,sync)
service portmap start
service nfs start
showmount -e localhost #检查共享
chkconfig --level 35 nfs on
4.1如果安装了图形界面,可以安装一下该服务,用来图形生成ks.cfg文件
没有安装的话,可以再/root/anaconda-ks.cfg 基础上进行更改
我的配置文件如下:
[root@stat install]# cat ks.cfg
# Kickstart file automatically generated by anaconda.
#for auto install linux
install
text
nfs --server=192.168.0.247 --dir=/mnt/install #系统安装文件
key --skip
lang en_US.UTF-8
keyboard us
# Installation logging level
logging --level=info
xconfig --startxonboot
network --bootproto=dhcp --device=eth0 --onboot=on
rootpw --iscrypted $1$Ftd5JARW$a8t5CIMF5rn9mmaRv7l9D1
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=hda --append="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
#clearpart --linux
clearpart --all --initlabel
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part / --bytes-per-inode=4096 --fstype="ext3" --size=50000
part swap --bytes-per-inode=4096 --fstype="swap" --size=4096
part /data --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%packages
@admin-tools
@base
@core
@development-libs
@development-tools
@editors
@gnome-desktop
@system-tools
@base-x
system-config-kickstart
kexec-tools
iscsi-initiator-utils
fipscheck
device-mapper-multipath
sgpio
python-dmidecode
imake
emacs
audit
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
6,从网卡启动 需要安装的机器