Informationsansvarig: Anders Nilsson , andersn@isy.liu.se
Sidan uppdaterades senast: 2009-01-20

[ Hoppa direkt till textinnehållet ] [ Hjälp ] [ Tillgänglighetsinformation ]
In English | A till Ö Kartor Översikt Kontakta oss
Gå till LiU.se
Boot WinPE 2.0 using PXE

Boot WinPE 2.0 using PXE


Background

In order to deploy Windows installations such as Windows XP or Windows Vista over network, one needs an installation environment in which a Windows installation can run. WinPE (Windows Preinstall Environment) is such an installation environment. This page describes howto setup the things needed to successfully boot WinPE 2.0 on a client PC (with PXE, Preboot eXecution Environment) taking all files needed from a server over a network.

In particular, we will be using a FreeBSD server, but any Linux/Unix or Windows server will work as well. However, all references to the server side on this page will assume that a FreeBSD server is being used.

Prerequisites

  • A server, running DHCP and TFTP (with remapping capability)
  • A technicians PC with a DVD burner, running Windows XP or Vista. This will be used for configurations of WAIK (Windows Automated Installation Kit)
  • A client PC (with PXE). This will be used for booting WinPE. You can use the technicians PC for this, but since you most likely will make several attemps before being successful, the constant rebooting of the technicians PC between WinPE boot attemps and WAIK configuration sessions will become annoying and time consuming.
  • WAIK (Windows Automated Installation Kit). Download and save that img-file on the technicians PC, burn it to a DVD and install WAIK. If you have a virtual DVD (like DAEMON Tools), you can just mount the image and install from there.
  • PXElinux. This is not really required, but very useful if you wish to have some sort of menu choice being able to boot other things than just WinPE, so we will use it as well.
From here on we assume you have a server running DHCP and TFTP properly. Only modifications to their respective configurations will be discussed. We also assume you have a technicians PC running Windows XP or Vista with WAIK installed, and lastly a client PC with PXE support.

Problems

What, the problems section already? Although getting this to work is a rather straight forward process with few alternatives and without any big decisions there are details that needs attention. Details that will make or break the whole thing, and since we are dealing with a boot process, debugging can be a bit more difficult than usual. So, giving you the problems early on, you know what to expect and where to focus your attention. Problems here usually come from one or more of the following three areas:

  1. Case of file names, lower case, upper case or a mix thereof. This is typically a problem in a mixed environment of operating systems as in our case with a FreeBSD server and a Windows (WinPE) client. Also the WAIK documentation helps to confuse things a bit.
  2. Location of files. Again the WAIK documentation will make you somewhat uncertain as to where you should put the files.
  3. Configuration of the BCD file. The bcdedit tool will prevent you from making any syntax errors in the BCD file, but you can still make mistakes.

Problems 1 and 2 can be solved with the remapping feature of TFTP. Why not simply rename files and use soft links? Well, renaming will make the files differ from the original name. Althought that might not seem to be a problem it easily confuses things later on when you or someone else needs to fix things. Soft links simply clog up the installation tree. Besides the only way to replace the backslash character "\" in Windows path names to the slash character "/" (needed in the FreeBSD, and other UNIX pathnames) is with the remapping feature. Using remapping all together is more tidy.

Problem 3, as long as not related to problems 1 or 2, can really only be solved by making a correct BCD file. However making a sufficient BCD file is simply a matter of typing an exact sequence of commands correctly.

Now that you know some of the problems that might arise, lets start.

TFTP

Not much to do here but to get TFTP up and running. That is however not part of this description. We simply assume it is working and that files are being served from the following directory path on the server:


    /tftpboot

Later we will configure remapping of file names and paths.

Copy source files to server

This step pretty much exactly follows the instructions found in the documentation for WAIK under the section "Walkthrough: Deploy an image by using PXE", step 1. It assumes you are running all commands on the technicians PC (x86 type) with WAIK installed.

First start the "Windows PE Tools Command Prompt", from Start / Programs / Microsoft Windows AIK.

Run the copype.cmd script.


    copype.cmd x86 c:\winpe_x86


Mount the base Windows PE image.


    imagex /mountrw c:\winpe_x86\winpe.wim 1 c:\winpe_x86\mount


Map a network connection to the root tftp directory on the tftp server, and create a boot folder. We will name the folder winpe20 as it will hold all necessary files for WinPE 2.0. This assumes the root tftp directory is being shared on the network. If this is not so use another share or some other means to make a network connection to the server and move the files later on. Naturally replace the word server below with the actual name of your server.


    net use y: \\server\tftpboot
    y:
    md winpe20


Copy PXE boot files from mounted directory to \winpe20 folder.


    copy c:\winpe_x86\mount\Windows\Boot\PXE\*.* y:\winpe20


Copy the boot.sdi file to the server.


    copy c:\Program Files\Windows AIK\Tools\PETools\x86\boot\boot.sdi y:\winpe20


Here comes an optional step. Once we have successfully booted WinPE we want to use it for something. In our case we aim to automate installations of Windows, so we will now do some small customization to the winpe.wim image. The image is mounted and we will change the contents of

c:\winpe_x86\mount\windows\system32\startnet.cmd
into this:


    wpeinit
    net use y: \\server\share
    y:
    setup.cmd

We have added a few lines that will mount a samba share from our server and run a setup script. That setup script will then take care of initiating the installation of Windows. More about that here

Although Windows PE has device support for many mass storage and network devices, things change and new hardware emerges. So, new device drivers need to be added to the

winpe.wim
image. This can be done with the
winpe.exe
command like this:


    peimg.exe /inf=path_to_drivers\drivername.inf C:\winpe_x86\mount\Windows

The drivername.inf can be a wildcard, like *.inf if needed.

Now we prepare the image (remove non-installed packages) and commit our changes, with these two commands:


    peimg /prep c:\winpe_x86\mount\windows
    imagex /unmount c:\winpe_x86\mount /commit

End of optional step.


Copy the bootable Windows PE image (winpe.wim) to the \winpe20 folder.


    copy c:\winpe_x86\winpe.wim y:\winpe20

Create the BCD file

Creation of the BCD (Boot Configuration Data) file is done using the bcdedit tool, which can only be done from a computer running Windows Vista or Windows PE. If you have access to a Windows Vista computer, fine. If not, you can create a bootable Windows PE CD-ROM following the steps in the walkthrough "Create a Bootable Windows PE RAM Disk on CD-ROM" found in the WAIK documentation.

By whatever means available to you, do the following.

Create a BCD store.


    bcdedit -createstore c:\BCD


Create RAMDISK settings.


    bcdedit -store c:\BCD -create {ramdiskoptions} /d "Ramdisk options"
    bcdedit -store c:\BCD -set {ramdiskoptions} ramdisksdidevice boot
    bcdedit -store c:\BCD -set {ramdiskoptions} ramdisksdipath \boot\boot.sdi


Creating the kernel debugger is optional, so we skip it


Create OSLoader settings.


    bcdedit -store c:\BCD -create /d "MyWinPE Boot Image" /application osloader

Upon a successful create command a GUID value will be returned. That value should be used in place of guid1 in the following commands. One might think that this value is unique in such a way that the created BCD file will only be useful on the computer where it was created, but that is not the case.

    bcdedit -store c:\BCD -set {guid1} systemroot \Windows
    bcdedit -store c:\BCD -set {guid1} detecthal Yes
    bcdedit -store c:\BCD -set {guid1} winpe Yes
    bcdedit -store c:\BCD -set {guid1} osdevice ramdisk=[boot]\Boot\WinPE.wim,{ramdiskoptions}
    bcdedit -store c:\BCD -set {guid1} device ramdisk=[boot]\Boot\WinPE.wim,{ramdiskoptions}


Create BOOTMGR settings.


    bcdedit -store c:\BCD -create {bootmgr} /d "Windows VISTA BootManager"
    bcdedit -store c:\BCD -set {bootmgr} timeout 30
    bcdedit -store c:\BCD -set {bootmgr} displayorder {guid1}


Copy BCD file to server.


    copy c:\BCD \\server\tftpboot\Boot

DHCP

The DHCP configuration file can be a big monster depending on your environment. However somewhere in that file there is usually a group statement where fixed hardware ethernet addresses are mapped towards a certain host name or ip number. Somewhere in that group statement, typically in the beginning, you should add three lines so that it may look something like this:


    group {
           option vendor-class-identifier "PXEClient";
           next-server TFTP-server-address;
           filename "pxeboot.n12";

           host hostname {
           hardware ethernet ethernet-address;
           fixed-address hostname;
           }

           ...

    }

The line

option vendor-class-identifier "PXEClient";
means that the DHCP server knows the location of the PXE server, which is one and the same in our case, so no further options are needed. If the PXE server is another computer then the vendor-encapsulated-options option (option 43) must be set. It has a lot of sub-options, so you will have to consult your manual to configure this one.

The line

next-server TFTP-server-address;
tells the location of the TFTP server.

The line

filename "pxeboot.n12";
tells what bootstrap file to serve requesting PXE clients. In this case the choosen file (pxeboot.n12) is the very same as another file named pxeboot.com, but the n12 file does not require you to press F12 on the client once the file is loaded. Both these files were copied to the server in the previos steps above in "Copy source files to server".

When using PXElinux another file named pxelinux.0 should be used instead. It is accuired from the syslinux package. See prerequisites above.

Observe! All modifications to the DHCP configuration file will depend upon your type of TFTP and DHCP server software. Again, check your documentation for this. Also the PXElinux documentation is helpful here.

Lastly, the DHCP daemon usually needs to be restarted, for the changes to take effect, once the configurations are done.

PXElinux

PXElinux is made for booting Linux off a network server, but may very well be used to boot bootstrap images for other operating systems as well. Which is exactly what we are going to do. Through its configuration file(s) it is possible have simple menus choosing what to boot. We assume you have downloaded the syslinux package, extracted the file pxelinux.0 and placed it on the server in the /tftpboot folder. In the same folder you should then create another folder named pxelinux.cfg in which the configuration file(s) is put.

As said there can be several configuration files, one for each client computer if you wish. At boot time of pxelinux a certian deduction process depending on the clients UUID, MAC address and IP address (in that order) will decide what configuration file name to use as the configuration file. Have a look at the pxelinux documentation. If no suitable file name is found, pxelinux will lastly look for the file named default and load its configuration.

A default configuration file could look like this:


    default boot
    prompt 0
    say booting...
    label boot
      kernel pxeboot.0

It basically says that without further delay load and boot the file named pxeboot.0. If you have been following things closely you may now realize that no such filename exist, anywhere, in any package. The file we intend to load is actually pxeboot.n12, but for PXElinux to treat the file as a bootstrap file it must be named with the suffix .0 (dot zero). We will however in the next step use TFTP remapping to fix this (among other things) so that pxeboot.n12 is the file loaded.

TFTP remapping

Up until this point we have not really cared about whether all packages (WinPE, TFTP, DHCP, PXElinux) refer to the very same filename and path where needed, but simply left things in their original state as suggested by each package. The point of this is that it becomes easier for both you and someone else to fix and update packages at a later time.

Using TFTP remapping we will now tie things together. The remapping configuration file typically looks like this in our case:


    # remap file access requests for WinPE 2.0 
    # 
    # change all \ to / 
    rg \\ / 
    # map path prefixes 
    r ^/Boot/ winpe20/ 
    # map file names 
    re ^pxeboot\.0 winpe20/pxeboot.n12 
    re ^bootmgr\.exe winpe20/bootmgr.exe 
    re WinPE\.wim winpe.wim 

This is what happens. All \ will be translated to /, as needed by our FreeBSD server. Any path referring to /Boot/ will be redirected to winpe20/. Any reference to the file pxeboot.0 will be redirected to winpe20/pxeboot.n12. Things work the same way for the file bootmgr.exe. Lastly, the filename WinPE.wim will be translated to winpe.wim.

We have named our configuration file tftpdremap and put it in the /tftpboot folder. On the command line for tftp we then supply with an option telling tftp where it is found, like this:


    in.tftp -l -m /tftpboot/tftpdremap -s /tftpboot

Things may very well differ for your tftp server, so check your documentation.

The tftp daemon typically needs to be restarted for any changes in the remap file to take effect.

Booting WinPE

With everything set up correctly you should now be able to boot WinPE on your client PC. Simply reboot it and press whatever button (if needed) to start booting from network (PXE).

Initially you should see your PC get an ip address via DHCP, then the deduction process of PXElinux (if used) to find the configuration file, and then the screen goes blank. You may not be able to read everything since all this goes pretty quick.

After a few seconds (10-15 seconds, depending on your network and computer speed) it will say "Windows is loading files ..." with a growing progress bar beneath. When finished the screen goes blank again.

After another few seconds the screen changes to some graphical mode with another type of progress bar and saying "(C) Microsoft Corporation" beneath. Finally you get the Vista colored background and a command prompt shell window. And that's it, you have successfully booted WinPE over network!

The speed of the whole process depends on the speed of your client PC and network. On our client PC (P4, 3GHz, 100Mbit network) the whole thing took a little more than 2 minutes from power up to command shell.

When things go wrong

The very most common problem we experienced was when the client PC could not find the files it requested. If you use logging features for the TFTP server you should be able to see the exact read requests and figure out what needs to be fixed, typically using remapping.


A problem you may encounter is this:


	Windows Boot Manager

    ...

    File:\Boot\BCD

    Status: 0xc000000f

    Info: An error occured while attempting to read the boot configuration
          data.

This typically means that the BCD file was not found. Check the TFTP log and change remapping to point out the correct filename and location.


Another problem situation is this:


	Windows Boot Manager

    ...

    Status: 0xc000000f

    Info: The boot selection failed because a required device is
          inaccessible.

This typically means that the WinPE.wim file was not found. Again, check the TFTP log and change remapping to fix it.

Other problems may of course occur but these two seems to be the ones causing most confusion.

The entire /tftpboot directory tree

For reference, here is the entire /tftpboot directory tree:


tftpboot:
total 20
-rw-r--r--   1 root  wheel  13940 14 Jan 14:05 pxelinux.0
drwxr-xr-x   2 root  wheel    512 16 Jan 14:12 pxelinux.cfg/
-rw-r--r--   1 root  wheel    225 16 Jan 13:10 tftpdremap
drwxr-xr-x  25 root  wheel   1024 16 Jan 14:01 winpe20/

tftpboot/pxelinux.cfg:
total 2
-rw-r--r--  1 root  wheel  65 14 Jan 14:19 default

tftpboot/winpe20:
total 164022
-rw-r--r--  1 root  wheel      12288 14 Jan 22:57 BCD
-rw-r--r--  1 root  wheel        333 18 Sep  2006 WdsConfig.inf
-rw-r--r--  1 root  wheel         79 18 Sep  2006 abortpxe.com
-rw-r--r--  1 root  wheel    3170304 18 Sep  2006 boot.sdi
-rw-r--r--  1 root  wheel     417896  2 Nov  2006 bootmgr.exe
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 cs-CZ/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 da-DK/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 de-DE/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 el-GR/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 en-US/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 es-ES/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 fi-FI/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 fr-FR/
-rw-r--r--  1 root  wheel      25372 21 Sep  2006 hdlscom1.com
-rw-r--r--  1 root  wheel      25356 21 Sep  2006 hdlscom1.n12
-rw-r--r--  1 root  wheel      25372 21 Sep  2006 hdlscom2.com
-rw-r--r--  1 root  wheel      25356 21 Sep  2006 hdlscom2.n12
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 hu-HU/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 it-IT/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 ja-JP/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 ko-KR/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 nb-NO/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 nl-NL/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 pl-PL/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 pt-BR/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 pt-PT/
-rw-r--r--  1 root  wheel      25068 21 Sep  2006 pxeboot.com
-rw-r--r--  1 root  wheel      25068 21 Sep  2006 pxeboot.n12
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 ru-RU/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 sv-SE/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 tr-TR/
-rw-r--r--  1 root  wheel      27596 11 Okt  2006 wdsnbp.com
-rw-r--r--  1 root  wheel  164002999  2 Nov  2006 winpe.wim
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 zh-CN/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 zh-HK/
drwxr-xr-x  2 root  wheel        512 14 Jan 14:25 zh-TW/

tftpboot/winpe20/cs-CZ:
total 64
-rw-r--r--  1 root  wheel  65024  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/da-DK:
total 64
-rw-r--r--  1 root  wheel  64000  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/de-DE:
total 66
-rw-r--r--  1 root  wheel  67072  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/el-GR:
total 68
-rw-r--r--  1 root  wheel  69632  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/en-US:
total 62
-rw-r--r--  1 root  wheel  63488  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/es-ES:
total 66
-rw-r--r--  1 root  wheel  66048  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/fi-FI:
total 64
-rw-r--r--  1 root  wheel  65024  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/fr-FR:
total 68
-rw-r--r--  1 root  wheel  68608  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/hu-HU:
total 66
-rw-r--r--  1 root  wheel  66560  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/it-IT:
total 66
-rw-r--r--  1 root  wheel  66560  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/ja-JP:
total 54
-rw-r--r--  1 root  wheel  53760  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/ko-KR:
total 54
-rw-r--r--  1 root  wheel  54784  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/nb-NO:
total 64
-rw-r--r--  1 root  wheel  64512  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/nl-NL:
total 66
-rw-r--r--  1 root  wheel  67072  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/pl-PL:
total 66
-rw-r--r--  1 root  wheel  67072  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/pt-BR:
total 66
-rw-r--r--  1 root  wheel  66048  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/pt-PT:
total 66
-rw-r--r--  1 root  wheel  66048  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/ru-RU:
total 66
-rw-r--r--  1 root  wheel  66048  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/sv-SE:
total 64
-rw-r--r--  1 root  wheel  64512  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/tr-TR:
total 64
-rw-r--r--  1 root  wheel  64512  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/zh-CN:
total 50
-rw-r--r--  1 root  wheel  51200  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/zh-HK:
total 50
-rw-r--r--  1 root  wheel  49664  2 Nov  2006 bootmgr.exe.mui

tftpboot/winpe20/zh-TW:
total 50
-rw-r--r--  1 root  wheel  49664  2 Nov  2006 bootmgr.exe.mui

Software versions

For reference, here are the versions of the software used:


    FreeBSD          6.2-STABLE
    TFTP             tftp-hpa 0.48, with remap, with tcpwrappers
    DHCP             Internet Systems Consortium DHCP Server V3.0.5
    PXElinux         3.51 2007-06-10
    WAIK             1.0.0.0
    WinPE            2.0