Introduction

Did you ever in a critical situation because your production Virtual Machine was running out of space but you were not able to extend the disk because there was recovery partition exist on the end of C:\ volume. This situation blocks you from extending the disk in a critical situation.

Image alt

We can actually just remove the recovery partition, and extend the disk, but we will lose the recovery partition which is important for troubleshooting purposes. We can use it for fixing multiple issues that might happen in the future using this windows recovery.

So, in this article, I will show you how to fix this issue by capturing the Recovery partition, recreate the partition, and restore it the WinRE partition. You can follow the best practice in the official Microsoft article, but you might be bit confused as there are too many steps.

Pre-requirement

Before proceeding with removing the partition. First, it strongly recomended to take a backup first. Next, you need to check the current recovery partition status, size, and the detail partition. You will need to create a recovery partition with the same size or larger size. Bassically, recovery partition requires the following set id and attribute on WinRE partition:

gpt attributes=0x8000000000000001
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"

Check the recovery partition, you can use reagentc, or diskpart.

  • Using reagentc
reagent /info
  • Using Diskpart
detail part

Capturing the current recovery partition.

Before deleting the Recovery partition, capture the recovery partition first. So that we can easily restore the Recovery partition and its content later after we recreate the partition.

diskpart
list disk
select disk
list partition
select partition
assign letter=S 

On the Windows Explorer, you will see the S:\ drive which contains Recovery Partition, but the folder is inaccesible due to system protection.

Open a new PowerShell or CMD window, and run the following command to capture the image. The captured recovery image will be stored on C:\ drive with name my-recovery-partition.wim

Dism /Capture-Image /ImageFile:C:\my-recovery-partition.wim /CaptureDir:S:\ /Name:"My recovery partition"

Removing the Recovery partition.

Once the process is finished, back to diskpart, and unmount back the S:\ drive, and go a head deleting the Recovery Partition.

diskpart
select disk
select partition
remove letter=S
delete partition override

Open the disk management, you will see that the recovery image is gone.

Now, you can extend the partition. but please ensure you keep the unallocated space on the end of volume to recreate the recovery partition later. Ensure the size is same as before or higher (please refer to the recovery partition size as capture in the first article). On my end, the recovery partition is 829MB, so I extend the disk, and keep unallocated 832MB for creating the recovery image.

Recreate the recovery partition.

Back to diskpart, and create the new recovery partition

create part primary size=829
format quick fs=ntfs
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
assign letter="S"

Check the recovery partition, and ensure all information is correct. (Please refer to the capture image on the first article).

detail part

Restore the capture recovery image.

Go to Windows Explorer to ensure the S:\ drive is mounted, then go a head to restore the Recovery partition content from the captured WinRE backup.

dism /Apply-Image /ImageFile:C:\my-recovery-partition.wim /Index:1 /ApplyDir:S:\

Re-register the recovery partition.

C:\Windows\System32\reagentc /setreimage /path S:\Recovery\WindowsRE /target C:\Windows

Back to diskpart window, and remove the S:\ drive

remove letter=S

Check the recovery status, and enable it if the recovery status is disabled.

reagentc /info

To Enable:

reagentc /enable

Test to boot into recovery mode.

Once the recovery partition recreation is completed, do a testing to boot into windows recovery mode. This command doesn’t work over the RDP. use the Server/VM console instead.

shutdown /r /o /t 0

If you notice the S:\ drive keeps mounted after computer is rebooted, fix by typing this command:

mountvol S: /d

If you can boot to recovery mode without having any issue, that means that recovery partition recreation is successful. However, if you got a BSOD when accessing the Recovery Partition, or the recovery boot doens’t show the recover option, then there could be a missing on the steps, please repeat the steps, and try again.