22 May, 2012

Windows Pre-Install Environment [WinPE] Booting

Abstract
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 Pre-install Environment) is such an installation environment. WinPE can boot on a client PC which is disk-less, taking all the necessary files from the server on the network. 

Prerequisites

  1. A server, running DHCP and TFTP. This can be Windows server OS with DHCP enabled or Windows XP or later version with free third party DHCP and TFTP server.
  2. A Technician’s PC with a DVD burner, running Windows Vista. This will be used for configurations of WAIK (Windows Automated Installation Kit). Administrative access for user is preferred in this machine.
  3. A client PC (with PXE). This will be used for booting WinPE. You can use the Technician’s PC for this, but since you most likely will make several attempts before being successful, the constant rebooting of the technicians PC between WinPE boot attempts and WAIK configuration sessions will become annoying and time consuming.
  4. 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.

System Requirements for Technician’s PC

  • An x86- or x64-based computer running Windows Vista / Windows 7
  • Windows OPK or Windows AIK.
  • A CD or DVD burner to create portable media.
  • Image-burning software.
  • .NET Framework 2.0 (provided with the WAIK during setup).
  • Network access, to download the latest updates (if you plan to use the  technician computer as a network share).

System Requirements for Server PC

  • An x86-  or x64-based computer running Windows XP / Windows Vista / Windows 7 / Windows Server 2003 operating system. 
  • Ethernet port
  • Properly configured DHCP Server
  • Properly configured TFTP Server. 
Note: Configure the root folder as ‘TFTPRoot’

System Requirements for Client PC

  • Working Ethernet Port 
  • PXE Boot supported Motherboard 
  • 512MB RAM
Note: Boot option in BIOS should be configured such that LAN has first priority

Procedure

Copy Source Files onto PXE Server 

In this step, you copy Windows PE source files to your PXE server.
  • On your technician computer, click  Start,  point to  Programs, point to Windows OPK  or Windows AIK, and then click  Windows PE Tools Command Prompt.The menu shortcut opens a Command Prompt window and automatically sets environment variables to point to all the necessary tools. By default, all tools are installed at C:\Program Files\[version]\Tools, where [version] can be Windows OPK or Windows AIK.
  • Run the copype.cmd script. The script requires two arguments: hardware architecture and destination location. copype.cmd [arch] [destination] where [arch] can be x86, amd64, or ia64 and [destination] is a path to a local directory. For example, 
copype.cmd x86 c:\winpe_x86

The script creates the following directory structure and copies all the necessary files for that
architecture. For example,  
  1. c:\winpe_x86
  2. c:\winpe_x86\ISO
  3. c:\winpe_x86\mount
Note: Now the command prompt must have changed to c:\winpe_x86
  • Mount the base Windows PE image (Winpe.wim) to the  \mount directory by using ImageX.
For example,
imagex /mountrw c:\winpe_x86\winpe.wim 1 c:\winpe_x86\mount
Note: If the command is successful you will see following folders under mount directory:
  1. Windows
  2. Program Files   
  3. Users 
  • Map a network connection to the root TFTP directory on the PXE/TFTP server and create a \Boot folder. For example,

net use y: \\[TFTP-Server]\TFTPRoot
y:md Boot
Note: Use IP or the Machine name of the TFTP Server as [TFTP-Server]. This can also be done from the windows explorer using ‘Map network drive’ option. 

  • Copy the PXE boot files from the mounted directory to the TFTP Root folder. 
For example, copy c:\winpe_x86\mount\Windows\Boot\PXE\*.* y:\ 
Note: Need to copy only the following files. Other folders available there are not needed.
  1. abortpxe.com
  2. bootmgr.exe
  3. hdlscom1.com
  4. hdlscom1.n12
  5. hdlscom2.com
  6. hdlscom2.n12
  7. pxeboot.com
  8. pxeboot.n12
  9. WdsConfig.inf
  10. wdsnbp.com
  • Copy the Boot.sdi file into the Boot folder in PXE/TFTP server.
copy “c:\Program Files\[version]\Tools\PETools\x86\boot\boot.sdi” y:\Boot  
Note: where [version] can be Windows OPK or Windows AIK. (In our case it is Windows AIK)

  • Copy the bootable Windows PE image (Winpe.wim) to the \Boot folder.
copy c:\winpe_x86\winpe.wim y:\Boot 
Note: All the copy operations in step 5, 6 and 7 can be performed using Windows explorer. 

Configure Boot Configuration Data

In this step, you create a BCD Store by using the BCDEdit tool. BCDEDIT can be run only from a
Windows Vista/Windows 7 computer or a Windows PE environment. BCDEdit is located in the
\Windows\System32 directory.
On a Windows Vista computer or in a Windows PE environment, create a BCD store by using BCDEdit. For example,

cd [Windows Installation Drive]:\Windows\System32
Bcdedit –createstore c:\BCD

  • Create the RAMDISK settings. For example,
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
  • Create kernel debugger settings. For example,
Bcdedit –store c:\BCD –create {dbgsettings} /d “Debugger settings” 
Bcdedit –store c:\BCD –set {dbgsettings} debugtype serial
Bcdedit –store c:\BCD –set {dbgsettings} baudrate 115200
Bcdedit –store c:\BCD –set {dbgsettings} debugport 1
Note: This step is optional. Required only if you need to debug the WinPE installation.
 
  • Create OSLoader settings for the Windows PE image. For example,
Bcdedit –store c:\BCD –create /d “MyWinPE Boot Image” /application osloader
Note: If the  create  command is successful, then the computer will return a GUID value. The

following examples refer to this value as {guid1}.
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 the BOOTMGR settings. For example,
Bcdedit –store c:\BCD –create {bootmgr} /d “Windows VISTA BootManager”  /inherit {dbgsettings} 
Note:  If you are not using debugging (Optional Step 3) remove “/inherit {dbgsettings}” from the

above command.
Bcdedit –store c:\BCD –set {bootmgr} timeout 30 
Bcdedit –store c:\BCD –displayorder {guid1} [{guid2}] where {guid1}, {guid2} and so on are the GUIDS for each ‘*.wim’ file entry.

  • Copy the BCD file generated at the C:\ to your server. For example,
copy c:\BCD y:\Boot
Important: The BCD store must reside in a \Boot directory in the TFTP root folder. Additionally,
the Boot Configuration Data (BCD) store file name must be ‘BCD’.

  • Configure your PXE/TFTP server to point PXE clients to download pxeboot.com / pxeboot.n12.
            Your PXE/TFTP server is now configured. It’s time to power Up the Client PC.

Deployment process

Client PC will request the DHCP server to assign an IP for it. Then the client will start downloading the files put in different places in the Server. The whole process should complete in 5-10 minutes depending upon the network conditions. If you successfully booted into Windows Pre-installation Environment you should see a command prompt.
Important: WinPE can hang-up for several minute apparently doing nothing.

The following outlines the download process.
  • A client is directed (by using DHCP Options or the PXE Server response) to download the file ‘pxeboot.com’
OR
  • A client is directed (by using DHCP Options or the PXE Server response) to download the file ‘pxeboot.n12’
Note: PXEBoot.com requires pressing the F12 key in the client to initiate PXE boot.
  • pxeboot.com / pxeboot.n12 download Bootmgr.exe and the BCD store. 
  • Bootmgr.exe reads the BCD operating system entries and downloads Boot.sdi and the Windows PE image (winpe.wim)
  • Bootmgr.exe begins booting Windows PE by calling into Winload.exe within the Windows PE image. 

Problems Encountered and Solution

A problem you may encounter

Windows Boot Manager
    ...
    File:\Boot\BCD
    Status: 0xc000000f
    Info: An error occurred while attempting to read the boot configuration data.

Solution

This typically means that the BCD file was not found. Check the TFTP folder and ensure that the BCD file is inside ’Boot’ folder in the TFTP root directory.

Another problem situation

Windows Boot Manager
    ...
    Status: 0xc000000f 
     Info: The boot selection failed because a required device is inaccessible

Solution

This typically means that the boot.wim file was not found. Again, check the TFTP folder and ensure that the *.wim files are copied inside ’Boot’ folder in the TFTP root directory.

Yet Another Problem

While you examin the TFTP log you may notice client/TFTP is complaining about missing files. Similarly BCD and *.wim file may not properly transferred at the first attempt.

Solution

These are ’Normal’ and this will not affect the WinPE booting procedure. 

One more ...

Typing these DOS commands in the prompt will be tedious. Instead create your own batch files using these listed commands.

Other relevant information

PXE Server Folder structure

Directory of C:\TFTPRoot
03/30/2012  04:59 PM    [DIR]          .
03/30/2012  04:59 PM    [DIR]          ..
09/19/2006  03:15 AM    79 abortpxe.com
03/28/2012  06:25 PM    [DIR]          Boot
11/02/2006  03:21 PM    417,896 bootmgr.exe
09/21/2006  11:10 AM    25,372 hdlscom1.com
09/21/2006  11:10 AM    25,356 hdlscom1.n12
09/21/2006  11:10 AM    25,372 hdlscom2.com
09/21/2006  11:10 AM    25,356 hdlscom2.n12
09/21/2006  11:10 AM    25,068 pxeboot.com
09/21/2006  11:10 AM    25,068 pxeboot.n12
09/19/2006  03:15 AM    333 WdsConfig.inf
10/11/2006  06:50 AM    27,596 wdsnbp.com

              10 File(s)

Directory of C:\TFTPRoot\Boot
03/28/2012  06:25 PM    [DIR]          .
03/28/2012  06:25 PM    [DIR]          ..
03/29/2012  06:55 AM    12,288 BCD
09/19/2006  02:15 AM    3,170,304 boot.sdi
03/29/2012  06:53 AM    169,078,909 winpe.wim
               3 File(s) 

Adding packages to the WinPE image

More functionality can be added to WinPE image by installing packages.  Enter the following command to list the components that are available for installation. 
peimg c:\winpe_x86\mount\windows /list  
Note: In the output, the + or  –  symbol in the Ins column indicates the installation flag on the package. + indicates the package will be installed, - indicates it will not be installed.
For installing a package use the following command:
peimg c:\winpe_x86\mount\Windows /install=[package]
Note: [package] is one of the listed packages when we used the /list command in the previous step.

Adding additional drivers to the WinPE image

In the Command Prompt, type the following command and then press ENTER  
peimg /inf="[driver_path]" c:\winpe_x86\mount\Windows
If you need to check the functionality of driver in WinPE  environment you can use the drvload command to temporarily load the driver using the below syntax
drvload.exe [driver_path]
Note: The driver can be copied using normal command line options (eg: copy command). Alternately can copy it as described in the next step
Important: The driver loaded using drvload command will not be available after rebooting the WinPE image.

Adding additional executable to the WinPE image

This can be done by copying the required executable into any of the folders available in the c:\winpe_x86\mount directory.

Prepping a WinPE build

In the Command Prompt, type the following commands and then press ENTER.  
peimg c:\Winpebuild\Windows /Prep /F
Note: The /F switch is used to remove the prompt confirming that you wish to prepare the image.
Important: As part of this process, the image will no longer be able to be modified.

Building a WinPE image 

Once the WinPE build has been customized and prepped, it is now ready to be captured and stored as a WIM file.
imageX /boot /compress maximum /capture c:\Winpebuild c:\winpe\sources\boot.wim “WinPE Image”
Note: The above action will take approximately 5 minutes to complete. 

Important: "[" and "]" are used instead of "<" and ">" respectively through out this guide.

Reference

  1. http://technet.microsoft.com/en-us/library/cc748892%28v=ws.10%29.aspx
  2. http://technet.microsoft.com/en-us/library/cc722358%28v=ws.10%29.aspx
  3. http://www.microsoft.com/download/en/details.aspx?id=10333
  4. http://www-pc.uni-regensburg.de/systemsw/vista/CLIHOL310.pdf
  5. http://www.da.isy.liu.se/~andersn/boot_winpe_using_pxe.html
  6. http://www.vercot.com/~serva/

5 comments:

  1. Hi All,

    I tried my best to collect all the information required to boot WinPE environment. If there are any omissions or additions needed please let me know.

    Thanks
    Deepak

    ReplyDelete
  2. All what you are doing here is automatically done by the new Serva, read here.

    http://www.vercot.com/~serva/howto/WindowsPXE1.html

    ReplyDelete
  3. odd that no one mentions that - does not work and the / is needed. i found this worked for all and i am stuck on the line
    Bcdedit /store Y:\Boot\BCD –create /d “MyWinPE Boot Image” /application osloader

    keeps telling me
    A description for the new entry must be specified.
    Run "bcdedit /?" for command line assistance.

    ReplyDelete
  4. Is y: is a network drive? I think it won't work.

    ReplyDelete
  5. Nice blog !!! Its can solve you querry about bootmgr missing error in windows 7 click this link and free from your windows 7 realted problem.
    BOOTMGR Missing in Windows 7
    Thanks
    Aalia lyon

    ReplyDelete