Subversion Repositories se3

Rev

Blame | Last modification | View Log | RSS feed

<HTML>
<HEAD>
<TITLE>Deploy windows 7 from Linux without WAIK - 1. Overview</TITLE>
<link rel="STYLESHEET" type="text/css" href="default.css">
</HEAD>
<BODY>
<CENTER>
<H1>Deploy windows 7 from Linux without WAIK</H1>
</CENTER>
<TABLE>
<TR>
<TD VALIGN=TOP NOWRAP>

<B>Menu</B><BR>
<LI>1. <A HREF="win7pxelinux1.html">Overview</A>
<LI>2. <A HREF="win7pxelinux2.html">Services</A>
<LI>3. <A HREF="win7pxelinux3.html">Boot Files</A>
<LI>4. <A HREF="win7pxelinux4.html">Unattended files</A>
<LI>5. <A HREF="win7pxelinux5.html">Troubleshooting</A>
</TD>
<TD WIDTH=20></TD>
<TD VALIGN=TOP>
<H2>3. Prepare the Windows boot files</H2>

<H3>3.1 Import the default boot file</H3>
First of all we'll need to mount the installation DVD. I'm going to assume here that it is in the DVD player known as /dev/cdrom. You'll should mount it like this:
<PRE>
  mount -t udf /dev/cdrom /work/sambashare/win7
</PRE>
If you have an iso file, then you should do something like:
<PRE>
  mount -o loop -t udf /work/windows7.iso /work/sambashare/win7
</PRE>
Once you've done this we can use the files on the DVD (image) and we've also published it through the samabashare.

Then we need to extract some files from the boot.wim file that resides in the /sources directory on the DVD. They will have to end up in the /work/tftproot directory so we go there first:
<PRE>
  cd /work/tftproot
  /work/bin/wimextract /work/sambashare/win7/sources/boot.wim //windows/boot/pxe pxeboot.n12
  mv pxeboot.n12 pxeboot.com
  /work/bin/wimextract /work/sambashare/win7/sources/boot.wim //windows/boot/pxe bootmgr.exe
  /work/bin/wimextract /work/sambashare/win7/sources/boot.wim //windows/boot/pxe wdsnbp.com
  cp /work/sambashare/win7/boot/boot.sdi /work/tftproot
</PRE>
Note that we extractthe pxeboot.n12 and that we rename it to pxeboot.com!

<H3>3.2 Prepare the WIM file</H3>
Well, now we need to create a winpe.wim file. Here's what we do:

<H4>3.2.1 Create a file winpehl.ini</H4>
It has to contain something like this:
<PRE>
[LaunchApps]
%SYSTEMDRIVE%\sources\new\install.cmd
%SYSTEMDRIVE%\windows\system32\cmd.exe
</PRE>
Make sure it has the dos format (and not unix format)
<PRE>
unix2dos winpeshl.ini
</PRE>

<H4>3.2.2 Create install.cmd script</H4>
Create an install.cmd script that will take care of the installation once Winpe has started:
<PRE>
@ECHO OFF

echo Starting windows7.cmd Command Script, press CONTROL+C to interrupt this script

echo.
echo Restoring the Setup environment
move %SYSTEMDRIVE%\setup.uda %SYSTEMDRIVE%\setup.exe
move %SYSTEMDRIVE%\sources\setup.uda %SYSTEMDRIVE%\sources\setup.exe


SET REGEXE=%SYSTEMDRIVE%\windows\system32\reg.exe

echo Getting UDA Template info from registry

for /f "tokens=2*" %%A IN ('%REGEXE% query HKLM\SYSTEM\CurrentControlSet\Control /f "SystemStartOptions" ^| find "UDA="') DO SET SSO=%%B

echo.
echo SYSTEMSTARTOPTIONS=%SSO%

echo.
for /f "tokens=1,2,3,4,5,6,7,8,9,10" %%A IN ( "%SSO%" ) DO (
  echo %%A | FIND "UDA=" && echo FOUND %%A && SET UDAOPTION=%%A
 echo %%B | FIND "UDA=" && echo FOUND %%B && SET UDAOPTION=%%B
 echo %%C | FIND "UDA=" && echo FOUND %%C && SET UDAOPTION=%%C
 echo %%D | FIND "UDA=" && echo FOUND %%D && SET UDAOPTION=%%D
 echo %%E | FIND "UDA=" && echo FOUND %%E && SET UDAOPTION=%%E
 echo %%F | FIND "UDA=" && echo FOUND %%F && SET UDAOPTION=%%F
 echo %%G | FIND "UDA=" && echo FOUND %%G && SET UDAOPTION=%%G
 echo %%H | FIND "UDA=" && echo FOUND %%H && SET UDAOPTION=%%H
 echo %%I | FIND "UDA=" && echo FOUND %%I && SET UDAOPTION=%%I
 echo %%J | FIND "UDA=" && echo FOUND %%J && SET UDAOPTION=%%J
)
echo.
echo UDAOPTION=%UDAOPTION%

for /f "delims=:= tokens=1,2,3,4,5" %%A IN ("%UDAOPTION%") DO (
 SET UDA_IPADDR=%%B
 SET UDA_TEMPLATE=%%C
 SET UDA_SUBTEMPLATE=%%D
 SET UDA_DRIVER=%%E
)

echo UDA Template info is:
echo.
echo UDA_IPADDR:       %UDA_IPADDR%
echo UDA_TEMPLATE:     %UDA_TEMPLATE%
echo UDA_SUBTEMPLATE:  %UDA_SUBTEMPLATE%
echo UDA_DRIVER:       %UDA_DRIVER%


SET UDADIR=%SYSTEMDRIVE%\sources\uda
SET DRVLOAD=%SYSTEMDRIVE%\windows\system32\drvload.exe
SET WPEINIT=%SYSTEMDRIVE%\windows\system32\wpeinit
SET NETEXE=%SYSTEMDRIVE%\windows\system32\net.exe
SET INSTALLDRIVE=I

SET PRESCRIPT=%INSTALLDRIVE%:\pxelinux.cfg\templates\%UDA_TEMPLATE%\%UDA_SUBTEMPLATE%.cmd

echo PRESCRIPT=%PRESCRIPT%

cd %UDADIR%

if "%UDA_DRIVER%"=="" goto tryall
FOR /F "eol=; tokens=1,2,3,4" %%A in ( %SYSTEMDRIVE%\sources\uda\drivers.txt ) DO (
  echo Driver=%%A Number=%%B Inffile=%%C Ssysfile=%%D
  if not "%%A"=="%UDA_DRIVER%" goto skipload
    echo Loading driver %%A
    %DRVLOAD% %%C && goto doneloading
   echo Could not succesfully load driver %UDA_DRIVER%, trying all instead
   goto tryall
:skipload
   echo Skipping load of driver %%A
)

:tryall
echo Trying all network drivers
FOR /F "eol=; tokens=1,2,3,4" %%A in ( %SYSTEMDRIVE%\sources\uda\drivers.txt ) DO (
    echo Driver=%%A Number=%%B Inffile=%%C Ssysfile=%%D
    %DRVLOAD% %%C && goto doneloading
   echo Could not succesfully load driver %%A, trying next one
)

goto manual

:doneloading


echo.
echo Starting the network
%WPEINIT%
if not %ERRORLEVEL%==0 goto manual

echo.
echo Mapping the network share
%NETEXE% use %INSTALLDRIVE%: \\%UDA_IPADDR%\REMINST

echo.
echo Handing over command to the remote template script and not coming back!
if EXIST %PRESCRIPT% %PRESCRIPT% %UDA_IPADDR% %UDA_TEMPLATE% %UDA_SUBTEMPLATE%

pause
:manual
echo.
echo Could not succesfully load a network driver, please try manually
echo you should do something like:
echo.
echo drvload x:\sources\uda\netamd.inf
echo wpeinit
echo net use i: \\%UDA_IPADDR%\REMINST
echo %PRESCRIPT% %UDA_IPADDR% %UDA_TEMPLATE% %UDA_SUBTEMPLATE%
echo.

cmd.exe
pause
</PRE>

<H4>3.2.3 Add Network drivers</H4>
Well. Network drivers are a difficult story. You'll need network drivers that come with your network card, can be downloaded from the network card vendor, or some may be already available in the Windows 7 WINPE distribution on your installation media. I'm going to assume here that you will be PXE booting a vmware virtual with an AMD network card (which is in many cases the default network card for a new virtual).
<BR><BR>
If your virtual boots and it shows an Intel E1000 network card when booting from the network, you'll have to shut down the virtual, remove the following line from the .vmx file and restart.
<PRE>
ethernet0.virtualDev = "e1000"
</PRE>
If you start it now It will say there's an AMD network card...
So now we need the windows PE drivers for this AMD network card.
There's a <A HREF="http://www.the-d-spot.org/wordpress/2010/01/20/vmware-network-drivers-for-winpe-3-0/">page</A> that tells you where you can download them:
<PRE>
cp netamd.inf   /work/wim/
cp pcntpci5.sys /work/wim/
</PRE>
For windows PE you can use windows XP drivers. In General you'll need an .inf file and the .sys file. The inf file usually contains a list of network device ID's and their corresponding driver (.sys) file(s). If you're not sure which network card ID your system has, then just copy multiple drivers (inf ans sys files) to the /work/wim directory.

<H4>3.2.4 Create an actionfile</H4>
Here's the actions we want to take when creating the winpe.wim from the boot.wim. Yuo may want to edit the drivers to add in
/work/wim/actionfile.txt.
Here's what that file looks like:
<PRE>
rename //setup.exe setup.new
rename //sources/setup.exe setup.new
add //windows/system32 winpeshl.ini
mkdir //sources new
add //sources/new netamd.inf
add //sources/new pcntpci5.sys
add //srouces/new install.cmd
</PRE>

<H4>3.2.5 Create the WIM file</H4>
Now we can create the winpe.wim file
</PRE>
cd /work/wim
/work/bin/updatewim /work/sambashare/win7/sources/boot.wim  /work/tftproot/winpe.wim /work/wim/actionfile.txt
</PRE>

<H3>3.3 Create the system-specific boot files</H3>
First we need the hivex tools. The RPM's I use are in the <A HREF="http://www.ultimatedeployment.org/win7pxelinux.tgz">package</A>.
<PRE>
cd /work/rpm
rpm -ivh hivex*
</PRE>
You may need other distribution packages for your favorite linux distribution.
We need these tools in order to be able to edit windows BCD files (Boot Cofiguration Data).

Now we do three things for both systems we want to install remotely:
<UL>
 <LI>Copy the Boot Cofiguration Data from the installation DVD to the systems pxe boot directory
 <LI>Modify it to become a PXE BCD
 <LI>Copy the Windows Deployment Services Network Boot Program (wdsnbp.com) to that directory as well and rename it to wdsnbp.0
</UL>
<PRE>
 cp /work/sambashare/win7/boot/bcd /work/tftproot/system1
 /work/bin/bcdedit.pl /work/tftproot/system1/bcd /winpe.wim /boot.sdi INFO=10.0.0.1:system1
 cp /work/tftproot/wdsnbp.com /work/tftproot/system1/wdsnbp.0

 cp /work/sambashare/win7/boot/bcd /work/tftproot/system2
 /work/bin/bcdedit.pl /work/tftproot/system2/bcd /winpe.wim /boot.sdi INFO=10.0.0.1:system2
 cp /work/tftproot/wdsnbp.com /work/tftproot/system2/wdsnbp.0
</PRE>
You can easily extend this for more then two systems...

<BR>
<BR>
<A HREF="win7pxelinux4.html">Continue to part 4</A>
<BR>
<BR>

<LI><A HREF="win7pxelinux1.html">Go to part 1: Overview</A>
<LI><A HREF="win7pxelinux2.html">Go to part 2: Configuring and starting services</A>
<LI><A HREF="win7pxelinux3.html">Go to part 3: Prepare the windows boot files</A>
<LI><A HREF="win7pxelinux4.html">Go to part 4: Prepare the unattended installation files</A>
<LI><A HREF="win7pxelinux5.html">Go to part 5: Troubleshooting</A>
</TD>
<TD VALIGN=TOP>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-7926266120435192";
/* win7pxelinux */
google_ad_slot = "2210822672";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>