Walkthrough: Boot Windows PE from Hard Disk

This walkthrough describes how to boot Windows PE directly from a hard disk (or CDROM-Drive/USB-Flash-Disk) but not into RAM disk, which enables you to start a computer for the purposes of deployment or recovery.

Prerequisites To complete this walkthrough, you need the following:
A technician computer that provides all the tools and source files. For more information, see Building a Technician Computer.

Step 1: Create a Bootable Windows PE RAM Media

Select one of the options below and follow the instructions for building a bootable Windows PE RAM media. Make sure you include ImageX with your image. After you create your bootable media, continue to the next step.

Walkthrough: Create a Bootable Windows PE RAM Disk on CD/ROM 
Walkthrough: Create a Bootable Windows PE RAM Disk on UFD 

Step 2: Prepare the Hard Drive

In this step, you boot the new computer with your Windows PE media and format the hard drive.

On the new computer, insert your Windows PE media and restart the computer.
Windows PE will start and launch a Command Prompt window.

Note:  
If the hard drive contains an active partition, you must override the boot order to boot from the CD/DVD drive. During initial boot, select the appropriate function key to override the boot order. If this is a new computer, the hard drive will be unformatted, so you can skip this step.

At a command prompt, format the hard drive by using DiskPart. Windows PE requires an active partition with a size equal to or greater than the size of your Windows PE image. For example,

diskpart
select disk 0
clean
create partition primary size=<insert size>
select partition 1
active
format fs=ntfs
exit
 
Step 3: Copy Windows PE Files to the Hard Disk

In this step, you copy Windows PE resource files to the hard drive from your bootable media. You need ImageX to apply the Boot.wim to the hard drive. This example assumes the hard drive is blank.

At a command prompt, use ImageX to apply the Windows PE image (Boot.wim) from your bootable media to the hard drive. For example,

d:\imagex /apply d:\sources\boot.wim 1 c:

Where d: is your bootable Windows PE media that contains ImageX and a Windows PE image.

Copy the \boot folder from your bootable media to the root of your hard drive. For example,

xcopy d:\boot\*.* /e /f c:\boot\
 
Copy the Bootmgr file (no extension) from your bootable media to the root of your hard drive. For example,

copy d:\bootmgr c:

Delete the boot configuration data (BCD) file that you copied from your bootable media. (You will create a new one in the next step.) For example,

del c:\boot\bcd
 
Step 4: Configure BCD Store

In this step, you will create a new boot configuration file called BCD by using BCDEdit. BCD replaces Boot.ini. BCDEdit is a command/line tool designed to manage BCD stores. BCDEdit is available in Windows PE and Windows Vista. For example,

Bcdedit /createstore c:\temp\BCD
Bcdedit /store c:\temp\BCD /create {bootmgr} /d "Boot Manager"
Bcdedit /store c:\temp\BCD /set {bootmgr} device boot
Bcdedit /store c:\temp\BCD /create  /d "WINPE" /application osloader

The last command returns a GUID value. Substitute GUID with this value in the following examples.



Bcdedit /import c:\temp\BCD

Bcdedit /store c:\boot\BCD /set GUID osdevice partition=c: 
(change "partition=c:" to "boot" for CDR or UFD)
Bcdedit /store c:\boot\BCD /set GUID device partition=c: 
(change "partition=c:" to "boot" for CDR or UFD)

Bcdedit /store c:\boot\BCD /set GUID path \windows\system32\winload.exe
Bcdedit /store c:\boot\BCD /set GUID systemroot \windows

Bcdedit /store c:\boot\BCD /set GUID winpe yes
Bcdedit /store c:\boot\BCD /set GUID detecthal yes

Bcdedit /store c:\boot\BCD /displayorder GUID /addlast
 

Your computer is now ready to boot Windows PE directly from the hard disk.

How to create an entry to boot a WIM image from a hard disk

To create an entry to boot a Windows Imaging Format (WIM) image, you will need to create an OSloader type entry with RAMDISK options pointing to the boot partition. To do this, use the following procedure. In this procedure, the arcpath multi(0)disk(0)rdisk(0)partition(1) refers to the C: drive on the computer, and Boot.wim is a regular Boot.wim with Winload.exe in the System32 folder inside the WIM image.	

To create an entry to boot a WIM image from hard disk

1. Create the {ramdisktoptions} object in your BCD store by specifying the following. Drive should be the drive that contains the image.

bcdedit /create {ramdiskoptions} /d "Ramdisk options"
bcdedit /set {ramdiskoptions} ramdisksdidevice partition=c:
bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi

2. Create a new boot application entry by specifying:

bcdedit /create /d "Boot from WIM" /application OSLOADER

3. This will return an identifier (GUID) for the newly created entry. This new entry will be referred to as {GUID} in the rest of this procedure. Next specify the following:

bcdedit /set {GUID} device ramdisk=[c:]\sources\boot.wim,{ramdiskoptions}
bcdedit /set {GUID} osdevice ramdisk=[c:]\sources\boot.wim,{ramdiskoptions}
bcdedit /set {GUID} path \windows\system32\winload.exe
bcdedit /set {GUID} systemroot \windows

4. If you are booting into Windows Preinstallation Environment (Windows PE), then you will also need to specify:

bcdedit /set {GUID} winpe yes
bcdedit /set {GUID} detecthal yes

5. Next specify the following to add your new entry to the display order:

bcdedit /displayorder {GUID} /addlast


How to modify BCD when installing a previous version of Windows onto a computer running Windows Vista

To install an older Windows operating system on a computer running Windows Vista, use the following procedure. 	
To install a previous version of Windows onto a computer running Windows Vista

1. Install the previous version of Windows. 

2. Log on to the older operating system and restore the latest boot manager by running the following. Fixntfs.exe will be in the \boot directory of the active partition.

fixntfs /lh (Change to bootsect /nt60 c:)

3. Create a BCD entry for the older operating system by specifying the following. Bcdedit.exe is located in the \Windows\System32 directory of the Windows Vista partition. Description is the description of the new entry for the older operating system.

Bcdedit /create {ntldr} /d "Windows Legacy OS Loader"
Bcdedit /set {ntldr} device boot
Bcdedit /set {ntldr} path \ntldr
Bcdedit /displayorder {ntldr} /addlast

4. The following command sets the legacy Windows loader (Ntldr) as the default
entry: {466f5a88-0af2-4f76-9038-095b170dc21c} is the predefined GUID for Ntldr.

bcdedit /default {ntldr}

5. the following command sets the boot manager TimeOut to 15 seconds:

bcdedit /timeout 15

6. Restart the computer in order for the changes to take effect.
