Windows Recovery Environment

Also known as WinRE

During an install, Windows will create a Recovery partition. If you deploy Windows manually for an install you will use diskpart to create the needed partitions, dism to install, and reagentc to manually link your recovery tools. It’s best practice to have them on a separate partition where they can’t normally be accessed.

Windows uses this layout for new installs:

  1. EFI > MSR > Recovery > Windows (1903 and earlier)

  2. EFI > MSR > Windows > Recovery (1909 and later)

I personally do not recommend using layout #2 as used in builds 1909 and later. This does make it easier to grow the Recovery partition, but limits users on Data partitions. Microsoft even details why this an issue. I highly recommend you use layout #1. In fact, here is the layout I use and their sizes:

  • EFI (200mb) > MSR (16mb) > Recovery (1gb) > Windows (remaining free space)

WARNING! If you create fresh boot files, rebuild boot files, or move partitions around using a third party tool, the Recovery partition link is missing or broken. You need to relink them. You can verify if the Recovery tools are working by typing in bcedit /enum and looking for:

Windows Boot Loader
-------------------
recoverysequence {0000000-0000-0000-0000-0000000000}
recoveryenabled Yes

You should know that this information is stored in a unique way. Because volumes/partitions do not mount in a specified order outside of Windows online, the BCD store has to use device path trees under GLOBALROOT to locate the Recovery partition. Hence why you might see the Windows partition mounted as a different letter other than C when booted from a working Recovery or a USB (if you have multiple disks and partitions). To see recovery information, type in reagentc /info. This is why moving partitions around using a third party tool will break the link. The Recovery tools was setup with Partition 3, Disk 0 as being the location. Looking at the example below, If you moved Recovery to Partition 4, then Windows cannot locate it.

Windows Recovery Environment (Windows RE) and system reset configuration
Information:
​
Windows RE status: Enabled
Windows RE location: \\?\GLOBALROOT\device\harddisk0\partition3\Recovery\WindowsRE
Boot Configuration Data (BCD) identifier: 00000000-0000-0000-0000-000000000000
Recovery image location:
Recovery image index: 0
Custom image location:
Custom image index: 0
​
REAGENTC.EXE: Operation Successful.

Those users who delete this partition because they insist on having the space... Stop. You're not really saving any space in so doing so. Just having them separated means the are much less likely to get damaged. If you used a standard Windows install through the GUI and deleted this partition, you have successfully removed your only recovery tools. Additionally, if you have Windows 1903 or earlier, once you delete this partition, you can't reclaim its space through Windows. You can reclaim free space to the right but not the left. This is a limitation to prevent data loss. You can use third party tools but there is a huge risk involved. Please stop. If you have Windows 1909 or later using the default layout, you can delete this partition and merge the free space to Windows, but this does not mean you should. Please leave it alone.

If you have a Recovery partition present, great! If you do not have Recovery partition, please read the "Exclusions" section. For this example, I'm going to show how to relink the tools after having repaired damaged/missing boot files. This assumes you have installed Windows with the GUI using the default 1909 and later layout:

While Windows is booted, open PowerShell as an admin:

  1. diskpart

  2. list disk

  3. select disk # - Replace # with the target disk you want to use.

  4. detail disk - Make sure you have the correct disk.

  5. select part 4 - This should be partition 4

  6. assign letter=R

  7. exit

  8. reagentc /disable

  9. reagentc /setreimage /path R:\Recovery\WindowsRE

  10. reagentc /enable

  11. diskpart

  12. list disk

  13. select disk #

  14. select part 4

  15. remove letter=R

  16. exit

Verify if the Recovery tools are working by typing in bcedit /enum. If you see the recovery sequence, you're all set.

Exclusions

But what if the above steps don't apply to you? Don't have the Recovery Partition? If you did not follow the correct procedure with a manual install, Windows will default to using the recovery tools on the system partition (if present). This isn't ideal and should be changed.

If you have the ability, you should create yourself a recovery partition. If you already have unallocated space, or need to create a new partition by shrinking another, please do so with Disk Manager. Then mount a Windows install ISO or plug in your install USB. Go to the following location:

  • X:\sources\install.esd\[1|2|3|4|5|6]\Windows\System32\Recovery

Xrefers to the mounted path of the USB device or ISO and [1|2|3|4|5|6] refers to the index of your install.

For this example, I'm going to use the USB device. My USB is mounted at D: and my index is 6. I'll use 7-Zip File Manager to open install.esd and navigate to:

  • D:\sources\install.esd\6\Windows\System32\Recovery.

The file winre.wim, needs to be extracted. Extract to the Desktop, then move to the C: drive. You'll need to open PowerShell to enter the command line steps below.

  1. diskpart

  2. list disk

  3. select disk # - Replace # with the target disk you want to use.

  4. detail disk - Make sure you have the right disk.

  5. select part # - Replace # with the correct Recovery partition you want to use.

  6. assign letter=R

  7. exit

  8. reagentc /disable

  9. cd R:\

  10. md R:\Recovery\WindowsRE

  11. xcopy /h C:\Winre.wim R:\Recovery\WindowsRE\

  12. reagentc /setreimage /path R:\Recovery\WindowsRE

  13. reagentc /enable

  14. diskpart

  15. list volume - List all partitions among all disks.

  16. select volume # - Select the volume number with the letter R

  17. remove letter=R

  18. exit

Verify if the Recovery tools are working by typing in bcedit /enum. If you see the recovery sequence, you're all set.