实验环境:
Server: Dell 380 with RHEL5.5_i386
IP address : 10.1.8.60/32
关闭iptables和selinux
Client: Acer 4315 & Dell 360
服务器环境设置:
1.安装所需的软件:
#yum install dhcp dhcp-3.0.5-3.el5
#yum install tftp-server tftp tftp-server-0.49-2 tftp-server-0.49-2
#yum install samba samba-3.0.33-3.28.el5
下载并安装cabextract,我这里使用的是1.3版本:
http://www.cabextract.org.uk/
2.设置所有的服务:
DHCP 服务器:
#vi /etc/dhcpd.conf
如下:
authoritative;
ddns-updates on;
ddns-update-style interim;
ddns-domainname "testing.com.";
do-forward-updates on;
key "rndckey" {
algorithm hmac-md5;
secret "ghObXTApKbkkrxhGWmwpR7C5a2zcm9trQ55u8q8iqBkJBuUDdFDyMNMM079z";
};
option wpad-url code 252 = text;
option wpad-url "http://mailbj.testing.com/wpad.dat /n";
ignore client-updates;
zone testing.com. { # Forward zone to be updated
primary 127.0.0.1;
key rndckey;
}
zone 8.1.10.in-addr.arpa. { # Backward zone to be updated
primary 127.0.0.1;
key rndckey;
}
subnet 10.1.8.0 netmask 255.255.255.0 {
option routers 10.1.8.1;
option subnet-mask 255.255.255.0;
option nis-domain "testing.com";
option domain-name "testing.com";
option domain-name-servers 10.1.8.2,220.231.35.70,202.106.0.20;
option time-offset -18000; # Eastern Standard Time
option ntp-servers 10.1.8.2;
option netbios-name-servers 10.1.8.2;
# Dynamic DNS update
ddns-domainname "testing.com";
deny unknown-clients;
range dynamic-bootp 10.1.8.101 10.1.8.249;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host desktopbj-it0 {
hardware ethernet B8:ac:6F:49:a2:c4;
fixed-address 10.1.8.60;
option routers 10.1.8.4;
option domain-name-servers 10.1.8.2,119.53.1.26,220.231.35.70;
}
host notebookbj-acer4315 {
allow booting;
allow bootp;
filename "pxelinux.0";
next-server 10.1.8.60;
option domain-name-servers 10.1.8.2,119.53.1.26,220.231.35.70;
option routers 10.1.8.4;
hardware ethernet 00:1d:72:1b:38:a5;
fixed-address 10.1.8.61;
}
host vm-hq1 {
allow booting;
allow bootp;
filename "pxelinux.0";
next-server 10.1.8.60;
option domain-name-servers 10.1.8.2,119.53.1.26,220.231.35.70;
option routers 10.1.8.4;
hardware ethernet 00:0c:29:9b:e2:70;
fixed-address 10.1.8.62;
}
拷贝pxelinux.0 到/tftpboot下:
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
pxelinux.0文件,一般安装了syslinux后就会有的
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 = -vvv -m /tftpboot/rules -s /tftpboot
# server_args = -s -vvv /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
增加了/tftpboot/rules文件,这个文件主要作用是,把请求tftp的所有路径和文件名改成小写。这个文件的内容为:
#vi /etc/tftpboot/rules
如下:
ri ^[a-z]: # Remove
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
Samba 服务器配置:
vi /etc/samba/smb.conf
如下:
security = share
[reminst]
path = /tftpboot
browsable = true
read only = yes
writable = no
guest ok = yes
null passwords = true #不用密码登陆
创建/tftpboot/pxelinux.cfg目录,在该目录下创建:default文件,内容为视情况修改:
#mkdir /tftpboot/pxelinux.cfg
#vi /tftpboot/pxelinux.cfg/default
如下:
default RHEL5_5
prompt 1
timeout 600
display pxelinux.cfg/list #显示列表,内容见后
label RHEL5_5
kernel vmlinuz5_5
append ks=nfs:10.1.8.60:/mnt/ks/RHEL5_5_ks.cfg initrd=initrd5_5.img
label WinXP
kernel winxp.0
#vi /tftpboot/pxelinux.cfg/list
choose one of the following linux or windows distribution for you installation:
Name distribution Arch installation media
RHEL5_5 RHEL5_5 i386 10.1.8.60:/mnt/RHEL5_5
WinXP WinXPSP3 i386 /data/winxp
ghost ghost8.3
把WinXP上的i386复制到/tftpboot/winxp下,把一个正常运行WinXP, 下的Windows目录中的inf复制到/tftpboot/winxp/i386下,里面主要包括一些驱动.
因为在tftp配置文件中增加了rules把所有文件和目录都改成小写(在启动client过程中,可以查看/var/log/message得知),所以把所有文件名和目录都改成小写.
如下:
#cd /tftpboot/winxp
#find ./ -depth | perl �Cne 'chomp;m</[^/]*$>;$d=$`;$_=$f=$&;''s/([/x80-/xFF].)|(/w)/$1/l$2/g;system "echo",$d.$f,$d.$_ if $f ne $_'
如果有显示,表明有这些明中是有大写字母的,然后运行:
#find ./ -depth | perl -ne 'chomp;m</[^/]*$>;$d=$`;$_=$f=$&;''s/([/x80-/xFF].)|(/w)/$1/l$2/g;system "mv",$d.$f,$d.$_ if $f ne $_'
下面要用到微软PXE启动的几个文件:startrom.n1_,setupldr.ex_,ntdetect.com,这几个文件在光盘中都可以找到,我这里将使用windows2003光盘中的,因为之前从XP光盘中提取出来的,在启动过程中会出现inf &#$b#$%c xxxx error, status 21.这样的一些错误.
1.拷贝文件:
#cp /mnt/win2003/i386/{startrom.n1_,setupldr.ex_,ntdetect.com} /tftpboot/
2.用cabextract解压上述文件:
#cabextract startrom.n1_
将得到一个startrom.n12
#cabextract setupldr.ex_
将得到一个setupldr.exe
3.配置上述文件:
#sed -i -e ‘s/NTLDR/xpldr/gi’ startrom.n12
#sed -i -e ‘s/ntldr/xpldr/gi’ startrom.n12
#mv /tftpboot/startrom.n12 /tftpboot/winxp.0
# sed -i -e ‘s/winnt/.sif/winxp/.sif/gi’ setupldr.exe
# sed -i -e ‘s/ntdetect/.com/ntdetect/.wxp/gi’ setupldr.exe
#mv /tftpboot/setupldr.exe /tftpboot/xpldr
#mv /tftpboot/ntdetect.com /tftpboot/ntdetect.wxp
4.创建winxp.sif
#vi /tftpboot/winxp.sif
如下:
[data]
floppyless = "1"
msdosinitiated = "1"
; Needed for second stage
OriSrc = "//10.1.8.60/reminst/winxp/i386"
OriTyp = "4"
LocalSourceOnCD = 1
DisableAdminAccountOnDomainJoin = 1
[SetupData]
OsLoadOptions = "/fastdetect"
; Needed for first stage
SetupSourceDevice = "/Device/LanmanRedirector/10.1.8.60/reminst/winxp"
[Unattended]
UnattendMode=ProvideDefault
OemPreinstall=No
TargetPath=/WINDOWS
FileSystem=LeaveAlone
NtUpgrade=No
OverwriteOemFilesOnUpgrade=No
[GuiUnattended]
EncryptedAdminPassword=NO
OEMSkipRegional=1
TimeZone=210
[UserData]
ProductKey=BYCMB-R844W-KJBQX-J3D9F-V3Y6G
FullName="admin"
OrgName="augusta"
ComputerName=desktopbj-
[Display]
BitsPerPel=32
Xresolution=1024
YResolution=768
Vrefresh=60
[TapiLocation]
CountryCode=86
[RegionalSettings]
LanguageGroup=10
SystemLocale=00000804
UserLocale=00000804
InputLocale=0804:00000804
[SetupMgr]
DistFolder=C:/windist
DistShare=windist
[Identification]
JoinDomain=%MACHINEDOMAIN%
DoOldStyleDomainJoin=Yes
[Networking]
InstallDefaultComponents=Yes
ProcessPageSections=Yes
[RemoteInstall]
Repartition=Yes
[OSChooser]
Description="Windows Professional - Standard Installation"
Help="This will install Windows Professional in a standard configuration."
LaunchFile="%INSTALLPATH%/%MACHINETYPE%/templates/startrom.com"
ImageType=Flat
下载Binl 服务并运行:
http://oss.netfarm.it/guides/ris-linux-04.tar.gz
cd /root
tar zvxf ris-linux-04.tar.gz
cd ris-linux-04
./infparser.py /tftpboot/winxp/i386/inf
如果有错误,把错误相应的文件删除,再执行
把驱动缓存
./binlsrv.py
遇到的错误并解决:
如遇到蓝屏什么的,一般是网卡驱动不对。
如找不到inf文件,一般是没有驱动,把驱动相应文件inf/sys/cab拷入/tftpboot/winxp/i386/inf,后运行ris重新load.