When you are working with Visual Machines (VMs) and fixed hard disks it can happen that you run out of space. In such cases it comes in handy that you can simply extend the existing virtual hard disk. Since Windows Server 2012R2 and Windows 8.1 this is even possible while the VM is running. After extending the VHDX you just need to go into Disk Management and expand your partition. That’s the theory at least. However in a non lab environment things might look a little different.

Primary Partition blocked by Recovery Partition

Primary Partition blocked by Recovery Partition

More often than not, the partition you want to extend is blocked by a “Recovery Partition”. Blocked because you can only extend your existing partition with unallocated space directly to the right of the partition you want to extend. In our case there is a recovery partition in between and therefor the primary partition (C:) cannot be extended. This happens because Windows 10 creates the recovery partition after your primary partition so it can easily be extended.

Windows Partition Layout

The Windows 10 UEFI parition layout looks like the following. First comes a System Partition containing the master boot record (MBR). Without the system parition you will not be able to start Windows. Follwing the system partition you have the Microsoft Reserved Parition (MSR) that manages the partitions itself. Then you have your primary Windows parition followed by the recovery parition containing tools and data to recover your Windows installation in case of failures.

Windows 10 UEFI Paritions


Deleting the Recovery Partition

We can now go ahead and delete the recovery partition to make room for our primary Windows Partition. You can delete the recovery parition with DISKPART using the following commands from an admin commandline.

C:\Windows\System32\> DISKPART

Microsoft DiskPart version 10.0.14393.0
Copyright (C) 1999-2013 Microsoft Corporation.

DISKPART> rescan

Please wait while DiskPart scans your configuration...

DiskPart has finished scanning your configuration.

DISKPART> list disk

 Disk ### Status Size Free Dyn Gpt
 -------- ------------- ------- ------- --- ---
 Disk 0 Online 300 GB 0 B *

DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list part

 Partition ### Type Size Offset
 ------------- ---------------- ------- -------
 Partition 1 Recovery 300 MB 1024 KB
 Partition 2 System 500 MB 301 MB
 Partition 3 Reserved 128 MB 801 MB
 Partition 4 Primary 298 GB 929 MB
 Partition 5 Recovery 451 MB 299 GB

DISKPART> select part 5

Partition 5 is now the selected partition.

DISKPART> delete partition override

DiskPart successfully deleted the selected partition.

We can now go ahead and extend our Windows Parition to consume the free space. You should however leave about 500MB room so we can recreate our recovery parition.

Expanded Windows Partition

Recreating the Recovery Partition

If you do not need your recovery environment you can stop here and enjoy your new disk space. However I highly recommend recreating the just deleted recovery enviroment. That way in case of a system failure you can easly troubleshoot and restore your system. To create a new recovery partition we first must format the remaining 500MB free space accordingly. Windows recognizes the recovery partition by the static unique id de94bba4-06d1-4d40-a16a-bfd50179d6ac and the GPT attribute bit 0x8000000000000001.

DISKPART> create part primary

DiskPart succeeded in creating the specified partition.

DISKPART> format quick fs=ntfs label="Recovery tools"

100 percent completed

DiskPart successfully formatted the volume.

DISKPART> assign letter="R"

DiskPart successfully assigned the drive letter or mount point.

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.

DISKPART> list volume

We now have a partition that can host the Windows Recovery Environment (WinRE). In the next step we are going to extract the WinRE from the Windows Installation media and copy it to the just created volume.

Extrating the Windows Recovery Environment (WinRE)

Download the .ISO image for your version of Windows our insert your installation disk and mount it by right clicking the image. We are now going to mount the installation files and copy the winre.wim file from Windows PE. Open an admin powershell and enter the following commands.

PS C:\Windows\System32> md C:\WinPE

PS C:\Windows\System32> md C:\WinPE\mount

# Copy install.wim from the mounted installation media
PS C:\Windows\System32> copy D:\sources\install.wim C:\WinPE\

# Mount the image in readonly mode
PS C:\Windows\System32> dism /mount-wim /wimfile:C:\WinPE\install.wim /index:1 /mountdir:C:\WinPE\mount /readonly

# Extract the Windows Recovery Environment
PS C:\Windows\System32> copy C:\WinPE\mount\Windows\System32\Recovery\Winre.wim C:\WinPE\

# Unmount the image
PS C:\Windows\System32> dism /unmount-wim /mountdir:c:\WinPE\mount /discard

Installing the Windows Recovery Enviroment (WinRE)

Now that we have the WinRE image we can install it in our new recovery volume (R:). We are going to copy the image and then tell Windows were to find it.

PS C:\Windows\System32> md R:\Recovery\WindowsRE

PS C:\Windows\System32> copy C:\WinPE\Winre.wim R:\Recovery\WindowsRE\

# Register the recovery image 
PS C:\Windows\System32> C:\Windows\System32\reagentc /setreimage /path R:\Recovery\WindowsRE /target C:\Windows
Directory set to: \\?\GLOBALROOT\device\harddisk0\partition5\Recovery\WindowsRE

REAGENTC.EXE: Operation Successful.

Thats it. We are all done and you can now use your recovery enviroment as before.


Blake Whitney · 26. March 2020 at 16:09

disk 0 is an MBR disk for me. so the set id piece is failing as well as the gpt piece. this is for windows server 2016 btw. any advice for an mbr disk on this?

    Michael · 26. March 2020 at 16:28

    Can you take a look at the following article?


    Note the last section where it says: “How to Delete the Recovery Partition and Move the BCD on BIOS-based PC?”

    Maybe that will help?

      Blake W · 26. March 2020 at 17:43

      Thank you Michael. It talks about moving the BCD to the C drive. First I don’t know what that’s actually doing and it’s too late as we already deleted the recovery partition as part of your process (which was the same as theirs), so now I’m not sure if it’s really back or not.

      But in any case, the article says to move the BCD, then delete the recovery partition/volume but doesn’t say how to recreate it like your does. thus it doesn’t tell us what ID to use or attributes, if any.


Nicholas Knowles · 15. April 2020 at 12:00

Can you remove the R drive letter once you’ve done?

    Lance · 23. April 2020 at 2:53

    I did. It wasn’t mounted with a letter before the move, so need to keep it with a letter afterwards.

    remove letter=”R”

    So just follow the directions to get to that partition (without deleting or creating anything) and where you would assign the letter, just use the command listed above.

Michael Mülller · 22. August 2020 at 9:02

Dear Michael, thank you so much, perfect article! I have looked for that a long time, et voilà, there it is, thank you! Have erroneously created a Windows 10 Hyper-V image, fully configured and then stated, that I have forgotten to look at the right disk size before starting… Thank you!

Ofir Milul · 2. September 2020 at 9:48

Dear Michael,
this is a great article!
i have windows version 2004, things are little different, i couldn’t find the install.wim file.
if there is some guidance for this I’ll be glad

Thank you

Human Bean · 26. September 2020 at 20:14

Thanks for this article, for step of recreating recovery I have issues. The MediaCreationTool2004.exe downloads ISO w/o install.wim but has install.esd so I did this to get the list of images in the .esd file

dism /Get-WimInfo /WimFile:D:\sources\install.esd

then used the Index number of my image ( windows 10 pro, no N, #6 ), then extract wim to install.wim. Replace the “6” with index number of your image

dism /export-image /SourceImageFile:D:\sources\install.esd /SourceIndex:6 /DestinationImageFile:c:\WinPE\install.wim /Compress:max /CheckIntegrity

Jampot · 8. February 2021 at 10:14

Many thanks. Have been baffled by how to extend a partition which has a recovery partition between it and free space. Followed your simple procedure and it worked.

Ian C · 29. March 2021 at 3:05

This is just awesome tutorial thank you so much! It worked for me 100%

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: