How to convert a Legacy Windows installation to UEFI

CAUTION: This guide will walk you through the procedures of converting a legacy MBR disk to GPT without wiping or reinstalling windows.

Before proceeding with this guide, ensure that the drive being modified has at least 229MB of free space before the C:\ partition. You can confirm this in Disk Management.

If the drive does not, you won’t be able to complete this guide without resizing the C:\ partition first, which can be done with any partition editor freeware for Windows or Linux. I recommend using PartedMagic‘s built-in partition editor.

Stage Ⅰ: Prepare

  1. Prepare Windows Bootable USB (see How to wipe and reload Windows – Mr. Robot)

  2. Identify which disk you want to convert (usually is #0). This can be done by looking at the number in the Windows Disk Management.

  3. Download gptgen from http://sourceforge.net/projects/gptgen
    This tool will allow you to convert your MBR disc to GPT with the data included. 

  4. ATTENTION: After this step, your computer CANNOT BOOT until the whole process is completed. DO NOT Shut Down Unless Instructed

    Unzip gptgen and then run CMD with elevated privileges. (replace the 0 with the identified disk number).

    This *will* result in a BSOD shortly after and it’s to be expected:

    gptgen.exe -w \\.\physicaldrive0

Stage Ⅱ: Boot

  1. Boot up using your Windows bootable USB prepared in Step 1.

  2. Choose language and preferences, and then select
    Repair Your Computer -> Troubleshoot -> Advanced options -> Command Prompt

  3. We will need the disk partitioning tool. With this, we will recreate the boot partitions.
    Type:
    diskpart

  4. Identify the boot disk where Windows is located, typing:
    list disk 

    Something like this should appear:

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


  5. Once identified, select the disk (replace with the correct number):
    select disk 0

  6. Verify the partitions:
    list partition

  7. Something similar at the info below should appear.
    Partition ###  Type         Size     Offset
    -------------  -----------  -------  ------
    Partition 1    Primary      350 MB  1024 KB
    Partition 2    Primary      126 GB   350 MB

  8. Delete the previous system partition:
    select partition 1
    delete partition

  9. Create the new boot partition, Microsoft reserved partition:
    create partition EFI size=100 offset=1
    format quick fs=fat32 label="System"
    assign letter=S
    create partition msr size=128 offset=103424

  10. If you list the partitions again, you should have ended up with something like this:
    Partition ###  Type          Size     Offset
    ------------  -----------  -------  -------
    Partition 1   System        100 MB  1024 KB
    Partition 2   Reserved      128 MB   101 MB
    Partition 3   Primary      126 GB   229 MB

  11. Ensure that your Windows installation is mounted, replacing X with the volume number of the Windows installation (usually 1)
    list volume
    select volume X
    assign letter=C

  12. Exit diskpart:
    exit

  13. Generate boot partition data, replacing C: with the letter of the Windows installation (usually C:):
    bcdboot c:\windows /s s: /f UEFI

  14. You should see the message boot files successfully created
    Remove USB drive and restart your computer