DHCP部分
yum install dhcp
- 利用现成的 dhcp 样例配置文档作为服务器的 dhcp 配置文档
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
vi /etc/dhcpd.conf

=======================================================

subnet 10.0.0.0 netmask 255.255.255.0 {

option routers 10.0.0.1;
option subnet-mask 255.255.255.0;

range dynamic-bootp 10.0.0.10 10.0.0.20;

allow bootp;
allow booting;

next-server 10.0.0.1;
filename "pxelinux.0";
}

=======================================================

TFTP部分
yum install tftp-server
vi /etc/xinetd.d/tftp

===============================================

server_args = -m /tftpboot/rules -s /tftpboot
disable = no

===============================================
- 然后创建必要的文件:
1,/tftpboot/rules 文件,主要作用是把请求 tftp 的所有路径和文件名改成小写。
vi /tftpboot/rules

===============================================
ri ^[a-z]: # Remove “drive letters”
rg \\ / # Convert backslashes to slashes
rg \# @ # Convert hash marks to @ signs
rg /../ /..no../ # Convert /../ to /..no../
rg A a
rg B b
rg C c
rg D d
rg E e
rg F f
rg G g
rg H h
rg I i
rg J j
rg K k
rg L l
rg M m
rg N n
rg O o
rg P p
rg Q q
rg R r
rg S s
rg T t
rg U u
rg V v
rg W w
rg X x
rg Y y
rg Z z
r ^/(.*) \1

===============================================
2,/tftpboot/pxelinux.0 文件
将 pxelinux.0(包含在 syslinux 包里,系统已安装)拷入 /tftpboot
cp /usr/lib/syslinux/pxelinux.0 /tftpboot

3,/tftpboot/pxelinux.cfg/default 文件
mkdir /tftpboot/pxelinux.cfg
vi /pxelinux.cfg/default

===============

default wxp
prompt 1
label wxp
kernel winxp.0

==============
4,/tftpboot/winxp/i386 目录
WinXP 光盘上的 i386 目录复制到 /tftpboot/winxp 目录下
5,/tftpboot/winxp/i386/inf 目录
把一个正在运行的WinXP SP2下的 WINDOWS\inf 目录复制到 /tftpboot/winxp/i386 目录下
6,/tftpboot/winxp.sif 文件

=======================================================================
[data]
floppyless = "1"
msdosinitiated = "1"
; Needed for second stage
OriSrc = "\\10.0.0.1\tftpboot\winxp\i386"
OriTyp = "4"
LocalSourceOnCD = 1
DisableAdminAccountOnDomainJoin = 1

[SetupData]
OsLoadOptions = "/fastdetect"
; Needed for first stage
SetupSourceDevice = "\Device\LanmanRedirector\10.0.0.1\tftpboot\winxp"

[UserData]
ComputerName = *
; if needed
;ProductID=
=======================================================================

- 接着将 /tftpboot/winxp 所有文件改成小写
find ./ -depth | perl -ne 'chomp;m</[^/]*$>;$d=$`;$_=$f=$&;''s/([\x80-\xFF].)|(\w)/$1\l$2/g;system "mv",$d.$f,$d.$_ if $f ne $_'

cabextract部分
- 安装 cabextract ,下载地址:ftp://ftp.univie.ac.at/systems/linux/dag/redhat/el4/en/i386/dag/RPMS/cabextract-1.2-1.el4.rf.i386.rpm

- 进入 /tftpboot/winxp/i386 目录,解开 driver.cab 和 sp2.cab 文件

(driver.cab 是 vmware 客户端的网卡驱动,实际网络中需将真实机器的网卡驱动解压至此,eg:cabextract xxxx.exe)
cabextract driver.cab
cabextract sp2.cab
- Extract the pxe loader:

(解压 pxe loader:startrom.n1_ )
cabextract /tftpboot/winxp/i386/startrom.n1_
- Modify the name of the loader from NTLDR to XPLDR:

(上个步骤执行后会产生一个 startrom.n12 文件,将里面的 NTLDR 替换为 XPLDR)
sed -i -e 's/NTLDR/XPLDR/gi' startrom.n12
- Move the modified pxe loader to tftpd root, and call it winxp.0:

(将 startrom.n12 重命名为 winxp.0 ,并放在 /tftpboot 下)
- Extract the setuploader, using cabextract:

(解压 setuploader: setupldr.ex_ )
cabextract tftpboot/winxp/i386/setupldr.ex_
- Modify the name of the response file from winnt.sif to winxp.sif:

(上个步骤会产生 setupldr.exe 文件,将里面的 winnt.sif 替换为 winxp.sif)
sed -i -e 's/winnt\.sif/winxp\.sif/gi' setupldr.exe
- Modify the name of ntdetect from ntdetect.com to ntdetect.wxp:

(将 setupldr.exe 文件里的 ntdetect.com 替换为 ntdetect.wxp)
sed -i -e 's/ntdetect\.com/ntdetect\.wxp/gi' setupldr.exe
- Move the modified setuploader to tftpd root, and call it xpldr:

(将 setupldr.exe 文件重命名为 xpldr,并放在 /tftpboot 下)
- Copy /tftpboot/winxp/i386/ntdetect.com to tftpd root and call it ntdetect.wxp

(将 ntdetect.com 文件重命名为 ntdetect.wxp,并放在 /tftpboot 下)

注:需要打开服务器用于tftp服务的防火墙

samba部分
yum install samba
vi /etc/samba/smb.conf
===============================================
[global]
workgroup = adways
netbios name = adways
server string = Linux Samba Server TestServer
security = share
[tftpboot]
path = /tftpboot
writeable = no
browseable = yes
read only=yes
guest ok = yes
public = yes
===============================================

- 设置 /tftpboot 用户和组
chown -R nobody:nobody /tftpboot

Binl Server部分
- 安装 ris-linux ,下载地址:http://oss.netfarm.it/guides/ris-linux-0.4.tar.gz
- 进入 ris-linux 目录,执行命令(其中 run ./binlsrv.py 需要一直运行,不要关闭)
./infparser.py /tftpboot/winxp/i386/inf
./binlsrv.py


FAQ

一、客户端执行 pxe 安装系统时,屏幕出现如下报错:
1,The operating system p_w_picpath you selected does not contain the necessary drivers for your network adapter. Try selecting a different operating system p_w_picpath. If the problem persists, contact your administrator. Setup cannot continue. Press any key to exit.
方法: 服务器需配备客户端网卡驱动,将客户端网卡 exe 文件解压到 /tftpboot/winxp/i386/inf 下,其实需要的只是 inf 文件。


2,File e100bnt5.sys caused an unexpected error (21) at line 3788 in d:\xpsprtm\base\boot\setup\setup.c. Press any key to continue.
方法:e100bnt5.sys 是 dimension 3100 戴尔主机的网络驱动解压出来的文件,将它放在 /tftpboot/winxp/i386 下。

二、如果同一个局域网里已经有 windows 的 dhcp 服务器,将会有 dhcp 上的冲突。

方法:将这台 pxe xp 服务器与 windows dhcp 结合,在 windows dhcp server 上,作用域选项:
- 066 Boot Server Host Name and the IP address of my PXEserver as the string

(选择 066 编号,数值项写入 pxe xp 服务器的 IP 地址)
- 067 Bootfile Name and a String Value of pxelinux.0

(选择 067 编号,数值项写入 pxelinux.0)