Chinaunix首页 | 论坛 | 博客
  • 博客访问: 75881
  • 博文数量: 22
  • 博客积分: 145
  • 博客等级: 入伍新兵
  • 技术积分: 181
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-07 16:43
文章分类

全部博文(22)

文章存档

2018年(5)

2017年(2)

2013年(6)

2012年(4)

2011年(5)

我的朋友

分类: LINUX

2011-12-23 16:20:28

PXE(preboot execute environment) 工作于 Client/Server 的网络模式,大致工作流程如下:
(1) client 通过 DHCP 向 Server 请求 IP 地址;
(2) client 获取 IP 后,通过 TFTP 协议下载一个 Bootstrap 程序;
(3) Bootstrap 从服务器读取一个配置文件,该配置文件里面定义了后续需要从服务器 tftp 下载的内核和根文件系统的文件名;
(4) Bootstrap 程序从服务器下载内核和根文件系统,最终将控制权交给内核;

过程详述:
我的实验条件是一台 Master,10多台 IMB 和 Dell 的slave,需要增加一台 IMB X336 的slave,所有的过程都通过抓包确认。Server 需要配置 dhcp 和 dns 服务等。 /etc/dhcpd.conf 中定义 Client Mac 和 IP 的对应关系,/etc/host 中定义了 IP 和 hostname 的对应关系。下述的所有路径除指定的绝对路径外,都基于 /tftpboot。 Bootstrap 程序,内核和根文件系统都放在该目录下,另下述的一些信息已经修改。

(1) Client DHCP 过程:
    (a) client send broadcast packet(DHCP Discover)
    (b) server send broadcast packet(DHCP Offer), including client ip, server identifier/ip, host name, subnet mask, address lease time and so on;
    (c) client send broadcast packet(DHCP Request), including client ip, server ip like above to tell all of the dhcp server that client has made a choice.
    (d) server send broadcast packet(DHCP ACK), verify client, and all the dhcp procedure is done.

(2) Client 向服务器请求的 Bootstrap 程序定义在 /etc/dhcpd.conf 程序中,如这样一行:
  filename "/pxelinux.0";
  那么服务器会将 /tftpboot/pxelinux.0 程序发送给 Client。

(3) Bootstrap 程序向 Server 请求配置文件,假设 client 通过 DHCP 获取的 IP 为 192.168.1.130,Client Mac 地址为 01-02-03-04-05-06-07, GUID 为 abcd1234-1234-b601-7a7f-00145e7f5723,那么请求配置文件的路径将按如下顺序,从 client 的 GUID 名称,到最后将请求 default 配置文件(C0A80182 是 192.168.1.130 的十六进制表示,pxelinux.cfg 位于 /tftpboot 路径下):

     File: /pxelinux.cfg/abcd1234-1234-b601-7a7f-00145e7f5723
     File: /pxelinux.cfg/01-02-03-04-05-06-07
     File: /pxelinux.cfg/C0A80182
     File: /pxelinux.cfg/C0A8018
     File: /pxelinux.cfg/C0A801
     …
     File: /pxelinux.cfg/C
     File: /pxelinux.cfg/default

配置文件大致格式如下:
 DEFAULT test
 LABEL test

 KERNEL bzImage_kernel
 IPAPPEND 1

 APPEND root=/dev/ram initrd=initrd.img

 TIMEOUT 2

(4) Bootstrap 程序根据配置文件中内核和文件系统名称,从 Server 下载文件(/tftpboot 目录下):
     File: /bzImage_kernel
     File: /initrd.img
阅读(2507) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~