What happened

A few days ago, I once again had to retrieve a large amount of data from M$ Sharepoint. The way I know is via Onedrive. You create a shortcut in Onedrive and then tell it to keep the whole folder locally. Since I rarely use Windows, I do this stuff in a Windows VM. Unfortunately, the hard disk in the VM was not big enough to download the folder completely.

Increase the disk

So I first enlarged the hard disk in the VM (qemu-img resize ...). So far so good, but now I was confronted with the problem that unfortunately, the recovery partition is located directly behind the Windows partition to be enlarged. This can neither be deleted nor moved by Windows using the hard disk management provided. What a mess. So first i think i must boot into some Linux LE to fix this with gdisk or gparted. But fortunately there is a better way for doing this inside of the running Windows.

howt to fix it in the running windows

Here are the needed steps to move the Recovery Partition to the End of the disk.

  1. start a powershell as Administrator

  2. Runreagentc /disable command will disable the recovery partition and will move the recovery partition into a file named Winre.wim and will be located in C:\Windows\System32\Recovery (you have to enable showing hidden system files if you want to see it)

    reagentc /disable
  3. start diskpart and select the correct disk

    diskpart
    list disk
    select disk 0
    list partition

    here is my output

    ps1

  4. select the partition and delete it

    select partition 4
    delete partition override

Now you can expand the Disk via DiskManagement. Please leftover 1 GB for the new RE Partition. You should then create a new Volume after the increased Windows Partition as follows: NTFS, no drive letter, Name -> New Recovery

back to the console

you should have open diskpart already if not start it again with a elevated powershell

  1. select the new Recovery Partition
    select partition 4
    set id=de94bba4-06d1-4d40-a16a-bfd50179d6ac
    gpt attributes=0x8000000000000001

On GPT disks we need to change the partition ID to de94bba4-06d1-4d40-a16a-bfd50179d6ac which tells Windows that this is a recovery partition
We also need to hide the drive and flag it as a required partition to do that we have to set a GPT attribute to 0x8000000000000001

  1. Quit diskpart and reenable the Recovery Partition with
    reagentc /enable

Previous Post