您的位置:首页 > 理论基础 > 计算机网络

linux+pxe+dhcp+tftp+samba+ris网络安装windows server 2003

2013-09-30 11:42 651 查看
一.原理简介RIS(远程安装服务,Remote Installation Services) 是windows server的可选服务,利用RIS可以让管理员很方便地为客户端部署操作系统。
二.环境说明server os:CentOS 5.4 i386server soft:dhcp, tftp, samba, ris-linux可以使用yum安装:yum –y install dhcp*
yum –y install tftp*
yum –y install samba*
server ip:eth1: 192.168.0.1
client:HP 360G5
windows 2003 sp2 cn enterprise
三.安装配置过程简介
1. 配置DHCP
more /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.0.1;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.0.10 192.168.1.254;
default-lease-time 21600;
max-lease-time 43200;
# Group the PXE bootable hosts# PXE-server configuration directionnext-server 192.168.0.1; #指向nfs服务器filename “/pxelinux.0″; #/tftp根目录下的启动引导文件}重启dhcp服务:/etc/init.d/dhcpd restart2. 配置TFTPmore /etc/xinetd.d/tftp# default: off# description: The tftp server serves files using 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{socket_type = dgramprotocol = udpwait = yesuser = rootserver = /usr/sbin/in.tftpdserver_args = -u nobody -s /tftpboot -m /tftpboot/rules –vv#-s指定tftp根目录, -m指定一个规则文件, -vv输出tftp的log到/var/log/messagedisable = no #默认yes,关闭per_source = 11cps = 100 2flags = IPv4}重启tftp服务:/etc/init.d/xinetd.restart查看tftp服务是否启动:chkconfig –list | grep tftp3. 建立TFTP的rules文件Linux下区分大小写,但windows不区分,为免混乱,将所有查找文件内容统一改成小写。more /tftpboot/rulesri ^[a-z]: # Remove “drive letters”rg \\ / # Convert backslashes to slashesrg \# @ # Convert hash marks to @ signsrg /../ /..no../ # Convert /../ to /..no../rg A arg B brg C crg D drg E erg F frg G grg H hrg I irg J jrg K krg L lrg M mrg N nrg O org P prg Q qrg R rrg S srg T trg U urg V vrg W wrg X xrg Y yrg Z zr ^/(.*) \14. 配置SAMBAwindows的ris安装是通过windows共享文件的方式进行文件传输,在linux下可以通过samba实现与windows进行文件共享,进而实现ris安装windows。编辑samba配置文件:/etc/samba/smb.conf全局配置:[global]null passwords = trueworkgroup = WORKGROUPserver string = Samba Server Version %vsecurity = sharedns proxy = noload printers = nodisable spoolss = yesdebug level = 2log file = /var/log/samba/%m.logmax log size = 0共享配置:[wininstall]comment = Windows 2003 Installpath = /tftpbootbrowsable = trueread only = nowriteable = yesguest ok = yes重启samba服务:/etc/init.d/smb restart5. 配置启动需要的文件上传windows2003的镜像或者文件到服务器。这里使用上传镜像然后挂载。mount /root/win2003cn.iso /mnt –o loopmkdir /tftpboot/win2k3cd /mntcp –a * /tftpboot/win2k3下面需要解压一些iso中的文件,可以使用cabextract。下载页:http://www.cabextract.org.uk/可以根据版本下载。wget http://www.cabextract.org.uk/cabextract-1.3-1.i386.rpmrpm –ivh cabextract-1.3-1.i386.rpm配置windows ris 启动文件cd /tftpbootcabextract win2k3/i386/startrom.n1_#解压sed -i -e ‘s/NTLDR/W2K3L/gi’ startrom.n12#直接替换startrom.n12文件中” NTLDR”为” W2K3L”#W2K3L: windows 2003 Setup Loadermv startrom.n12 /tftpboot/w2k3.0# w2k3.0: windows 2003 pxe loadercabextract win2k3/i386/setupldr.ex_sed -i -e ‘s/winnt\.sif/wi2k3\.sif/gi’ setupldr.exesed -i -e ‘s/ntdetect\.com/ntdetect\.2k3/gi’ setupldr.exemv setupldr.exe /tftpboot/w2k3lcp win2k3/i386/ntdetect.com /tftpboot/ntdetect.2k3# ntdetect.2k3: windows 2003 ntdetect.com配置pxe启动镜像cp /usr/lib/syslinux/pxelinux.0 /tftpboot# pxelinux.0依赖于syslinux,没有安装使用yum:yum –y install syslinux*# pxelinux.0是PXE启动引导文件配置pxe启动加载文件pxelinux.0启动中,读取同目录先pxelinux.cfg文件夹下的配置文件以确定它应该怎么加载启动文件。mkdir /tftpboot/pxelinux.cfgvim /tftpboot/pxelinux.cfg/defaultdefault win2k3label win2k3kernel w2k3.0 #与ris启动文件匹配建立安装应答文件这个文件很强大,提供的参数不是对系统很了解的人并不一定全知道,我们只需要知道对我们有用的参数。当然,没事的时候也可以慢慢研究。:)vim /tftpboot/wi2k3.sif[data]AutoPartition = “0″#关闭自动分区,2003还不能完全自动分区,这点需要手工操作。如果一定要跳过这一步,需要和后面的参数配合,并且2003提供的只有将全盘划成根盘(c:\)floppyless = “1″msdosinitiated = “1″UnattendedInstall = “Yes”OriSrc = \\192.168.0.1\wininstall\win2k3\i386#注意samba和win安装文件路径OriTyp = “4″LocalSourceOnCD = “1″DisableAdminAccountOnDomainJoin = “1″[SetupData]OsLoadOptions = “/fastdetect”SetupSourceDevice = “\Device\LanmanRedirector\192.168.0.1\wininstall\win2k3″[Unattended]UnattendMode = “FullUnattended”#使用unattended文件FileSystem = “LeaveAlone”NtUpgrade = “No”OverwriteOemFilesOnUpgrade = “No”DriverSigningPolicy = “Ignore”UpdateInstalledDrivers = “Yes”ConfirmHardware = “No”ExtendOEMPartition = “0″TargetPath = “\WINDOWS”UnattendSwitch = “Yes”WaitForReboot = “No”CrashDumpSetting = “0″OemSkipEula = “Yes”OEMSkipWelcome = “1″InstallFilesPath = “\\192.168.0.1\wininstall\win2k3\i386″LegacyNIC = “1″OemPreInstall = “Yes” #加载OEM中的驱动[UserData]ProductKey = “M4VQK-HVTD9-42RQX-2DJP2-23KVM”FullName = “admin”OrgName = “SDO”ComputerName = C1ZJ[GuiUnattended]AdminPassword = WD#sd7258EncryptedAdminPassword = “No”OEMSkipRegional = “1″TimeZone = “220″OemSkipWelcome = “1″[LicenseFilePrintData]AutoMode=PerServerAutoUsers=5[Identification]JoinWorkgroup = WORKGROUP[RemoteInstall]Repartition = “NO”UseWholeDisk = “No”#这里和分区有关[Networking]InstallDefaultComponents = “Yes”#以下的默认文件中没有,和服务器raid卡驱动有关[MassStorageDrivers]“Windows Driver for Smart Array SAS/SATA Controllers” = OEM[OEMBootFiles]cp011324.xmlcpqsetup.exegeneric.dllhpcisss2.cathpcisss2.syshpcissx2.infinstall.xmltxtsetup.oem#以下是系统安装完毕后第一次启动执行的批处理文件[GuiRunOnce]%systemdrive%\preinstall\runonce.cmd6. 驱动加载相关因为是服务器的安装,所以需要提前加载一些驱动,自动安装的麻烦就在此。pxe安装需要加载网卡驱动(引导和文件传输是两个阶段,传输文件阶段开始时要先把网卡驱动加载起来的)。查到服务器使用的Broadcom NetXtreme II网卡,而Broadcom提供在ris下的驱动:wget http://www.broadcom.com/docs/driver_download/NXII/win_2k3_RIS-5.0.0.zipmkdir /tftpboot/nicdriveunzip win_2k3_RIS-5.0.0.zip -d /tftpboot/nicdrive驱动网卡,需要有一个binl server,binl读取所有新的与网络接口卡相关的.inf文件,并在映像中创建.pnf文件。binl server下载:http://oss.netfarm.it/guides/wget http://oss.netfarm.it/guides/ris-linux-0.4.tar.gztar –zxvf ris-linux-0.4.tar.gzcd ris-linux-0.4./infparser.py /tftpboot/nicdrive/Server/W2K3_W2K8/RIS/./binlsrv.py -d #-d 后台运行,不能停止此程序cp /tftpboot/nicdrive/Server/W2K3_W2K8/RIS/b06nd51x.sys /tftpboot/win2k3/i386这里是Broadcom提供有专门的ris网卡驱动,如果没有,可以将windows需要的网卡驱动(不限于网卡)的.inf文件放在/tftpboot/inf文件夹下,执行:./infparser.py /tftpboot/inf./binlsrv.py然后是加载raid卡驱动(其他驱动也适用,关键是能否找到相关文件)光 盘安装windows在开始时蓝色屏幕上有一个按F6的提示,提示是通过软盘加载磁盘驱动,这类驱动是windows系统中的驱动,可以下载好 windows驱动,解压好驱动放在一个指定的目录,再通过应答文件,一般可以加载上这类驱动。这类驱动加载完毕后不必在系统中再安装。加载这类驱动有注 意点:文件要有正确的oem数字签名(一般提供驱动的厂商都带数字签名),乱改动这类文件,同时不在配置文件中写明去掉数字签名认证,是不能加载的。下载HP的raid卡驱动(已经查明型号:Smart Array E200i, 一般一个驱动支持多种类型的raid卡)。wget http://h30445.www3.hp.com/pub/softlib2/software1/sc-windows/p1285069816/v55115/cp011324.exemkdir /tftpboot/win2k3/i386/$oem$/textmodeunzip cp011324.exe -d /tftpboot/win2k3/i386/$oem$/textmode在自动应答文件wi2k3.sif末尾添加:[MassStorageDrivers]“Windows Driver for Smart Array SAS/SATA Controllers” = OEM#” Windows Driver for Smart Array SAS/SATA Controllers”可以查看textmode文件夹下的txtsetup.oem文件,名字保持一致[OEMBootFiles]cp011324.xmlcpqsetup.exegeneric.dllhpcisss2.cathpcisss2.syshpcissx2.infinstall.xmltxtsetup.oem#textmode下的所有文件名字,一般自动安装的驱动文件.inf, .cat, .sys修改[Unattended]字段,添加:OemPreInstall = “Yes”7. 补丁,前期包,其他驱动的加载完成以上操作就已经可以安装系统了,但是系统安装完成后需要做一些前期操作,像打补丁,打安全包,或者一些驱动(芯片组,网卡,显卡等在上面没有加载到系统中的一些驱动)。这些优化的问题可以利用批处理文件解决。这些批处理文件最好是在windows下编辑好再上传到服务器,否则会出现格式问题导致文件不能执行。首先需要在$oem$目录下建立cmdlines.txt文件,这个文件会在系统安装过程的注册组件时间段(即还剩13分钟左右时)调用:vim /tftpboot/win2k3/$oem$/cmdlines.txt[COMMANDS]“install.cmd”#文件的内容以” [COMMANDS]“为起头;使用引号(“)来标记下面需要执行的每条命令。 注意路径问题,install.cmd的路径为cmdlines.txt的同级目录。这里还可以添加注册表。以下是此时使用的nstall.cmd:@ echo offtitle Windows Install Prepackage, Hotfix and Drives@ color 0a@echo 安装WINDOWS_2003_SP2补丁, 大约需要20分钟… 2>>%HOMEDRIVE%/errlog.txt@ cd hotfix 2>>%HOMEDRIVE%/errlog.txtWindowsServer2003-KB914961-SP2-x86-CHS.exe /quiet /norestartWindowsUpdateAgent30-x86.exe /quiet /norestartWindowsServer2003-KB925902-x86-CHS.exe /quiet /norestartWindowsServer2003-KB930178-x86-CHS.exe /quiet /norestartWindowsServer2003-KB931784-x86-CHS.exe /quiet /norestartWindowsServer2003-KB932168-x86-CHS.exe /quiet /norestartWindowsServer2003-KB935839-x86-CHS.exe /quiet /norestartWindowsServer2003-KB935840-x86-CHS.exe /quiet /norestartWindowsServer2003-KB933729-x86-CHS.exe /quiet /norestartWindowsServer2003-KB943460-x86-CHS.exe /quiet /norestartWindowsServer2003-KB921503-x86-CHS.exe /quiet /norestartWindowsServer2003-KB938829-x86-CHS.exe /quiet /norestartWindowsServer2003-KB941644-x86-CHS.exe /quiet /norestartWindowsServer2003-KB943485-x86-CHS.exe /quiet /norestartWindowsServer2003-KB942830-x86-CHS.exe /quiet /norestartWindowsServer2003-KB942831-x86-CHS.exe /quiet /norestartWindowsServer2003-KB943055-x86-CHS.exe /quiet /norestartWindowsServer2003-KB946026-x86-CHS.exe /quiet /norestartWindowsServer2003-KB941693-x86-CHS.exe /quiet /norestartWindowsServer2003-KB944338-x86-CHS.exe /quiet /norestartWindowsServer2003-KB945553-x86-CHS.exe /quiet /norestartWindowsServer2003-KB948590-x86-CHS.exe /quiet /norestartWindowsServer2003-KB951748-x86-CHS.exe /quiet /norestartWindowsServer2003-KB950974-x86-CHS.exe /quiet /norestartWindowsServer2003-KB952954-x86-CHS.exe /quiet /norestartWindowsServer2003-KB938464-x86-CHS.exe /quiet /norestartwindowsserver2003-kb953155-x86-chs.exe /quiet /norestartwindowsserver2003-kb954211-x86-chs.exe /quiet /norestartwindowsserver2003-kb956803-x86-chs.exe /quiet /norestartwindowsserver2003-kb956841-x86-chs.exe /quiet /norestartwindowsserver2003-kb957095-x86-chs.exe /quiet /norestartWindowsServer2003-KB958644-x86-CHS.exe /quiet /norestartWindowsServer2003-KB957097-x86-CHS.exe /quiet /norestartWindowsServer2003-KB956802-x86-CHS.exe /quiet /norestartWindowsServer2003-KB958687-x86-CHS.exe /quiet /norestartWindowsServer2003-KB958690-x86-CHS.exe /quiet /norestartWindowsServer2003-KB960225-x86-CHS.exe /quiet /norestartWindowsServer2003-KB952004-x86-CHS.exe /quiet /norestartWindowsServer2003-KB956572-x86-CHS.exe /quiet /norestartWindowsServer2003-KB960803-x86-CHS.exe /quiet /norestartWindowsServer2003-KB961501-x86-CHS.exe /quiet /norestartWindowsServer2003-KB968537-x86-CHS.exe /quiet /norestartWindowsServer2003-KB970238-x86-CHS.exe /quiet /norestartWindowsServer2003-KB958469-x86-CHS.exe /quiet /norestartWindowsServer2003-KB971032-x86-CHS.exe /quiet /norestartWindowsServer2003-KB971657-x86-CHS.exe /quiet /norestartWindowsServer2003-KB967723-x86-CHS.exe /quiet /norestartWindowsServer2003-KB953298-x86-CHS.exe /quiet /norestartWindowsServer2003-KB958869-x86-CHS.exe /quiet /norestartWindowsServer2003-KB971486-x86-CHS.exe /quiet /norestartWindowsServer2003-KB975467-x86-CHS.exe /quiet /norestartWindowsServer2003-KB969947-x86-CHS.exe /quiet /norestartWindowsServer2003-KB974392-x86-CHS.exe /quiet /norestartWindowsServer2003-KB972270-x86-CHS.exe /quiet /norestartWindowsServer2003-KB971468-x86-CHS.exe /quiet /norestartWindowsServer2003-KB975713-x86-CHS.exe /quiet /norestartWindowsServer2003-KB977165-x86-CHS.exe /quiet /norestartWindowsServer2003-KB978251-x86-CHS.exe /quiet /norestartWindowsServer2003-KB979683-x86-CHS.exe /quiet /norestartWindowsServer2003-KB980232-x86-CHS.exe /quiet /norestartWindowsServer2003-KB979559-x86-CHS.exe /quiet /norestartWindowsServer2003-KB980218-x86-CHS.exe /quiet /norestartif %errorlevel% EQU 0 (@ echo 补丁安装成功, 继续安装prepackge… 2>>%HOMEDRIVE%/errlog.txt@ cd ..@ goto prepackge 2>>%HOMEDRIVE%/errlog.txt) else (@ echo 补丁安装失败, 继续安装prepackge… 2>>%HOMEDRIVE%/errlog.txt@ cd ..@ goto prepackge 2>>%HOMEDRIVE%/errlog.txt):prepackge@ echo 安装Prepackage中… 2>>%HOMEDRIVE%/errlog.txt@ cd windows_2010628 2>>%HOMEDRIVE%/errlog.txtinstall.bat /qn 2>>%HOMEDRIVE%/errlog.txtif %errorlevel% EQU 0 (@ echo Prepackage安装成功 2>>%HOMEDRIVE%/errlog.txt@ cd ..@ goto end 2>>%HOMEDRIVE%/errlog.txt) else (@ echo Prepackage安装失败 2>>%HOMEDRIVE%/errlog.txt@ cd ..@ goto end 2>>%HOMEDRIVE%/errlog.txt):end批处理文件中的hotfix(有重要的补丁,可以下载放到这,但别忘记了修改批处理文件),windows_20100628(安全部门制作的安全包解压所得)文件夹和install.cmd位于同级目录,这里就是在/tftpboot/win2k3/$oem$/下其中在组件注册时不能执行的的命令或者程序(包括有交互而不适合执行的程序),可以通过在自动应答文件wi2k3.sif中添加[GuiRunOnce]字段,在第一次登录系统时执行脚本来完成一些短时间能够完成的操作。在/tftpboot/win2k3/$oem$/下建立文件夹$1,这个文件夹下的所有文件(夹)会在安装过程中复制到兄根目录,即C盘。mkdir /tftpboot/win2k3/$oem$/$1cd mkdir /tftpboot/win2k3/$oem$/$1mkdir preinstall在windows平台编辑一个批处理文件runonce.cmd,上传到preinstall文件夹下:@ echo offtitle Windows GuiRunOnce Install Drives@ color 0aecho starting driveecho.@ cd\@ cd preinstall@ cd hpcall bp000588.cmdecho.echo starting pcanywhere@ cd\@ cd preinstall@ cd pcanywhere_10.5.1cnstart /wait SymantecpcAnywhere.msiecho.shutdown -r -t 0exit这 里我将HP的所有驱动放到hp文件夹下(因为我也分部清楚哪些需要,哪些不需要,就只有全部上传了,L),pcanywhere安装文件放到 pcanywhere_10.5.1cn文件夹下。所有这些文件夹统一放到preinstall文件夹下(有需要还可以增加,修改runonce.cmd 即可)最后在自动应答文件wi2k3.sif中添加:[GuiRunOnce]%systemdrive%\preinstall\runonce.cmd#注意路径8. 进阶上面只是提到32为系统,对于64位系统,我们可以在/tftpboot下建立win2k3_64文件夹,将iso下的文件拷到此文件夹下。cabextract win2k3_64/i386/startrom.n1_#解压sed -i -e ‘s/NTLDR/W2K3L_64/gi’ startrom.n12#直接替换startrom.n12文件中” NTLDR”为” W2K3L_64”#W2K3L_64: windows 2003 64bit Setup Loadermv startrom.n12 /tftpboot/w2k3_64.0# w2k3_64.0: windows 2003 bit pxe loadercabextract win2k3_64/i386/setupldr.ex_sed -i -e ‘s/winnt\.sif/wi2k3_64\.sif/gi’ setupldr.exesed -i -e ‘s/ntdetect\.com/ntdetect\.2k3_64/gi’ setupldr.exemv setupldr.exe /tftpboot/w2k3l_64cp win2k3_64/i386/ntdetect.com /tftpboot/ntdetect.2k3_64# ntdetect.2k3_64: windows 2003 bit ntdetect.comsamba服务器需要建立针对64位系统的共享目录,如[win64install];同时建立自动应答文件/tftpboot/wi2k3_64.sif 。这两者当中的路径问题请一定要注意一一对应。pxe加载/tftpboot/pxelinux.cfg/default文件,需要有系统选择时,可以修改文件:vim /tftpboot/pxelinux.cfg/defaultdefault win2k3timeout 30label win2k3kernel w2k3.0label win2k3_64kernel w2k3_64.0其实不管是32位还是64位系统,启动文件都是一样的,这些都可以不用修改,只是客户端从服务器下载文件的路径一定要区分32位和64位。启 动顺序:pxelinux.0—> default—> pxe loader(w2k3.0, startrom.n12)—>setup loader(w2k3l, setupldr.exe) —> ntdetect.com(ntdetect.2k3) and winnt.sif(wi2k3.sif)9. 小结关 于驱动加载的问题,如果我们参照一台已经装好windows2003系统的服务器的硬件驱动(重要的是芯片组,网卡,显卡等)可以看出这些驱动主 要由.sys, .dll, .inf(驱动信息文件), .cat(驱动签名文件)等文件组成。如果能收集到这些文件放到系统安装文件里,就不用事后打驱动那么麻烦。但这个过程目前我还没有摸透,这点还是有很大 的改进空间的。使用这套系统安装windows2003系统,加上打补丁(大概超过20分钟)的时间,前后在40分钟左右
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息