Skip to content

Grace-Solutions/HiddenRecoveryPartition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HiddenRecoveryPartition

A Windows recovery partition solution that enables automatic operating system backup and restore functionality using a hidden recovery partition. This solution leverages Microsoft Deployment Toolkit (MDT), Windows PE, and Windows Recovery Environment (WinRE) to create a Dell/HP/Lenovo-style factory reset capability for custom Windows deployments.

Overview

This solution creates a hidden recovery partition that stores a complete Windows image backup. When triggered (via boot key or automatic recovery), the system boots into Windows PE and either:

  • Creates a recovery image of the current OS installation
  • Restores the OS from a previously created recovery image

Features

  • Hidden Recovery Partition: Uses partition type 0x27 (MBR) or GUID de94bba4-06d1-4d40-a16a-bfd50179d6ac (GPT) to hide the recovery partition from Windows
  • Boot Key Support: Configure a function key (F1-F12) to boot directly into recovery mode
  • Dual Architecture: Supports both x86 and x64 Windows installations
  • Legacy and UEFI Support: Automatically detects BIOS mode and adjusts recovery operations accordingly
  • Automatic Detection: Can detect newer recovery scripts from optical media for updates

Prerequisites

  • Microsoft Deployment Toolkit (MDT) with Generic Windows PE boot images generated
  • Windows Assessment and Deployment Kit (ADK)
  • Administrator privileges on the target system
  • A disk layout with:
    • Partition 1: Recovery partition (labeled "RECOVERY")
    • Partition 2: OS partition (labeled "OS")
    • Optional: Data partition (labeled "DATA")

Directory Structure

HiddenRecoveryPartition/
├── Diskpart/
│   ├── 0x27.txt                      # DiskPart script to set partition type 0x27 (MBR)
│   └── de94bba4-06d1-4d40-a16a-bfd50179d6ac.txt  # DiskPart script for GPT
├── HiddenRecoveryPartition/
│   ├── ConfigureRecoveryPartition.vbs    # Configures Windows Recovery Agent
│   ├── ModifyGenericWindowsPE.vbs        # Customizes MDT boot images
│   └── WindowsPE/
│       ├── x64/                          # 64-bit PE resources
│       │   ├── Scripts/
│       │   │   ├── Initialize.vbs        # PE startup script
│       │   │   └── Recovery.vbs          # Main recovery logic
│       │   ├── Tools/                    # Architecture-specific tools
│       │   ├── Unattend.xml              # PE automation config
│       │   └── Windows/                  # Additional Windows components
│       └── x86/                          # 32-bit PE resources (same structure)
└── README.md

Setup Instructions

Step 1: Prepare the Generic Windows PE Boot Images

Run ModifyGenericWindowsPE.vbs to customize the MDT generic boot images with recovery scripts:

cscript.exe "HiddenRecoveryPartition\ModifyGenericWindowsPE.vbs"

This script will:

  1. Prompt you to select your MDT Deployment Share
  2. Mount the Generic_x86.wim and Generic_x64.wim boot images
  3. Copy the recovery scripts and tools into the WIM files
  4. Commit changes and output the modified images to {DeployShare}\Custom\HiddenRecoveryPartition\Output\

Step 2: Configure the Recovery Partition

After deploying Windows to a machine with the appropriate partition layout, run:

cscript.exe "HiddenRecoveryPartition\ConfigureRecoveryPartition.vbs" /Bootkey:"F11"

The /Bootkey parameter is optional. Supported values: F1, F2, F3, F4, F6, F7, F9, F10, F11, F12

This script will:

  1. Assign a drive letter to the recovery partition
  2. Copy the recovery environment files (Winre.wim, boot.sdi)
  3. Configure the Windows Recovery Agent (reagentc.exe)
  4. Remove the recovery partition drive letter
  5. Configure BCD to ignore minor boot failures

Step 3: Hide the Recovery Partition

For MBR (Legacy BIOS) Systems:

diskpart /s "Diskpart\0x27.txt"

For GPT (UEFI) Systems:

diskpart /s "Diskpart\de94bba4-06d1-4d40-a16a-bfd50179d6ac.txt"

Note: These scripts target Disk 0, Partition 1. Modify if your layout differs.

DiskPart Scripts

0x27.txt (MBR/Legacy)

Sets the partition type to 0x27 (OEM Recovery Partition), which hides it from Windows Explorer.

de94bba4-06d1-4d40-a16a-bfd50179d6ac.txt (GPT/UEFI)

Sets the partition GUID type and applies GPT attributes to hide and protect the partition:

  • GUID: de94bba4-06d1-4d40-a16a-bfd50179d6ac (Windows Recovery Environment)
  • Attributes: 0x8000000000000001 (Required partition + No drive letter)

How Recovery Works

  1. Trigger Recovery: Boot using the configured function key or through Windows Recovery options
  2. Windows PE Loads: The hidden recovery partition boots into Windows PE
  3. Initialize.vbs Runs: Checks for updates on optical media, then launches Recovery.vbs
  4. Recovery.vbs Executes:
    • Detects BIOS mode (Legacy/UEFI)
    • Locates the RECOVERY, OS, and DATA partitions
    • If no recovery image exists: Creates Install.wim from the OS partition
    • If recovery image exists: Prompts user to restore with confirmation

Boot Key Scan Codes

Key Scan Code
F1 0x3b00
F2 0x3c00
F3 0x3d00
F4 0x3e00
F6 0x4000
F7 0x4100
F9 0x4300
F10 0x4400
F11 0x8500
F12 0x8600

Note: F5 and F8 are reserved by Microsoft and cannot be used.

Partition Labels

The solution expects specific volume labels:

  • RECOVERY: The hidden recovery partition containing WinRE and recovery images
  • OS: The main Windows operating system partition
  • DATA: Optional data partition (preserved during recovery)

Troubleshooting

  • Recovery partition not detected: Ensure the volume label is exactly "RECOVERY"
  • Boot key not working: Verify reagentc is properly configured: reagentc /info
  • WIM mount failures: Run dism /cleanup-wim to clear stale mount points
  • Architecture mismatch: Ensure you're using the correct x86/x64 boot image for your OS

License

See LICENSE for details.

About

A Windows recovery partition solution that enables automatic operating system backup and restore functionality using a hidden recovery partition. This solution leverages Microsoft Deployment Toolkit (MDT), Windows PE, and Windows Recovery Environment (WinRE) to create a Dell/HP/Lenovo-style factory reset capability for custom Windows deployments.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors