Once I saw that one of the test virtual machines was running out of free space on system drive C:. I increased the disk size in the virtual machine settings and switched to the guest OS (Windows 10) to extend the size of the system partition using the unallocated space. When I opened the Disk Management console (diskmgmt.msc), I noticed that there were two recovery partitions on the drive. And the unallocated space was appeared after the second recovery partition (labeled as Windows RE). On some reason the recovery partition is located after the main partition (C:) and does not allow to expand the primary volume by using the unallocated space.
How to Move Recovery and Extend System Partition on UEFI-based Computer?
On my virtual machine, Windows 10 is installed in UEFI mode (Partition style: GPT).
As you can see on the screenshot below, the “Extend Volume” button is inactive (gray). You can extend the partition using the Windows built-in tools if it has an unallocated space to the right of it (Windows 10 cannot extend primary partition to the right into unallocated space). In my case, I cannot extend the C: drive because it is blocked by the recovery partition (Windows RE). So, prior to extending the size of the system partition, I will have to delete the recovery partition.
On the screenshot, you can see that there are two recovery partitions (Recovery and Windows RE). To understand, which of them is used by Windows as an active recovery partition, you must assign the drive letters to your partitions. For example, you can assign a drive letters E:
and R:
using the the Disk Management or Diskpart.exe: select disk 0 -> select part 1 -> assign letter r:
. To check the active recovery partition, run the command:
bcdedit /enum all
Please pay attention to the following sections:
- Windows Boot Manager (it indicates the partition where the BCD bootloader is located). In my case, the bootloader is on the EFI partition:
Windows Boot Manager -------------------- identifier {bootmgr} device partition=\Device\HarddiskVolume2 path \EFI\Microsoft\Boot\bootmgfw.efi description Windows Boot Manager locale en-US inherit {globalsettings} default {current} resumeobject {dbaf5561-4424-11e9-b766-b7001b047795} displayorder {current} toolsdisplayorder {memdiag} timeout 30
- Now look at the values in the Windows Boot Loader section. The Winre.wim image file (recovery environment) is located on the second partition with the Windows RE volume label.
Windows Boot Loader ------------------- identifier {dbaf5563-4424-11e9-b766-b7001b047795} device ramdisk=[E:]\Recovery\WindowsRE\Winre.wim,{dbaf5564-4424-11e9-b766-b7001b047795} path \windows\system32\winload.efi description Windows RE locale en-us inherit {bootloadersettings} displaymessage Windows RE osdevice ramdisk=[E:]\Recovery\WindowsRE\Winre.wim,{dbaf5564-4424-11e9-b766-b7001b047795} systemroot \windows nx OptIn bootmenupolicy Standard winpe Yes
To expand the size of the main Windows volume, we will have to delete the recovery partition to the right of it, extend the volume and recreate the recovery partition.
To copy the Winre.wim file to the system volume and set new the WinRE.wim file location, run these commands:
reagentc /disable
md c:\Recovery\WinRE
xcopy e:\Recovery\WindowsRE\Winre.wim c:\Recovery\WinRE /h
reagentc /setreimage /path c:\Recovery\WinRE /target C:\Windows
reagentc /enable
If you try to delete the recovery partition from the Disk Management GUI by clicking Delete Volume (sometimes the disk properties are not available at all), the following error will appear:
Virtual Disk Manager Cannot delete a protected partition without the force protected parameter set.
You can delete such a protected partition only using the diskpart tool. Open the elevated command prompt and run the diskpart command. Select the partition you want to delete (note the results of your commands, since the numbers of disks and partitions may vary).
DISKPART> rescan
DISKPART> list disk
DISKPART> select disk 0
DISKPART> list part
DISKPART> select part 5
DISKPART> delete partition override
DiskPart successfully deleted the selected partition.
DISKPART> Rescan
The override parameter allows diskpart to delete any partition regardless of its type (whether it is an active, system, or boot partition).
Now you can open the Disk Management and extend the system partition (the Extend Volume option is now available). If you want to recreate the recovery partition (it is recommended to save it or move it to the system partition as described above), leave 500MB of unallocated space on your drive. In the screenshot below, I am extending my Windows partition by 1.5GB and leaving 500MB at the end of the drive.
After extending the main partition, I have 500MB free space left for WinRE recovery partition.
Windows detects the recovery partition by the special labels: GUID — de94bba4-06d1-4d40-a16a-bfd50179d6ac and the GPT attribute 0x8000000000000001.
Let’s create a new partition and assign these attributes to it:
DISKPART> create part primary
DISKPART> format quick fs=ntfs label="WinRE"
DISKPART> assign letter="R"
DISKPART> set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
DiskPart successfully set the partition ID
DISKPART> gpt attributes=0x8000000000000001
DiskPart successfully assigned the attributes to the selected GPT partition.
Exit
Then copy WinRE files from the Windows 10 installation disk (image) to your new recovery partition.
Mount the install.wim file from your Windows 10 install ISO image and extract the WinRE file (Winre.wim) from it:
md C:\WinISO
md C:\WinISO\mount
dism /mount-wim /wimfile:F:\sources\install.wim /index:1 /mountdir:C:\WinISO\mount /readonly
md R:\Recovery\WinRE
copy C:\WinISO\mount\Windows\System32\Recovery\Winre.wim R:\Recovery\WinRE\
dism /unmount-wim /mountdir:C:\WinISO\mount /discard
Then just move the WinRE file to the recovery partition and update the bootloader configuration:
reagentc /disable
reagentc /setreimage /path R:\Recovery\WinRE /target C:\Windows
reagentc /enable
So, we have recreated the recovery partition and registered a new path to the WinRE image. If you have any Windows boot problems, your recovery environment will boot automatically.
How to Delete the Recovery Partition and Move the BCD on BIOS-based PC?
If your computer is based on BIOS (not UEFI), you can move the Windows boot manager (BCD) and the recovery environment files to the C: volume prior to deleting the recovery partition as follows.
First of all, you have to move BCD files from drive E: to drive C: (I have assigned this drive letter to my recovery partition):
Reg unload HKLM\BCD00000000
robocopy e:\ c:\ bootmgr
robocopy e:\boot c:\boot /s
bcdedit /store c:\boot\bcd /set {bootmgr} device partition=C:
bcdedit /store c:\boot\bcd /set {memdiag} device partition=C:
Then move the recovery wim image:
reagentc /disable
md c:\Recovery\WinRE
xcopy e:\Recovery\WindowsRE\Winre.wim c:\Recovery\WinRE /h
reagentc /setreimage /path c:\Recovery\WinRE /target C:\Windows
reagentc /enable
Now you can remove the recovery partition using diskpart (as shown above) and extend your system partition successfully.
4 comments
Thanks! Just what I was looking for, worked perfectly first time.
Thanks! it worked Great!
I just needed to recreate my .wim file, so had some help from “https://community.spiceworks.com/how_to/163540-convert-esd-to-wim”.
But really big big thanks!!!
This line gives error on my computer:
robocopy e:\boot c:\boot /s
since the system could not find the \boot\ file in the recovery partition
The Partition style is not GPT in my computer, so I followed instructions in part “How to Delete the Recovery Partition and Move the BCD on BIOS-based PC”
When I made the RE partition unhidden and assigned it a name, I could see directories and files as follows:
F:
– Recovery
– WindowsRE
boot.sdi
ReAgent.xml
Winre.wim
Could you please advise how to move BCD and relevant files to C: drive properly.
[…] If it was an 'original' drive it may well have the original image in the recovery partition with specific drivers and software provided by the manufacturer, or it could just be the Win RE partition. It horses for courses I'm afraid, it seems a little less common these days, but sometimes it can do more harm than good – especially when an elderly relative or less IT literate family member chooses 'restore my computer' or something from a troubleshooting menu and wipes all their data and photos… If he has the original drive and has mastered the cloning process (depending on the software he used), he may be able to do the clone again and choose which partitions to clone on to the new drive? This has some good info: Extend Volume Blocked by a Recovery Partition on Windows 10 | Windows OS Hub […]