Compartilhar via


OSD Pre-stage and UEFI Systems

Update:  A more recent blog post on these and other issues has been released at https://blogs.technet.com/b/system_center_configuration_manager_operating_system_deployment_support_blog/archive/2014/04/02/how-to-apply-task-sequence-prestaged-media-on-multi-partitioned-disks-for-bios-or-uefi-pcs-in-system-center-configuration-manager.aspx

 

The concept of pre-staging an operating system for deployment with OSD is well understood and effective. There is plenty of documentation detailing configuring pre-staging for legacy BIOS based systems. But what about pre-staging with UEFI based systems? I and a couple of colleagues struggled through this recently. The process if similar in concept to BIOS based systems but different in implementation.

Before I get to the details let me start from the beginning. Pre-staging in OSD is the process of pre-loading Windows PE and the image you want to deploy onto the hard disk of a system. A pre-stage scenario is often thought to be applicable only to PC OEM’s but is also applicable in other scenarios, such as an on premise build lab. In ConfigMgr 2012 you also have the ability to pre-stage any content referenced by the task sequence, such as packages or applications, which further conserves network resources and enhances the efficiency of a pre-stage scenario. Once loaded those systems are shut down and shipped to wherever they will reside. When powered up the system will boot back into Windows PE and apply the operating system that is already in place, along with any configured references, without the need to again download the content from the network.

The process of pre-staging systems requires a few configurations.

1. Import an Operating System WIM you wish to deploy

For my lab scenario I simply used the install.wim from the Windows 8 media. In earlier versions of ConfigMgr using the media based WIM directly would not work but in ConfigMgr 2012 this works fine.

clip_image002

2. Create a task sequence to deploy the WIM imported in step 1.

For my lab I simply use a basic task sequence without the format/partition step. Note: The drives on the system will already be formatted and information staged here as part of the pre-stage process so you don’t want to again partition and format and wipe that information away.

 

image

 

3. Create the Pre-staged media.

The Create Task Sequence Media option will allow you to launch the Pre-Stage media wizard, as shown. There are a number of options available on the wizard, including the ability to choose a task sequence that will be deployed as part of the pre-stage process. You also have the ability to choose drivers, applications and other content you wish to include as part of the pre-stage media.

image

In my lab the resulting media is called prestage.wim. As you read some of the documentation for BIOS based pre-stage the instructions will be to import the WIM created for pre-stage into the console so it can be referenced by the Apply Data Image task sequence option. For pre-staging with UEFI systems you should NOT use the Apply Data Image task sequence option and, instead, simply use ImageX or DISM. For that reason there really is no need to import the pre-stage WIM into the console and, as you will see, I simply reference it on a network location.

4. Create a task sequence to manage the pre-staging process.

The task sequence for staging the pre-stage WIM is where the magic happens so let’s slow down and work through the steps. The task sequence looks pretty basic, and it is, but there is a lot that happens here.

Connect C: to CAS

The first step of the task sequence is to map a network drive to a share in my environment. This share contains both the pre-stage WIM file and two scripts that will be used during the pre-stage process. In my case I chose the CAS to host these files.

image

Copy UEFI files

This step simply copies the two scripts that will be used in later steps into the root of the X:\ drive. The X:\ drive is the RAM disk created by PE when it starts up.

image

Partition Disks – UEFI

This step is used to partition and format the disk as needed for a UEFI system. The step leverages a diskpart script for controlling the action. I did NOT use the native Partition and Format step because I need a bit more control over the process than what is afforded in that step.

image

DiskPart script:

select disk 0
clean
convert GPT
create partition EFI size=200
format quick fs=fat32 label=EFI
assign letter=S

create partition MSR size=128

create partition primary
format quick fs=ntfs label=Windows
assign letter=C
list vol

DISM

This step applies the pre-stage WIM file to the C:\ drive. The WIM file is pulled from a network location that I mapped to earlier. Normally I would use the Apply Data Image step but there seem to be some things done in that step that don’t work well with UEFI so instead I use DISM directly.

image

Prepare Disks

This step make use of my second script to make sure files are positioned as needed ahead of shutting down the system and preparing for the reboot. The script references drive letters based on what was configured in the diskpart step earlier. Also, the script references the D: drive because this is what is normally associated with the boot media. Remember, X:\ is the Windows PE RAM disk but D:\ is the drive associated with the physical USB or CD based boot media. Depending on your specific system configuration you may need to alter the mapping.

image

Disk Configuration Script

xcopy d:\EFI\* S:\EFI\* /cherkyfs
xcopy d:\sources\* C:\sources\* /cherkyfs

copy d:\boot\boot.sdi C:\sources\
copy d:\efi\microsoft\boot\*.efi s:\efi\Microsoft\boot\*
copy d:\efi\boot\*.efi s:\efi\Microsoft\boot\*
copy X:\windows\boot\EFI\*.efi S:\EFI\Microsoft\Boot\*

del S:\EFI\Microsoft\Boot\BCD /f

bcdedit -createstore S:\EFI\Microsoft\Boot\BCD
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {bootmgr} /d "Boot Manager"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {globalsettings} /d "globalsettings"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {dbgsettings} /d "debugsettings"
bcdedit -store S:\EFI\Microsoft\Boot\BCD -create {ramdiskoptions} /d "ramdiskoptions"

For /f "Tokens=1,2,3" %%a in ('bcdedit -store S:\EFI\Microsoft\Boot\BCD -create /d "Windows PE" /application osloader') Do Set PreStagePEID=%%c

bcdedit -store S:\EFI\Microsoft\Boot\BCD /default %PreStagePEID%

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} device partition=s:
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} locale en-us
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {bootmgr} timeout 10

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} device ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} path \windows\system32\winload.efi
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} osdevice ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} systemroot \windows
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} winpe yes
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} nx optin
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {Default} detecthal yes
bcdedit -store S:\EFI\Microsoft\Boot\BCD -displayorder {Default} –addfirst

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {dbgsettings} debugtype Serial
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {dbgsettings} debugport 1
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {dbgsettings} baudrate 115200

bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {ramdiskoptions} ramdisksdidevice partition=C:
bcdedit -store S:\EFI\Microsoft\Boot\BCD -set {ramdiskoptions} ramdisksdipath \sources\boot.sdi

md c:\_SMSTaskSequence
md c:\_SMSTaskSequence\SMS
xcopy c:\sms\* c:\_SMSTaskSequence\sms\* /cherkyfs

 

Shutdown

The shutdown step forces a shutdown of the system. It may not seem like it but this is a critical step. If you fail to use this step and allow the task sequence to exit normally then the _SMSTaskSequence folder will be removed and the process will fail.

image

And that’s it – when you turn the system back on after a shutdown it should boot back into Windows PE to allow you to continue the imaging process but now most, if not all, of the content will be pre-loaded onto the hard disk. Overall, the process here is not too difficult but awfully frustrating if you had to figure this out on your own (trust me!).

A couple of closing observations that might help as well

- The UEFI boot process can take some time, particularly if you have PXE boot configured. It may appear the process is failing but if you wait long enough it should kick in.
- UEFI is architecture specific so if deploying a 64 bit OS you must use 64 bit boot media.
- In this example it is assumed that the source media being used is either CD or USB. This process was not tested on PXE but should work there as well, albeit a few tweaks may be needed.

Comments

  • Anonymous
    September 24, 2013
    Thanks for sharing this! Could you please update the screenshots, because they're not readable.

  • Anonymous
    October 02, 2013
    I agree that the screenshots are a bit blurry which is why I pasted all of the key text below each.

  • Anonymous
    November 07, 2013
    The comment has been removed

  • Anonymous
    January 30, 2014
    Thanks Steve.  Followed your instructions but when I turn the system back on after the shutdown, this is what happens.

  • WinPE loads
  • setting up devices
  • Shutting down It doesn't appear to load my pre-staged TS and in addition after the shutdown, I wouldn't boot anymore.  Any clues what this could be?  I'm on SCCM 2012 R2.