You are in a critical situation because your production machine is running out of space but you are not able to extend the disk because there’s recovery partition exist on the end of C:\ volume. This blocks you from extending the disk in a critical situation.
If you ever experienced this situation, you are not alone! lol..
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 fix multiple issues that might happen in the future using this windows recovery.
So, in order to fix this issue, we need to remove and recreate the recovery partition. You can follow the official Microsoft article, but be careful as the instructions might be a bit confusing.
Before proceeding with removing the partition. First, you need to check the current recovery partition status, size, and the detail partition. Therefore, you can create a recovery partition with similar size as before it deleted. Recovery partition requires the following set id and attribute:
gpt attributes=0x8000000000000001 set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
To check the recovery partition, you can use reagentc, or diskpart.
As we can see, the recovery partition is currently pointed to partition 5.
Back to diskpart, and select the partition 5.
The disk and partition might be different on each server/computer.
Match with your own server. You can also save the captured image or save any information of this partition to a notepad.
Capturing the current recovery partition.
You can capture the recovery partition from the Windows ISO installation, but instead of recreating the recovery partition from the Windows ISO installation, it’s easier to capture the existing recovery using DISM. First, you need to assign a drive letter of the recovery partition as S:\
You see the new S:\ drive is now visible.
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:\ with name my-recovery-partition.wim
Dism /Capture-Image /ImageFile:C:\my-recovery-partition.wim /CaptureDir:S:\ /Name:"My recovery partition"
Once completed successfully, back to diskpart, and remove back the S: drive letter
Deleting the recovery partition.
Back to diskpart, run list disk to ensure you’re still in recovery partition (see the asterisk tag).
Then, run below to delete the recovery partition.
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 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 assign letter="S" set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" gpt attributes=0x8000000000000001
Check the recovery partition, and ensure all information is correct. (Please refer to capture image on the first article).
Once we have assigned the recovery partition as S:\ drive, we can now continue to restore the captured to this drive. I assume you previously stored the capture image on C:\
dism /Apply-Image /ImageFile:C:\my-recovery-partition.wim /Index:1 /ApplyDir:S:\
Once done, Register the location of the recovery tools
C:\Windows\System32\reagentc /setreimage /path S:\Recovery\WindowsRE /target C:\Windows
Back to diskpart, and remove the S:\ drive.
Check the recovery status, and enable it if the recovery status is disabled.
reagentc /info reagentc /enable
Once the recovery partition recreation is completed, do a testing to boot into windows recovery mode.
shutdown /r /o /t 0
If you can boot to recovery mode without having any issue, this means that recovery partition recreation is successful. Please comment if you think this is helpful article.