Partilhar via


Bare Metal Reset/Recovery: Enable Your Users to Create Media and to Recover Hard Drive Space

This walkthrough describes how to configure the Windows RE push-button reset features to fully recreate the partition structure of the hard drive. This procedure is also known as a bare-metal recovery. This procedure can be performed if a user needs to replace their hard drive or completely wipe it clean.

You can supply media with a recovery image instead of, or in addition to, including a recovery image on the PC.

You can also configure the PC to enable users to create their own recovery media. When properly configured, users can use this option to reclaim the hard drive space from the recovery image partition when needed.

In this topic:

Creating Configuration Files to Prepare Recovery Media

You can use the same configuration files to:

  • Enable your users to create their own recovery media.

  • Create your own recovery media for inclusion on the PC.

To create a push-button reset configuration file

  1. In Notepad, create a configuration file that points to your push-button reset partition script.

    The following examples are based on the recommended partition configurations in the following topics:

    For information about configuring this file, see ResetConfig XML Reference.

    To customize your push-button reset, you can also add your extensibility script locations to this configuration file. For more information, see the Add a Script to Push-Button Reset Features topic.

    UEFI:

    <?xml version="1.0" encoding="utf-8"?>
    <!-- ResetConfig.xml for UEFI -->
    <Reset>
        <!-- May be combined with custom scripts – insert Run Phase elements here -->
        <SystemDisk>
            <DiskpartScriptPath>ResetPartitions-UEFI.txt</DiskpartScriptPath>
            <MinSize>75000</MinSize>
            <WindowsREPartition>1</WindowsREPartition>
            <WindowsREPath>Recovery\WindowsRE</WindowsREPath>
            <OSPartition>4</OSPartition>
            <RecoveryImagePartition>5</RecoveryImagePartition>
            <RecoveryImagePath>RecoveryImage</RecoveryImagePath>
            <RestoreFromIndex>1</RestoreFromIndex>
            <RecoveryImageIndex>1</RecoveryImageIndex>
        </SystemDisk>
    </Reset>
    

    BIOS:

    <?xml version="1.0" encoding="utf-8"?>
    <!-- ResetConfig.xml for BIOS -->
    <Reset>
        <!-- May be combined with custom scripts – insert Run Phase elements here -->
        <SystemDisk>
            <DiskpartScriptPath>ResetPartitions-BIOS.txt</DiskpartScriptPath>
            <MinSize>75000</MinSize>
            <WindowsREPartition>1</WindowsREPartition>
            <WindowsREPath>Recovery\WindowsRE</WindowsREPath>
            <OSPartition>2</OSPartition>
            <RecoveryImagePartition>3</RecoveryImagePartition>
            <RecoveryImagePath>RecoveryImage</RecoveryImagePath>
            <RestoreFromIndex>1</RestoreFromIndex>
            <RecoveryImageIndex>1</RecoveryImageIndex>
        </SystemDisk>
    </Reset>
    
  2. Save the file using the UTF-8 file format:

    Click File, and then click Save As. In the Encoding box, select UTF-8, and save this file as E:\Recovery\RecoveryImage\ResetConfig.xml.

To create a partition reset script

  1. In Notepad, create a configuration file that repartitions the hard drive after the hard drive has been reset. This script should be the same as the script used to create partitions on the hard drive, with the following exceptions:

    • The script should not contain commands to select or clean the drive. The system drive is identified automatically by Windows RE. For more information, see Identifying the System Drive later in this topic.

    • The script should assign letters to the Windows RE tools partition (UEFI), the system partition, the Windows partition, and the recovery image partition.

    The following examples are based on using the following sample Diskpart scripts, located in the associated topics:

    UEFI:

    rem == ResetPartitions-UEFI.txt ==
    rem == These commands are used with DiskPart to
    rem    reset the drive and recreate five partitions
    rem    for a UEFI/GPT-based computer.
    rem    Adjust the partition sizes to fill the drive
    rem    as necessary. ==
    rem == The differences between this file and
    rem    CreatePartitions-UEFI.txt
    rem    are noted in parenthesis.
    rem       (NOT USED: select disk 0)
    rem       (NOT USED: clean)
    convert gpt
    rem == 1. Windows RE tools partition ===============
    create partition primary size=300
    format quick fs=ntfs label="Windows RE tools"
    assign letter="T"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    rem == 2. System partition =========================
    create partition efi size=100
    rem ** NOTE: For Advanced Format 4Kn drives,
    rem          change this value to size = 260 **
    format quick fs=fat32 label="System"
    assign letter="S"
    rem == 3. Microsoft Reserved (MSR) partition =======
    create partition msr size=128
    rem == 4. Windows partition ========================
    rem ==    a. Create the Windows partition ==========
    create partition primary 
    rem ==    b. Create space for the recovery image ===
    shrink minimum=15000
    rem ==    c. Prepare the Windows partition ========= 
    format quick fs=ntfs label="Windows"
    assign letter="W"
    rem === 5. Recovery image partition ================
    create partition primary
    format quick fs=ntfs label="Recovery image"
    assign letter="R"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    list volume
    exit
    

    BIOS:

    rem == ResetPartitions-BIOS.txt ==
    rem == These commands are used with DiskPart to
    rem    reset the drive and create three partitions
    rem    for a BIOS/MBR-based computer.
    rem    Adjust the partition sizes to fill the drive
    rem    as necessary. ==
    rem == The differences between this file and
    rem    CreatePartitions-BIOS.txt
    rem    are noted in parenthesis.
    rem       (NOT USED: select disk 0 )
    rem       (NOT USED: clean )
    rem == 1. System partition ======================
    create partition primary size=350
    format quick fs=ntfs label="System"
    assign letter="S"
    active
    rem == 2. Windows partition =====================
    rem ==    a. Create the Windows partition =======
    create partition primary
    rem ==    b. Create space for the recovery image  
    shrink minimum=15000
    rem ==    c. Prepare the Windows partition ====== 
    format quick fs=ntfs label="Windows"
    assign letter="W"
    rem == 3. Recovery image partition ==============
    create partition primary
    format quick fs=ntfs label="Recovery image"
    assign letter="R" 
    set id=27
    list volume
    exit
    
  2. Save your completed file as either E:\Recovery\RecoveryImage\ResetPartitions-UEFI.txt or E:\Recovery\RecoveryImage\ResetPartitions-BIOS.txt, based on your firmware type.

    To hide the recovery partition drive letters, or to reset your custom OEM partitions, you can add a custom script. For more information, see Add a Script to Push-Button Reset Features.

Enabling Your Users to Create Media and to Recover Hard Drive Space

Users can use this option to create recovery media, and to reclaim the hard drive space from the recovery image partition when needed.

Step 1: Design your partitions so hard drive space can be recovered into the Windows partition

Step 2: Add the configuration files to the destination computer

  1. On your destination computer, insert the USB flash drive with the configuration files.

  2. Copy the configuration files to the destination computer:

    Copy E:\Recovery\RecoveryImage\* R:\RecoveryImage\*
    

    where E is the drive letter of the USB flash drive and R is the drive letter of the recovery image partition.

Step 3: Test that Windows can create external media and reclaim hard drive space

  1. Restart the destination computer, and complete Out-Of-Box Experience (OOBE).

  2. Open File Explorer. Right-click Computer, and select Manage. Click Disk Management.

  3. Confirm that the recovery partition exists. Leave the Disk Management window open.

  4. Click Start, type create a recovery drive, select the Settings search scope, and then select Create a recovery drive.

  5. Insert a USB flash drive.

  6. Select Copy the contents from the recovery partition to the recovery drive > Next > Next > Create.

  7. After the USB flash drive is created, select Delete the recovery partition. Windows removes the recovery partition, and reclaims the hard drive space into the Windows partition.

  8. Restore the Disk Management window. Click Action > Refresh. Confirm that the recovery partition no longer exists, and that the drive space has been reclaimed into the Windows partition.

  9. Confirm that the USB drive is successfully created. Optionally, verify that any customizations are present and that they function as intended.

Step 4: Test the recovery media

  1. On a computer that has no operating system, insert your recovery media.

  2. Start the computer, press a key to open the firmware boot menus, and then select the appropriate boot device.

  3. At the Windows RE Tools menus, select a keyboard layout, for example, US.

  4. Click Troubleshoot > Reset your PC > Next.

Note

If you are testing on the same computer, and you have not cleaned the hard drive, you may be prompted to select a drive. Select Windows 8.

Select **Yes, repartition the drives** \> **Just remove my files** \> **Reset**.

Important

Troubleshooting:

  • Make sure that ResetConfig.xml is saved as a UTF-8 file.

  • Make sure that the filename listed in the <DiskpartScriptPath>ResetPartitions-BIOS.txt</DiskpartScriptPath> element of the ResetConfig.xml file matches the filename in the Diskpart script.

  • Make sure that the Diskpart script doesn't include commands to select the drive or clean the drive (select disk 0, clean).

  1. Optionally, verify that your customizations exist and function as intended.

Identifying the System Drive

Windows identifies the system drive using the following methods:

BIOS-based computers: the BIOS-reported system drive is used.

UEFI-based computers: When Windows RE is enabled by using the reagentc /setreimage command, Windows writes the adaptor location path and GUID of the system disk to a UEFI variable. This step is only performed when both the system and OS partitions are on the system drive. The variable is updated if necessary when Windows RE gets disabled and then re-enabled.

If multiple local drives are detected, Windows identifies the system drive by searching in the following order:

  1. Windows searches for a drive with a GUID matching the value stored in firmware.

  2. Windows searches for a drive with a location path matching the value stored in firmware.

  3. Windows searches for a drive with an existing ESP.

    If multiple drives with ESP are found, the recovery process will not proceed.

  4. Windows searches for an uninitialized (raw) disk.

    If multiple uninitialized disks are found, the recovery process will not proceed.

Next steps

Large-Scale Deployment

See Also

Tasks

Add a Script to Push-Button Reset Features

Reference

ResetConfig XML Reference
REAgentC Command-Line Options

Concepts

Push-Button Reset Overview