How to expand the Windows OS Partition when there is a Recovery Partition directly placed behind
If your Windows recovery partition is located after the OS partition, it may cause issues when attempting to extend the OS partition or perform certain recovery tasks.
Windows Recovery Environment (WinRE) is a recovery environment that can repair common causes of unbootable operating systems. WinRE is based on Windows Preinstallation Environment (Windows PE), and can be customized with additional drivers, languages, Windows PE Optional Components, and other troubleshooting and diagnostic tools.
By default, WinRE is preloaded into the Windows 10 and Windows 11 for desktop editions (Home, Pro, Enterprise, and Education) and Windows Server 2016, and later, installations.
Below I want to show in this post how to handle this situation. We can either just disable and deleting the WinRE partition or in case we want to keep it, after deleting the partition we can re-create it.
Disabling and Deleting the WinRE Partition
The reagentc /disable command is used in Windows operating systems to disable the Windows Recovery Environment (WinRE).
WinRE is a recovery tool that helps troubleshoot and repair issues with Windows when the system cannot boot normally. Disabling WinRE can free up disk space, but it also removes the ability to use recovery tools if something goes wrong with the system.
As you can see, directly behind the OS partition there is the WinRE partition placed and therefore currently we are not able to extend the OS partition by using the unallocated 40 GB which in my case was added by extending the virtual disk in VMware vSphere.

Before we can delete the WinRE partition, we first need to disable it by running the following command.
The reagentc /disable command is used to disable the Windows Recovery Environment (WinRE). Running this command will remove the association between your Windows installation and the recovery partition.
C:\Windows\system32>reagentc /disable

We are now able to delete this partition by using diskpart. So execute the following commands to finally delete this partition.
C:\Windows\system32>diskpart DISKPART> list disk DISKPART> select disk 0 DISKPART> list partition DISKPART> select partition 4 DISKPART> delete partition override

Looks good and the WinRE partition was deleted successfully.

We are now able to extend the volume as usual.

In case we doesn’t need or want to use the Windows Recovery Environment (WinRE), we can select all available space below to extend the OS partition.

Re-Creating the WinRE Partition
The commands we need to execute to re-create the Windows Recovery Environment (WinRE) depends on if the OS disk partition style is using a Master Boot Record (MBR) or a GUID Partition Table (GPT).
See Microsoft KB5028997 for details about that.
You can determine the OS disk partition style by right-click on the disk and select properties.

Within the device properties navigate to the Volumes tab, here you will see the partition style for the selected disk.

Alternatively we can also use the diskpart utility to check the partition style.
Check if there is an asterisk character (*) in the “Gpt” column. If there is an asterisk character (*), then the drive is GPT. Otherwise, the drive is MBR.
PS> diskpart DISKPART> list disk

First when extending the disk as mentioned we need to leave around 600 MB space unallocated to use later for the WinRE.


Before re-creating the WinRE partition we first check the WinRE status by running the following command.
If the WinRE is installed, there should be a “Windows RE location” with a path to the WinRE directory. An example is, “Windows RE location: [file://%3f/GLOBALROOT/device/harddisk0/partition4/Recovery/WindowsRE]\\?\GLOBALROOT\device\harddisk0\partition4\Recovery\WindowsRE.” Here, the number after “harddisk” and “partition” is the index of the disk and partition WinRE is on.
PS> ReAgentc /info

Re-Create WinRE on Master Boot Record (MBR) Disks
If your disk is MBR, run the following command.
create partition primary id=27
Re-Create WinRE on GUID Partition Table (GPT) Disks
If your disk is GPT, run the following command.
The specific GUID de94bba4-06d1-4d40-a16a-bfd50179d6ac is used for Windows Recovery Environment partitions.
create partition primary id=de94bba4-06d1-4d40-a16a-bfd50179d6ac


Format the WinRE Partition
To format the partition, run format quick fs=ntfs label=”Windows RE tools”. The partition is already selected after creating it.
format quick fs=ntfs label="Windows RE tools"

Now we can exit the diskpart utility and run the following command to finally re-enable WinRE
PS> reagentc /enable

Links
Windows Recovery Environment (Windows RE)
https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-recovery-environment–windows-re–technical-reference?view=windows-11Instructions to manually resize your partition to install the WinRE update
https://support.microsoft.com/en-us/topic/kb5028997-instructions-to-manually-resize-your-partition-to-install-the-winre-update-400faa27-9343-461c-ada9-24c8229763bf