1 Pxe安装原理
无论安装什幺类型的操作系统,PXE的安装过程大致可以描述为以下几个步骤:
客户机从自己的PXE网卡启动,向本网络中的DHCP服务器索取IP ,客户机向本网络中的TFTP服务器索取bootstrap文件,客户机取得bootstrap文件后之执行该文件,根据bootstrap的执行结果,通过TFTP服务器加载内核和文件系统进入安装画面, 此时可以通过选择FTP,HTTP,NFS方式之一进行安装从这里我们不难得到实现PXE网络安装必需的4个要素
客户机的网卡必须为PXE网卡
网络中必须要有DHCP和TFTP服务器,当然这两个服务器可以是同一台物理主机,所安装的操作系统必须支持网络安装,即必须提供自己的bootstrap
必须要有FTP,HTTP,NFS至少一个服务器,当然也可以和DHCP和TFTP服务器同为一台物理主机
2 Pxe安装启动图例
3 软件包环境
[root@localhost iso]# rpm -qa|grep dhcp
dhcp-3.0.5-23.el5_6.4
[root@localhost iso]# rpm -qa|grep nfs
nfs-utils-1.0.9-42.el5
system-config-nfs-1.3.23-1.el5
nfs-utils-lib-1.0.8-7.6.el5
[root@localhost iso]# rpm -qa|grep tftp
tftp-0.49-2.el5.centos
tftp-server-0.49-2.el5.centos(务必安装)
采用yum方式安装
4 dhcp配置 指定安装端
[root@localhost ~]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename
"pxelinux.0";
--制定bootstrap文件,默认是tftp的主目录(/tftpboot)
subnet 192.168.15.0 netmask 255.255.255.0 {
# --- default gateway
option routers
192.168.15.101;
option subnet-mask
255.255.255.0;
option nis-domain
"domain.org";
option domain-name
"domain.org";
option domain-name-servers
192.168.15.101;
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.15.100 192.168.15.149;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
group pxe {
host centos5.4_text{
next-server 192.168.15.101;
--指明tftpserver的地址
hardware ethernet 00:0C:29:81:CE:8E; --此地址与客户端网卡地址保持一致,也可不分配IP和MAC地址
fixed-address 192.168.15.148;
}
}
}
未指定安装端
[root@localhost iso]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename
"pxelinux.0";
next-server 192.168.15.101;
subnet 192.168.15.0 netmask 255.255.255.0 {
ddns-update-style interim;
ignore client-updates;
filename
"pxelinux.0";
next-server 192.168.15.101;
subnet 192.168.15.0 netmask 255.255.255.0 {
# --- default gateway
option routers
192.168.15.101;
option subnet-mask
255.255.255.0;
option nis-domain
"domain.org";
option domain-name
"domain.org";
option domain-name-servers
192.168.15.101;
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.15.100 192.168.15.200;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
#
next-server 192.168.15.101;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 192.168.15.119;
}
}
注:next-server 192.168.15.101;要写在前面,不能在host ns 内,hardware Ethernet和fixed-address默认文件配置的,可不予理睬!安装完成后IP为( range dynamic-bootp 192.168.15.100 192.168.15.200)随机获得的IP地址。
5 Tftp配置
[root@localhost ~]# vi /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves filesusing 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
{
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
6 nfs配置
1) 编辑NFS服务器配置文件 /etc/exports,以允许其它机器通过NFS访问目录/madia/rhel4,文件内容如下:
#vi /etc/exports
/iso/ *(ro)
--镜像文件解压后放置此处
/tftpboot/
*(ro)
2) 重新启动NFS服务以使新配置生效
# service portmap restart
# service nfs restart
7 制作linux内核、跟文件系统
将/usr/lib/syslinux/下的启动镜像文件pxelinux.0拷到TFTP服务器/tftpboot/ 下
#cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
将/isolinux/下的isolinux.cfg复制到TFTP服务/tftpboot/pxelinux.cfg/下:
#cp /media/rhel4/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
将/isolinux/下的所有名为.msg文件、vmlinuz文件 、initrd.img文件拷到TFTP服务器/tftpboot/ /下:
#cp /iso/isolinux/*.msg/tftpboot/
#cp /iso/isolinux/vmlinuz /tftpboot/
#cp /iso/isolinux/initrd.img /tftpboot/
/tftpboot/linux-install/pxelinux.cfg/default此文件可以默认不用配置,但也可以修改,
到此手动安装已完成,pxe启动客户端,进入boot选择网络安装,然后选择nfs服务器指定其目录进行安装