Sunday, October 07, 2007 10:42 AM bart

Getting started with Windows PE 2.0 for Windows Vista: boot Windows from a USB flash drive

This is going to be a somewhat unfamiliar post on my blog. The history for it goes back to 2003-2004 when I was involved in a local Microsoft Belux project called "SchoolServer". At that time, we used a Windows PE (where PE stands for "Pre-Installation Environment" and not "Portable Executable") version extracted from the Windows Server 2003 branch (NT 5.2), which was available to volume licensing customers only. But what's Windows PE?

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 (as we'll see it goes further than that in v2.0).

The reason to use it is pretty straightforward: for "Pre-Installation" tasks, such as disk partitioning, or even to build a (scripted) system setup that runs in a familiar Windows environment right from the start (e.g. generating a winnt.sif unattended installation file using a nice graphical wizard, making the right partitions, copying setup sources to the harddrive and invoking setup using winnt.exe or so). But also for day-to-day computer (disk) administration tasks, this proves very useful. Indeed, Microsoft's Windows PE solution isn't the only one out there but are others as well which have similar ideas like BartPE (I'm not that Bart).

If you've installed Windows Vista or Windows Server 2008 already (I hope you did), you'll have noticed that there's no blue-background textual setup anymore, the system boots into Windows from the cd to have an end-to-end graphical setup which is based on the Windows PE technology. As a developer I loved to have such a Windows PE version myself bootable from USB Flash and for free. In this post I explain how I did it from A to Z. I'll also explain how to create an ISO image for Windows PE cd's.

 

Getting started: download and install the WAIK

WAIK stands for the Windows Automated Installation Kit and is available as a download. It's a big download, but it's worth to put your connection under stress for :-). Burn it to a cd or mount it using some ISO/IMG mounting tool and install it.

 

The Windows PE Tools Command Prompt

Next, open up the Windows PE Tools Command Prompt from the Start Menu and make sure to Run as Administrator:

image

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

image

You should see something like this:

image

Notice the message points you at a few usable executables: peimg, oscdimg and imagex. We're going to use these in a minute.

 

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 c:\winpe_x86

    This makes a copy of the Windows PE files to the specified folder. Alternatively, you can specify amd64 for 64-bit machines. We'll manipulate this folder in the next steps.

    image
  2. Next, you can customize the Windows PE image (using the Windows Imaging Format, aka WIM) using ImageX:

    image

    You can mount a WIM file to a folder like this:

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

    image

    image

    For the curious, 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, like this:

    > peimg /list /image=c:\winpe_x86\mount\Windows

    to show a list of all images:

    image

    Next, you can add packages by calling:

    > peimg /install=<package> c:\winpe_x86\mount\Windows

    where package is either * (all packages) or one from the list shown by invoking peimg with the /list switch.
  4. You could add drivers and language packs as well, but for that I refer kindly to the excellent help documentation that comes with the WAIK. When you're done with the image customization, run peimg with the prep switch:

    > peimg /prep c:\winpe_x86\mount\Windows

    and unmount the image using ImageX:

    > imagex /unmount c:\winpe_x86\mount /commit

    and copy the created .wim file to the ISO folder:

    > copy c:\winpe_x86\winpe.wim c:\winpe_x86\ISO\sources\boot.wim
  5. Next you can create an ISO file for the image using oscdimg:

    > oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO c:\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:

    image
  6. To test your image, just create a new Virtual PC virtual machine (e.g. with 256 MB of RAM) and mount the ISO file. No harddisk or network adapters needed:

    image

    VPC should boot like this:

    image    image    image

    Feel free to start taskmgr and notepad or so to get familiar with your next big friend :-). Finally shut it down using wpeutil shutdown.
  7. You might have noticed the image has the QWERTY keyboard layout, but you can change that if you like to do so. Go back to step 2 to mount and do the following on the mounted image using intlcfg:

    > intlcfg -inputlocale:<locale> -image:c:\winpe_x86\mount
    > intlcfg -syslocale:<locale> -image:c:\winpe_x86\mount
    > intlcfg -userlocale:<locale> -image:c:\winpe_x86\mount

    where <locale> is replaced by the locale you want (e.g. nl-be for Belgian Period keyboard).

    image

    Go back to step 4 to unmount, commit, prep and create the iso. Rerun VPC to test.

    For the curious, this changes some of the <mount>\Windows\System32\config\*.* registry hives:

    image

    In regedit.exe you can mount these hives to see what's in. To do this, open regedit, select HKLM and choose File, Load Hive. Next select the file to load (e.g. DEFAULT) and specify a name for the loaded hive (e.g. Mount):

    image

    As you can see, intlcfg has changed the Keyboard Layout\Preload list. Of course, the hardcore ones of you might prefer to make changes to the registry hive directly this way. By the way, while you're in the loaded hive, check out other settings like:

    - desktop wallpaper via Control Panel\Desktop\WallPaper
    - (from the SYSTEM hive) command line to invoke after starting Windows PE via Setup\Cmdline

    Tip: regedit.exe is also available in Windows PE itself, so you can check the outcome over there. However, changes mage while running Windows PE won't take effect since the registry is loaded in memory.
  8. Finally, it's time to put the whole thing on a USB Flash key or to burn the ISO created in step 5 to a cd-rom. I'll cover the former option. 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!

    > select disk 1
    > clean
    > create partition primary
    > select partition 1
    > active
    > format fs=fat32
    > assign
    > exit

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

    > xcopy c:\winpe_x86\ISO\*.* E: /E
  9. 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.

 

Enjoy!

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under:

Comments

# microsoft &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot Windows from a USB flash drive

Pingback from  microsoft &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot Windows from a USB flash drive

# re: Getting started with Windows PE 2.0 for Windows Vista: boot Windows from a USB flash drive

Sunday, October 07, 2007 2:09 PM by Depechie

This is just brilliant ! Where is my usb key :)

# Kefrotate.Com &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot &#8230;

Pingback from  Kefrotate.Com &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot &#8230;

# New and Notable 196

Tuesday, October 09, 2007 6:00 AM by Sam Gentile

WCF/BizTalk Services Brian talks about the new CodeRush 2.5.4 WCF Templates which take the drudgery out

# Boot vista from a flash drive

Tuesday, October 09, 2007 7:17 AM by DotNetKicks.com

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# Vista booting and running from a USB Disk &laquo; Musings in Code

Wednesday, October 10, 2007 2:43 AM by Vista booting and running from a USB Disk « Musings in Code

Pingback from  Vista booting and running from a USB Disk &laquo; Musings in Code

# S&#243; o Bart consegue isso...

Thursday, October 11, 2007 5:21 AM by Dennes

Existem certos assuntos que realmente me dão até alergia. Distribuição de software, na área de...

# Windows Vista no Pen Drive (running from a Flash Drive)

Thursday, October 11, 2007 9:39 AM by Carlos Fernando Paleo da Rocha
SBS MVP in Brazil

This is a translation froma GREAT post at: community.bartdesmet.net/.../10

# re: Getting started with Windows PE 2.0 for Windows Vista: boot Windows from a USB flash drive

Thursday, October 11, 2007 9:40 AM by Carlos

I have just translated this to portuguese here, so now even people whom doesnt understand english can take advantage from this GREAT post. Many thanks!

msmvps.com/.../windows-vista-no-pen-drive-running-from-a-flash-drive.aspx

# Windows Vista no Pen Drive (running from a Flash Drive)

Thursday, October 11, 2007 10:17 AM by Tecnologias

This is a translation froma GREAT post at: community.bartdesmet.net/.../10

# layout &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot &#8230;

Pingback from  layout &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot &#8230;

# wallpaper &raquo; Blog Archive &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot &#8230;

Pingback from  wallpaper  &raquo; Blog Archive   &raquo; Getting started with Windows PE 2.0 for Windows Vista: boot &#8230;

# Rendere una pen-drive avviabile con Windows Vista

Wednesday, October 24, 2007 10:04 AM by Alessandro Del Sole's Blog

# Rendere una pen-drive avviabile con Windows Vista

Wednesday, October 24, 2007 10:13 AM by Alessandro Del Sole's Blog

# http://community.bartdesmet.net/blogs/bart/archive/2007/10/07/getting-started-with-windows-pe-2-0-for-windows-vista-boot-windows-from-a-usb-flash-drive.aspx

# http://bartdesmet.net/blogs/bart/archive/2007/10/07/getting-started-with-windows-pe-2-0-for-windows-vista-boot-windows-from-a-usb-flash-drive.aspx

# http://blog.bartdesmet.net/blogs/bart/archive/2007/10/07/getting-started-with-windows-pe-2-0-for-windows-vista-boot-windows-from-a-usb-flash-drive.aspx

# New and Notable 196

Tuesday, December 02, 2008 4:45 PM by Sam Gentile's Blog

WCF/BizTalk Services Brian talks about the new CodeRush 2.5.4 WCF Templates which take the drudgery out of the boilerplate stuff. I have gone personally to a combination of Resharper + CodeRush. I use Resharper for all the Refactoring plus the code analysis

# appleugg&#8217;s blogs &raquo; Blog Archive &raquo; boot Windows from a USB flash drive

Pingback from  appleugg&#8217;s blogs  &raquo; Blog Archive   &raquo; boot Windows from a USB flash drive

# Edition Portable | Hawthorns Restaurant Supply

Wednesday, November 03, 2010 5:01 PM by Edition Portable | Hawthorns Restaurant Supply

Pingback from  Edition Portable | Hawthorns Restaurant Supply

# Q&amp;A: how can i install Portable WinXP USB stick Edition 2? | How to Windows

Pingback from  Q&amp;A: how can i install Portable WinXP USB stick Edition 2? | How to Windows