Friday, November 04, 2011

WAIK: Create Windows Pre-installation Environment image

Windows Pre-installation Environment (WinPE) is a lightweight version of Windows XP, Windows Server 2003 or Windows Vista that is used for the deployment of workstations and servers. It is intended as a 32-bit or 64-bit replacement for MS-DOS during the installation phase of Windows, and can be booted via PXE, CD-ROM, USB flash drive or hard disk.

WinPE contains limited Windows API library that is enough for the installation of Windows operating system using familiar Windows GUI interface.

Windows Automated Installation Kit

Windows Automated Installation Kit (WAIK) is a free tool that may prepare a WinPE image.  It has a GUI tool – Windows System Image Manager that allow user create an answer for unattended installation.  Most usage of WAIK tools is via command line.  Installation of WAIK is easy and straight forward.

Prepare a plain WinPE image

WinPE image is a file with extension .wim.  In this example, we use a WAIK command line tools to create WinPE image.  There is a special console shell available in WAIK tools: “Deployment Tools Command Prompt

capture

To create a plain WinPE x86 image, simply run:

C:\>copype x86 c:\winpe_x86
A new WinPE image is created in the folder:
C:\>winpe_x86>dir
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86

11/04/2011  11:17 AM    <DIR>          .
11/04/2011  11:17 AM    <DIR>          ..
06/10/2009  02:14 PM             4,096 etfsboot.com
11/04/2011  11:17 AM    <DIR>          ISO
11/04/2011  11:17 AM    <DIR>          mount
07/13/2009  07:51 PM       114,088,185 winpe.wim
               2 File(s)    114,092,281 bytes
               4 Dir(s)  22,600,298,496 bytes free

The copype command support create x86, amd64 and ia64 WinPE image:

c:\>winpe_x86>copype
Usage: copype [x86 | amd64 | ia64] destination

Example: copype x86 c:\windowspe-x86

Mount and Un-mount a WinPE image

An administrator privilege access is required to mount a WinPE image.  Run “Deployment Tools Command Prompt” as administrator, and use imagex to mount the WinPE image:

C:\winpe_x86>imagex /mount winpe.wim 1 mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Mounting: [C:\winpe_x86\winpe.wim, 1] -> [C:\winpe_x86\mount]...

[ 100% ] Mounting progress

Successfully mounted image.

Total elapsed time: 8 sec

The contents in WinPE image looks like normal Windows installation:

C:\winpe_x86>dir mount
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86\mount

11/04/2011  12:44 PM    <DIR>          .
11/04/2011  12:44 PM    <DIR>          ..
07/14/2009  10:04 AM    <DIR>          Program Files
07/14/2009  10:03 AM    <DIR>          Users
07/14/2009  10:51 AM    <DIR>          Windows
               0 File(s)              0 bytes
               5 Dir(s)  22,594,248,704 bytes free

To unmount the WinPE image, run

C:\winpe_x86>imagex /unmount mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Unmounting: [C:\winpe_x86\mount]...

[ 100% ] Mount cleanup progress

Successfully unmounted image.

Total elapsed time: 7 sec

Make changes to WinPE image

Follow the steps to make changes to WinPE image:

  1. Mount WinPE image using “/mountrw” switch
  2. Make necessary changes
  3. Unmount and commit changes using “/commit” switch

Prepare a WinPE image with Windows Recovery Environment

The plain WinPE image doesn’t contain Windows Recovery Environment (WinRE).  The WinPE with WinRE allows us to recover damage or corrupt Windows installation.  It is a handy environment for system administrator.

The windows installation DVD or ISO image file include Windows Recovery Environment WinPE image.  We may grep a ready WinPE image from it.

Locate a file install.wim under DVD:\\sources folder of installation tree:

C:\winpe_x86>dir d:\sources\install.wim
 Volume in drive D is GSP1RMCULFRER_EN_DVD
 Volume Serial Number is FE46-C76E

 Directory of d:\sources

04/12/2011  11:47 AM     2,249,015,826 install.wim
               1 File(s)  2,249,015,826 bytes
               0 Dir(s)               0 bytes free

Mount the install.wim in a new created folder os_install:

C:\winpe_x86>mkdir os_install
C:\winpe_x86>imagex /mount d:\sources\install.wim 1 os_install

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Mounting: [d:\sources\install.wim, 1] -> [C:\winpe_x86\os_install]...

[ 100% ] Mounting progress

Successfully mounted image.

Total elapsed time: 45 sec

Locate WinPE image of Windows Recovery Environment (WinRE.wim):

C:\winpe_x86>dir os_install\Windows\System32\Recovery
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86\os_install\Windows\System32\Recovery

04/12/2011  10:17 AM    <DIR>          .
04/12/2011  10:17 AM    <DIR>          ..
06/11/2009  05:33 AM               660 ReAgent.xml
11/20/2010  11:09 PM       145,287,084 winRE.wim
               2 File(s)    145,287,744 bytes
               2 Dir(s)  22,371,160,064 bytes free

Copy WinRE.wim to serve as base WinPE image:

C:\winpe_x86>copy os_install\Windows\System32\Recovery\winRE.wim
        1 file(s) copied.

C:\winpe_x86>dir
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86

11/04/2011  02:28 PM    <DIR>          .
11/04/2011  02:28 PM    <DIR>          ..
06/10/2009  02:14 PM             4,096 etfsboot.com
11/04/2011  12:27 PM    <DIR>          ISO
11/04/2011  12:48 PM    <DIR>          mount
11/04/2011  02:22 PM    <DIR>          os_install
07/13/2009  07:51 PM       114,088,185 winpe.wim
11/20/2010  11:09 PM       145,287,084 winRE.wim
               3 File(s)    259,379,365 bytes
               5 Dir(s)  22,225,870,848 bytes free

Unmount os_install:

C:\winpe_x86>imagex /unmount os_install

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Unmounting: [C:\winpe_x86\os_install]...

[ 100% ] Mount cleanup progress

Successfully unmounted image.

Total elapsed time: 4 sec

Disable Windows Recovery Environment on start-up

WinRE.wim starts Windows Recovery Environment by default.  To disable it, make changes to “\windows\system32\winpeshl.ini” in WinRE.wim:

C:\winpe_x86>type mount\windows\System32\winpeshl.ini
[LaunchApp]
AppPath=X:\sources\recovery\recenv.exe

Make it start command prompt by default:

[LaunchApps]
%SYSTEMROOT%\System32\wpeinit.exe
%SYSTEMROOT%\System32\cmd.exe

You may manually execute

X:\>%SYSTEMDRIVE%\sources\recovery\recenv.exe

to run Windows Recovery Environment via command prompt:

Add drivers into WinPE image

Both the plain or WinRE WinPE image contain basic drivers that is just enough to boot up machine.  In network deployment environment, the network adapters is an important devices that should be configured once boot up with WinPE or else the subsequent network operation will fail.

Assume we have some drivers ready in folder c:\winpe_x86\drivers:

C:\winpe_x86>dir drivers
 Volume in drive C has no label.
 Volume Serial Number is 1848-9FE0

 Directory of C:\winpe_x86\drivers

11/04/2011  02:45 PM    <DIR>          .
11/04/2011  02:45 PM    <DIR>          ..
11/04/2011  02:45 PM    <DIR>          Driver_Win7_7027_10202010
               0 File(s)              0 bytes
               3 Dir(s)  22,304,944,128 bytes free

Mount WinPE image as Read-Write mode:

C:\winpe_x86>imagex /mountrw winre.wim 1 mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Mounting: [C:\winpe_x86\winre.wim, 1] -> [C:\winpe_x86\mount]...

[ 100% ] Mounting progress

Successfully mounted image.

Total elapsed time: 8 sec

Use dism command to add a driver:

C:\winpe_x86>dism /image:c:\winpe_x86\mount /add-driver:C:\winpe_x86\drivers\Dri
ver_Win7_7027_10202010\Driver_Win7_7027_10202010\WIN7\32\rt86win7.inf

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7601.17514

Found 1 driver package(s) to install.
Installing 1 of 1 - C:\winpe_x86\drivers\Driver_Win7_7027_10202010\Driver_Win7_7
027_10202010\WIN7\32\rt86win7.inf: The driver package was successfully installed
.
The operation completed successfully.

Use “/recurse” switch to add all drivers at once:

C:\winpe_x86>dism /image:c:\winpe_x86\mount /add-driver:C:\winpe_x86\drivers /recurse

Unmount and commit WinPE image:

C:\winpe_x86>imagex /unmount /commit mount

ImageX Tool for Windows
Copyright (C) Microsoft Corp. All rights reserved.
Version: 6.1.7600.16385

Committing: [C:\winpe_x86\mount]...

[ 100% ] Committing Image progress

Successfully committed image.

Unmounting: [C:\winpe_x86\mount]...


[ 100% ] Mount cleanup progress

Successfully unmounted image.

Total elapsed time: 13 sec

List available drivers in WinPE

C:\winpe_x86>dism /image:c:\winpe_x86\mount /get-drivers

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7601.17514

Obtaining list of 3rd party drivers from the driver store...

Driver packages listing:

Published Name : oem0.inf
Original File Name : rt86win7.inf
Inbox : No
Class Name : Net
Provider Name : Realtek
Date : 9/20/2010
Version : 7.27.920.2010

Published Name : oem1.inf
Original File Name : rt64win7.inf
Inbox : No
Class Name : Net
Provider Name : Realtek
Date : 9/20/2010
Version : 7.27.920.2010

Published Name : oem10.inf
Original File Name : ioatdma.inf
Inbox : No
Class Name : System
Provider Name : Intel
Date : 11/16/2009
Version : 1.3.22.0

Remove a driver in WinPE image

C:\winpe_x86\mount>dism /image:c:\winpe_x86\mount /Remove-Driver /Driver:C:\winp
e_x86\drivers\Driver_Win7_7027_10202010\Driver_Win7_7027_10202010\WIN7\32\rt86wi
n7.inf

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385

Image Version: 6.1.7601.17514

Found 1 driver package(s) to remove.
Removing 1 of 1 - oem0.inf: The driver package was successfully removed.
The operation completed successfully.

Create a WinPE Bootable CD-ROM

  1. CopyPE will create a folder ISO:
    c:\winpe_x64>dir
     Volume in drive C has no label.
     Volume Serial Number is 1848-9FE0
    
     Directory of c:\winpe_x64
    
    12/02/2011  09:23 AM    <DIR>          .
    12/02/2011  09:23 AM    <DIR>          ..
    07/13/2009  04:20 PM         1,474,560 efisys.bin
    07/13/2009  04:20 PM         1,474,560 efisys_noprompt.bin
    06/10/2009  02:14 PM             4,096 etfsboot.com
    12/02/2011  09:23 AM    <DIR>          ISO
    12/02/2011  09:23 AM    <DIR>          mount
    07/13/2009  08:13 PM       135,115,506 winpe.wim
                   4 File(s)    138,068,722 bytes
                   4 Dir(s)  26,488,061,952 bytes free
  2. Copy WinPE image file into ISO\sources.  Name the WinPE image file as boot.wim:
    c:\winpe_x64>copy c:\win7_x64.wim iso\sources\boot.wim
            1 file(s) copied.
    
    c:\winpe_x64>dir iso\sources
     Volume in drive C has no label.
     Volume Serial Number is 1848-9FE0
    
     Directory of c:\winpe_x64\iso\sources
    
    12/02/2011  09:50 AM    <DIR>          .
    12/02/2011  09:50 AM    <DIR>          ..
    11/29/2011  05:11 PM       185,913,458 boot.wim
                   1 File(s)    185,913,458 bytes
                   2 Dir(s)  26,302,144,512 bytes free
  3. Create ISO image:
    c:\winpe_x64>oscdimg -n –bc:\winpe_x64\etfsboot.com c:\winpe_x64\ISO winpe_x64.iso
    
    OSCDIMG 2.55 CD-ROM and DVD-ROM Premastering Utility
    Copyright (C) Microsoft, 1993-2007. All rights reserved.
    Licensed only for producing Microsoft authorized content.
    
    
    Scanning source tree
    Scanning source tree complete (21 files in 9 directories)
    
    Computing directory information complete
    
    Image file is 218308608 bytes
    
    Writing 21 files in 9 directories to winpe_x64.iso
    
    100% complete
    
    Final image file is 218308608 bytes
    
    Done.
    
    c:\winpe_x64>dir
     Volume in drive C has no label.
     Volume Serial Number is 1848-9FE0
    
     Directory of c:\winpe_x64
    
    12/02/2011  09:52 AM    <DIR>          .
    12/02/2011  09:52 AM    <DIR>          ..
    07/13/2009  04:20 PM         1,474,560 efisys.bin
    07/13/2009  04:20 PM         1,474,560 efisys_noprompt.bin
    06/10/2009  02:14 PM             4,096 etfsboot.com
    12/02/2011  09:23 AM    <DIR>          ISO
    12/02/2011  09:23 AM    <DIR>          mount
    07/13/2009  08:13 PM       135,115,506 winpe.wim
    12/02/2011  09:52 AM       218,308,608 winpe_x64.iso
                   5 File(s)    356,377,330 bytes
                   4 Dir(s)  26,083,835,904 bytes free
    
  4. The ISO file may burn into CD-ROM for booting.

Reference

  1. http://solitudo.net/blah/posts/Create_Windows_PE_rescue_and_installation_images_using_WAIK_for_Windows_7_and_configure_Linux_boot_server_for_PXE_booting_the_images/

No comments: