Reboot To PXE in a ConfigMgr Task Sequence

This article discusses how ConfigMgr task sequences can be created to allow a reboot back into PXE boot for deployment.

Overview

When deploying a new, unconfigured server, there are no configured disks from which to boot. This means that the system must boot from other media, such as a CD\DVD drive, from USB, or from the network via PXE. At times, the server being deployed may need to be rebooted during the task sequence in order to complete initialization of a configuration, such as defining array disks. In fact, if the disks on a system are defined or redefined after WinPE boots, WinPE does not recognize the new system partition, which means a reboot is necessary in order to successfully complete a deployment.

The primary issue is that when using a “Reboot Computer” standard action within the task sequence editor, the action requires a writeable partition, either to reboot into the existing OS, or to copy down WinPE to the disk and reboot to WinPE again. If you assign a reboot task to a machine and these conditions do not exist, the task sequence will fail at that action. The capability of rebooting the machine in the middle of a task sequence without a valid boot partition does not exist.

If you were using PXE and the machine were to simply end the task sequence and reboot on its own, Configuration Manager will not re-advertise the PXE boot to the computer. The PXE advertisement must be reset if it is to run the same task sequence again. This means the server would likely reboot into an unknown state and stop at a “No Operating System” prompt. You could assign a second task sequence to the machine, but when the first task sequence ended, the second would start immediately, without a reboot between them.

If you were using boot media such as a USB drive or CD/DVD media, the result would be the same in that the task would fail when the reboot task was run because a valid boot partition did not exist. If you simply made the task sequence end instead of using a reboot, the system would reboot and start the task sequence again, but without some sort of conditional flow control, it would simply re-run the same tasks over and over.

The Solution

The solution relies on resolving several different issues by doing the following:
  • Setting a machine variable during the task sequence
  • Using that variable to control which steps are run during that task sequence
  • Using WMI remote calls to reset the PXE advertisement for the computer

In order to control the flow of the task sequence across reboots, groups are created that run based on the value of a machine variable. This machine variable is set by the client running the task sequence via script. The general layout of the task sequence is as follows:
  • Restart In WinPE (if not in WinPE)
  • Set task sequence variable : increment by 1
  • Group 1 (Condition: variable = 1)
    • Actions needed before 1st reboot
    • Run command line task – run a script to reset the PXE advertisement
  • Group 2 (Condition: variable = 2)
    • Actions needed before reboot #2
    • Run command line task – run a script to reset the PXE advertisement
  • Group 3 (Condition: variable = 3)
    • Additional actions, including standard reboot actions
    • Reset task sequence variable to 0

Given the above, here is how that task sequence would flow on the target machine:
  • Boot #1
    • Computer boots WinPE via PXE. (Task sequence variable not set)
    • Script sets task sequence variable to 1
    • Group 1 condition evaluates to TRUE
      • Actions inside group 1 run
      • PXE advertisement is reset
    • Group 2 condition evaluates to FALSE, steps skipped
    • Group 3 condition evaluates to FALSE, steps skipped
    • Task sequence runs out of steps to perform, so WinPE reboots the machine
  • Boot #2
    • Computer boots and uses PXE to load WinPE again
    • Script sets task sequence variable to 2
    • Group 1 condition evaluates to FALSE, steps skipped
    • Group 2 condition evaluates to TRUE
      • Actions inside group 2 run
      • PXE advertisement is reset
    • Group 3 condition evaluates to FALSE, steps skipped
    • Task sequence runs out of steps to perform, so WinPE reboots the machine
  • Boot #3
    • Computer boots and uses PXE to load WinPE again
    • Script sets task sequence variable to 2
    • Group 1 condition evaluates to FALSE, steps skipped
    • Group 2 condition evaluates to FALSE, steps skipped
    • Group 3 condition evaluates to TRUE
      • The task sequence variable reset to 0
      • Actions inside group 3 run
      • Task sequence ends and computer reboots (to final OS loaded on disk)

Putting It All Together

Ok, so now that you know the basic steps and how it works, now you get to put all of this together. Using the sample scripts and code available in this project, you can save a lot of time in getting this done.
First of all, here are some links to the file you will need:
The only problem is that this particular script expects to be run from a custom task sequence. So, you can either modify the script or create a custom action. I will have more on this later.

Last edited Jul 1, 2009 at 6:42 PM by rhearn, version 2

Comments

No comments yet.