I posted this article a while back on another blog. It has since been removed so I'm reproducing it here. Enjoy!
Introduction
There are few reasons to switch from MBR on BIOS to GPT on UEFI, but some like adventure. Current OS and motherboard support is quite inconsistent and not well documented. If you first installed on the former and want to switch to the latter without having to lose all your data or re-install Windows, then this is your guide.
The basic idea is to backup the current install to a disk image, erase the disk, then reload the backup. Windows ships with a disk imaging tool and an image restore tool. Unfortunately the restore tool (wbadmin) requires the target partition to be at least the same size as the original backup, so we have to use another method for restore.
WARNING: You may lose all the data on your disk during this process. Make sure to back up your data!
Prerequisites
- A UEFI motherboard
- A copy of Windows 7 64bit installed to a local disk partitioned using MBR
- Windows install media (DVD, Hard disk, USB stick)
- Backup destination with enough space to hold a copy of your existing Windows install
- Sufficient free space on the Windows partition; the new partition will be about a gigabyte larger.
Process
- Backup your Windows installation and all other partitions on the physical disk to another physical disk. This backup can be done using the built-in image tool found within the control panel under “Backup and Restore” behind the “Create a system image” link. NOTE: The rest of this guide will assume just one partition to be restored.
- Reboot the computer to a Windows install disk.
- Open the command prompt
- press
Shift + F10
at the “Install Windows” window.
- press
- Repartition the disk
diskpart
list disk
select disk x
(where x is the number of the disk to convert)- WARNING: This is your last chance to go back!
clean
convert gpt
create partition ESP size=128
format fs=fat32 quick
assign letter=i
or any other free drive lettercreate partition MSR size=128
create partition primary
format fs=ntfs label="Windows" quick
active
assign letter=y
or any other free drive letterexit
- Mount the backup VHD
diskpart
select vdisk file=filename.vhd
where filename.vhd is your disk backupattach vdisk
assign letter=z
or any other free drive letter for your new partitionexit
- Restore the files from the image
z:
(where z is the letter of your VHD)xcopy * y:\ /e /c /h /k /o /b /q /y
(where d is the letter of your new partition)e
= copy all subdirectories even if they are emptyc
= ignore errorsh
= copy hidden and system filesk
= retain readonly flago
= copy file ownershipb
= copy links as linksq
= quiet mode (should speed things up)y
= always respond with yes instead of prompting
- Wait for the copy to complete. Commenter Niko has an excellent point here: There may be permission errors which you can probably ignore. These are likely for special system folders like "System Volume Information". Turn off quiet mode to be sure or if the process doesn't work and you want to verify this isn't the cause.
- Copy EFI bootloader to ESP partition
i:
(where z is the letter of your ESP partition)mkdir EFI
cd EFI
mkdir Boot
mkdir Microsoft
cd Microsoft
mkdir Boot
copy x:\Windows\Boot\EFI\bootmgfw.efi i:\EFI\Microsoft\Boot
copy x:\Windows\Boot\EFI\bootmgfw.efi i:\EFI\Boot\bootx64.efi
- Create BCD
- This step varies quite a bit, depending on your system’s hardware, existing NVRAM (non-volatile memory on your motherboard), and hidden BCD stores scattered around your system’s disks and partitions.
- Cross your fingers and hope that this step can be done automatically
bootrec /RebuildBcd
- If things don’t work out, you will have to resort to using bcdedit. A few notes about BCD edit: it operates on the motherboard’s NVRAM unless you specify a file. As far as I can gather, the NVRAM store doesn’t matter as my PC basically ignores any setting within and boots just fine after I’ve erased it.
i:
cd EFI\Microsoft\Boot
bcdedit /createstore BCD
bcdedit /store BCD /create /d "Windows Boot Manager" {bootmgr}
- Commenter Manuel says this should be
bcdedit /store BCD /create {bootmgr} /d “Windows Boot Manager”
but I haven't tested this. This may depend on the version of BCD edit you are using.
- Commenter Manuel says this should be
bcdedit /store BCD /create /d “Windows 7” /application osloader
- The previous command will return a GUID, referred to later as
<guid>
bcdedit /store BCD /set {bootmgr} default <guid>
bcdedit /store BCD /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi
bcdedit /store BCD /set {bootmgr} locale en-us
bcdedit /store BCD /set {bootmgr} displayorder {default}
bcdedit /store BCD /set {bootmgr} timeout 10
bcdedit /store BCD /set {default} device partition=c:
bcdedit /store BCD /set {default} osdevice partition=c:
bcdedit /store BCD /set {default} path \windows\system32\winload.efi
bcdedit /store BCD /set {default} systemroot \windows
- Change your motherboard firmware to run in UEFI mode
- You should now be able to select your Windows disk as your startup disk.
Good luck!
More Reading
- https://neosmart.net/wiki/recovering-windows-bootloader/
- http://technet.microsoft.com/en-us/library/cc709667(v=ws.10).aspx