Install Windows 7 over PXE from Linux without WAIK

Menu
  • 1. Overview
  • 2. Services
  • 3. Boot Files
  • 4. Unattended files
  • 5. Troubleshooting
  • 3. Prepare the Windows boot files

    3.1 Import the default boot file

    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:
      mount -t udf /dev/cdrom /work/sambashare/win7
    
    If you have an iso file, then you should do something like:
      mount -o loop -t udf /work/windows7.iso /work/sambashare/win7
    
    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:
      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
    
    Note that we extractthe pxeboot.n12 and that we rename it to pxeboot.com!

    3.2 Prepare the WIM file

    Well, now we need to create a winpe.wim file. Here's what we do:

    3.2.1 Create a file winpehl.ini

    It has to contain something like this:
    [LaunchApps]
    %SYSTEMDRIVE%\sources\new\install.cmd
    %SYSTEMDRIVE%\windows\system32\cmd.exe
    
    Make sure it has the dos format (and not unix format)
    unix2dos winpeshl.ini
    

    3.2.2 Create install.cmd script

    Create an install.cmd script that will take care of the installation once Winpe has started:
    @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
    

    3.2.3 Add Network drivers

    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).

    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.
    ethernet0.virtualDev = "e1000"
    
    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 page that tells you where you can download them:
    cp netamd.inf   /work/wim/
    cp pcntpci5.sys /work/wim/
    
    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.

    3.2.4 Create an actionfile

    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:
    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
    

    3.2.5 Create the WIM file

    Now we can create the winpe.wim file cd /work/wim /work/bin/updatewim /work/sambashare/win7/sources/boot.wim /work/tftproot/winpe.wim /work/wim/actionfile.txt

    3.3 Create the system-specific boot files

    First we need the hivex tools. The RPM's I use are in the package.
    cd /work/rpm
    rpm -ivh hivex*
    
    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:
    • Copy the Boot Cofiguration Data from the installation DVD to the systems pxe boot directory
    • Modify it to become a PXE BCD
    • Copy the Windows Deployment Services Network Boot Program (wdsnbp.com) to that directory as well and rename it to wdsnbp.0
      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
    
    You can easily extend this for more then two systems...

    Continue to part 4

  • Go to part 1: Overview
  • Go to part 2: Configuring and starting services
  • Go to part 3: Prepare the windows boot files
  • Go to part 4: Prepare the unattended installation files
  • Go to part 5: Troubleshooting