Skip to content

Instantly share code, notes, and snippets.

@bp2008
Created August 18, 2023 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bp2008/4e86b5211c1f9f62bb7187ac7e40e5df to your computer and use it in GitHub Desktop.
Save bp2008/4e86b5211c1f9f62bb7187ac7e40e5df to your computer and use it in GitHub Desktop.

Moving Windows Recovery Partition

When cloning a Windows OS disk to a larger disk, it is common for the OS partition to be followed by a recovery partition. If your disk cloning software does not allow moving the recovery partition, or you forget to do it, it is possible to fix it from within Windows later.

It is possible to move a Windows Recovery Partition without third-party software and without shutting down, for the purpose of extending the OS partition before it.

This guide is based on a superuser.com answer:

answered Oct 21, 2020 at 19:04 - VainMan

SOURCE: https://superuser.com/a/1596291 (https://superuser.com/questions/1453790/how-to-move-the-recovery-partition-on-windows-10)

First Steps

You may have multiple recovery partitions. Investigate to see which one is being used (although maybe it is possible that multiple are being used?).

The following command will show you a low-level path including the disk number and partition number that is being used as the recovery partition. Run this command and copy/screenshot the results:

reagentc /info

Then use diskpart to help you learn more about your disks:

DISKPART> list volume
DISKPART> list disk
DISKPART> select disk <the-number-of-disk-where-current-recovery-partition-locate>
DISKPART> list partition

From these commands, it should become clear which partition is the one you need to move, and which partition(s) can be safely(?) deleted.

From Superuser

According to MS's documentation, capture-and-apply-windows-system-and-recovery-partitions, the recovery partition can be captured and applied to a new partition. I have made it to work on my windows 10 PC.

Warning 1: You must know what the following commands do before you execute them. Check the link above and MS's documentation for diskpart, dism and reagentc.

Warning 2: Check disk numbers, partition numbers and volume letters carefully before executing commands.

  1. Use diskpart to find current recovery partition and assign a driver letter (eg. N) to it:
DISKPART> list disk
DISKPART> select disk <the-number-of-disk-where-current-recovery-partition-locate>
DISKPART> list partition
DISKPART> select partition <the-number-of-current-recovery-partition>
DISKPART> assign letter=N
  1. Create an image file from current recovery partition:
Dism /Capture-Image /ImageFile:C:\recovery-partition.wim /CaptureDir:N:\ /Name:"Recovery"

Verify that the recovery-partition.wim file was created.

  1. Unregister the location of the recovery tools:
reagentc /disable
  1. Note the recovery partition's size, then delete the recovery partition via diskpart:
DISKPART> select volume N
DISKPART> delete partition override
  1. Using the Disk Management GUI, extend the OS partition, leaving enough space at the end of the disk for a new recovery partition.

  2. Using the Disk Management GUI, create a new recovery partition of the same size as the old one. Assign it the same letter as the old one (N) and it is fine to do a quick format.

  3. Apply the created image file to the new partition (eg. N) that will become the new recovery partition:

Dism /Apply-Image /ImageFile:C:\recovery-partition.wim /Index:1 /ApplyDir:N:\
  1. Register the location of the new recovery partition:
reagentc /setreimage /path N:\Recovery\WindowsRE
reagentc /enable
  1. Use diskpart to flag the recovery partition appropriately and remove its drive letter:

    • For UEFI:
    DISKPART> select volume N
    DISKPART> set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    DISKPART> gpt attributes=0x8000000000000001
    DISKPART> remove
    
    • For BIOS:
    DISKPART> select volume N
    DISKPART> set id=27
    DISKPART> remove
    
  2. Delete the registry key that would cause the drive letter to be re-added upon boot:

Great instructions! One comment: after following the above instructions, my new recovery partition kept reappearing in Windows Explorer/ This PC as drive 'N' despite the diskpart > remove step. I discovered there was a registry key \DosDevices\N: under Computer\HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices that was making this come back. Deleting that key fixed this issue. YMMV; registry editing precautions apply. This is detailed here: answers.microsoft.com/en-us/windows/forum/all/… – SSilk - Jul 25, 2021 at 21:12

  1. Reboot the computer, now the new recovery partition should be working

  2. (Optional) Check if the recovery partition is working:

    1. Show the current status:
    reagentc /info
    
    1. Specifies that Windows RE starts automatically the next time the system starts:
    reagentc /boottore
    
    1. Reboot the computer and do your stuff in Windows RE (eg. enter CMD and run some tools)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment