5

While setting up this home Windows installation some months back I managed to end up without a recovery partition for complicated reasons I won't get into, but I'd like to have it back. I have ~1000MBish unallocated at the end of my main drive to turn into the RE partition.

I have seen a lot of suggestions to just do an in-place upgrade from installation media, which is supposed to conjure up a recovery partition on its own, but I've also seen reports that this doesn't always work and I am just not willing to chance it.

I can enable/disable RE on C: using reagentc /enable and reagentc /disable which happily moves Winre.wim between ..\System32\Recovery\ when disabled and C:\Recovery\WindowsRE\ when enabled.

I have, in preparation, created a partition in the unallocated space as such:

> diskpart
> create partition primary
> format quick fs=ntfs label="Windows RE tools"
> assign letter="R"

My problem is I am unsure how to tell reagentc to deploy the files to this partition when enabling. (and will removing the drive letter then break it or will it use the internal GUID?)

I have found this excellent answer here that tells us all about ensuring that proper ID and attributes are set on the partition, which is great for once the RE is actually in the right place.

For clarity this is a GPT disk, currently there is a ~3720GB C: part, a 260MB EFI partition, and the new R: on the end.

Side Q: can I delete C:\Recovery dir when recovery is on a separate partition, or does Windows throw a tantrum?

ch4rl1e97
  • 202
  • 1
  • 2
  • 12

2 Answers2

5

Right, turns out I was very close.

After creating my extra space at the end and formatting/naming it, the only job remaining is to just set the ID. REAgentC will automatically detect it when enabling! That's what I missed.

Here are full steps with explanations and example output. Skip down to part 8 if you already have freed up some space (At least 700MB-ish).

  1. Open an elevated cmd.exe prompt and type...
  2. diskpart
  3. list disk

Outputs:

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online         1863 GB  2048 KB   *    *
  Disk 1    Online         3726 GB      0 B        *

In my case, my main drive is Disk 1, so I used:

  1. select disk 1

  2. list partition

Outputs:

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Reserved            16 MB  1024 KB
  Partition 2    System             260 MB  3723 GB
  Partition 3    Reserved          1000 MB  3724 GB
  Partition 4    Primary           3723 GB    17 MB

You will inevitably have different partitions in a different order and different sizes, doesn't matter. You need to identify the largest sized one. this will probably be your main drive (e.g. C:\) that you store things on, so check you have at least a few GB free on your main drive and free some if you don't, or the next step may not work. In this example we will pick number 4, don't blindly copy this.

  1. select partition 4
  2. shrink desired=700

This will reduce the size of the partition by 700MB, which seems to be a recommended size as of this writing. You can check with list partition that there should be 700MB unallocated.

  1. create partition primary

Outputs:

DiskPart succeeded in creating the specified partition
  1. format quick fs=ntfs label="winRE"

Outputs:

DiskPart successfully formatted the volume

We've filled the empty space (it will use all available space automatically) and formatted it how it needs to be, and given it a nice name. Note when you create a new partition it will automatically select the new partition, so we skipped doing select partition ... again.

  1. set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac

This is a magic ID that tells it that this is a recovery partition. if you now do list partition then you will see the "Type" of our new partition is set to "Recovery"!

  1. gpt attributes=0x8000000000000001

This is two attributes combined, 0x8000000000000000 "specifies that the partition won't receive a drive letter by default when the disk is moved to another computer, or when the disk is seen for the first time by a computer." Meanwhile 0x0000000000000001 "specifies that the partition is required by the computer to function properly." (source on attributes)

  1. We're done with DiskPart! Type exit.

  2. reagentc /disable

  3. reagentc /enable

This will turn off and on again the recovery. If you didn't already have it enabled then the first command will tell you, but it's worth checking. REAgentC will automatically detect our new Recovery partition when we /enable it and will install the recovery partition in there, instead of on your C:\ drive. Let's double check its in the right place:

  1. reagentc /info

Outputs (something like):

Windows Recovery Environment (Windows RE) and system reset configuration
Information:
Windows RE status:         Enabled
Windows RE location:       \\?\GLOBALROOT\device\harddisk1\partition5\Recovery\WindowsRE
Boot Configuration Data (BCD) identifier: b52d9340-ac37-11ee-b25e-38d57a9b2c2e
Recovery image location:
Recovery image index:      0
Custom image location:
Custom image index:        0

REAGENTC.EXE: Operation Successful.

We're looking to make sure that in the long bit of text near the top, we see harddisk1 (or whatever disk number you picked earlier, usually 0 for most people), and then partition5 (the number of our new partition)

ch4rl1e97
  • 202
  • 1
  • 2
  • 12
3

I tried all the steps detailed above. The recovery partition remained empty.

The problem was that reagentc saw that recovery was already installed... in C:\Recovery. As long as that directory was there, it wouldn't bother filling the extra recovery partition. That directory is there (in my case), but it's hidden because it is "protected operating system files". Explorer can open it, if you enter the path in the address bar.

So then I did:

  • rename C:\Recovery Recovery_tmp to "break" the existing recovery
  • reagentc /enable /logpath C:\Temp\Reagent.log

The log is insightful and detailed. It shows how reagentc enumerates and checks partitions, and why it would dismiss each partition. It accepted the newly prepared partition (NOTE: select partition because it meets WinRE requirements). There are a few warnings, but they look expected or deal with mechanisms that are not used (missing ReAgentOld.xml and ReCustomization.xml, names tell a story).

I confirmed that the WinRE partition indeed contains some data (~400 MB)

I then rmdir /S C:\Recovery_tmp because it's no longer needed.