Sunday, February 17, 2008

Windows PE 2.0 and a USB flash drive

Windows PE is a version of the Windows OS that runs without installation entirely in memory (no harddisk required) and boots from a cd-rom or the network

Getting started
Download and install the Windows Automated Installation Kit (WAIK) it is available as a download. It's a big download. Burn it to a cd or mount it using some ISO/IMG mounting tool and install it.

The Windows PE Tools Command Prompt
Open up the Windows PE Tools Command Prompt from the Start Menu and make sure to Run as Administrator: (Run as Administrator is only required on Windows Vista and Windows Server 2008)

Alternatively, you can change the shortcut's properties, Advanced..., Run as Administrator to run it everytime elevated as an administrator.


Building your Windows PE
In order to build your custom Windows PE, follow the next steps:

  1. Run copype.cmd as follows: copype.cmd x86 d:\winpe_x86
    This makes a copy of the Windows PE files to the specified folder. Alternatively, you can specify amd64 for 64-bit machines.
  2. You can customize the Windows PE image (using the Windows Imaging Format, (WIM)) using ImageX:You can mount a WIM file to a folder using the following command:
    imagex /mountrw d:\winpe_x86\winpe.wim 1 d:\winpe_x86\mount
    This works through a file system driver called WimFltr (see sc queryex WimFltr).
  3. Add all apps you like to add to the image in the mounted folder. Windows PE is based on packages that can be added to the image at will. This is done through peimg, using: peimg /list /image=d:\winpe_x86\mount\Windows
    to show a list of all images.
    Next, you can add packages by using the command:
    peimg /install=package d:\winpe_x86\mount\Windows
    where package is either * (all packages) or one from the list shown by invoking peimg with the /list switch.
    The packages are :
    WinPE-HTA-Package = HTML Application support
    WinPE-MDAC-Package = Microsoft Data Access Component support
    WinPE-Scripting-Package = Scripting (VBS, WSH) Support
    WinPE-WMI-Package = Windows Management Instrumentation Support
    WinPE-XML-Package = Microsoft XML (MSXML) parser support
  4. To copy various deployment tools into the Windows PE image, type:
    xcopy "C:\Program files\Windows AIK\Tools\x86\*.*" "D:\WinPE_x86\Mount\Program Files\Tools" /s
    and then press ENTER.
    When prompted about a file or directory name, type D.

    Or other tools type XCopy “C:\Tools\*.*” “D:\WinPE_x86\Mount\Tools” /s, and then press ENTER. When prompted about a file or directory name, type D.

    You could add drivers and language packs as well, please see the notes lower in this blog or the help documentation that comes with the WAIK.
  5. When you're done with the image customization, run peimg with the prep switch: peimg /prep d:\winpe_x86\mount\Windows
    and unmount the image using ImageX:
    imagex /unmount d:\winpe_x86\mount /commit
    and copy the created .wim file to the ISO folder:
    copy d:\winpe_x86\winpe.wim d:\winpe_x86\ISO\sources\boot.wim
    Answering Y to agree to the file being overwritten.

Create a bootable Windows PE ISO Image

You can create an ISO file for the image using oscdimg:

oscdimg -n -bd:\winpe_x86\etfsboot.com d:\winpe_x86\ISO d:\winpe_x86\winpe_x86.iso

where the -b flag specifies the El Torito boot sector for the ISO to be created. It just takes a few seconds to complete.

Create a Bootable Windows PE USB Flash disk

Finally, it's time to put the whole thing on a USB Flash key or to burn the ISO created in the previous step to a cd-rom. Open up diskpart and execute the following commands.

WARNING! Make sure to select the right disk in step 1; you can view all disks using the "list disk" command. In the steps below, all data from the USB Flash disk will be removed!

This is completed from a computer running Windows Vista. Windows Server 2003 version of diskpart does not display flash memory drives.


1. select disk 1
2. clean
3. create partition primary
4. select partition 1
5. active
6. format fs=fat32
7. assign
8. exit

Now copy to the d:\winpe_x86\ISO folder contents to the USB disk (which I assume has letter E: assigned)

xcopy d:\winpe_x86\ISO\*.* E: /e /h

Now you should be able to boot from the USB Flash disk. Make sure to select the right boot device during the boot cycle or to change the boot order in your computer's BIOS.

NOTES:

  • Shutting down Windows PE - use wpeutil shutdown.
  • Adding a driver
    drvload.exe x:\lan\atl01_xp.inf
    Online - the drvload.exe command allows the driver to load after starting WindowsPE. Ideal for rarely used drivers.

    peimg /inf=c:\lan\atl01_xp.inf D:\WinPE_x86\Windows
    Offline - the peimg /inf command for adding a driver in the image. Suitable for frequently used devices, e.g. network card. Only specifying the path to the folder is not sufficient, but you have to enter the full name of the driver file (if you do not do this, the erorr 0x80070002 will appear) #
  • Change the language and location settings.
    The standard image has the QWERTY keyboard layout. Go back to step 2 to mount and do the following on the mounted image using intlcfg:
    intlcfg -inputlocale: -image:d:\winpe_x86\mount
    intlcfg -syslocale: -image:d:\winpe_x86\mount
    intlcfg -userlocale: -image:d:\winpe_x86\mount
    where is replaced by the locale you want (e.g. nl-be for Belgian Period keyboard).

Links:

1 comment:

amltzy said...

Now it's already 3.0 -5.0. And you can also try third-party pe builder:
http://www.aomeitech.com/pebuilder/tutorials/how-to-make-a-winpe-bootable-flash-drive-1004.html