Swapping Windows 7 OS Drive from MBR to GPT

So this was an unexpectedly fun project to work through.
(Protip: do not use GPTGen.exe to convert your Windows 7 OS drive to GPT if you expect to be able to boot back up).

So a little backstory. I had a client system with a failing 2TB hard drive acting as their Windows 7 pro operating system drive as well as having a large data partition. This drive started failing, so given we had a spare 4TB drive sitting around I figure ‘hey perfect opportunity to swap the drives’. Of course for the more savvy amongst us you may realize that there’s a delineated boundary between 2TB hard drive sizes and anything larger, that being a different boot record requirement or an inability to use any space beyond 2TB.

So after imaging the drive over I though to attempt to expand the partition, no dice because we’re on an MBR.

Well a quick google pulls up a handy live MBR to GPT converter program GPTGen.exe. Excellent I think. Of course there’s cautions about backing up your data etc etc but I still have the original working 2TB drive if I need to re-image, as well as various backups. Of course there’s the warning about updating your operating system drive but hey, it might be fine right? …. WRONG….

So while the partition table upgrades to GPT (allowing expanding partition sizes over 2TB) the system won’t boot, I get the dreaded ‘NTLDR is Missing’ black screen of doom (because its even before we can earn a blue screen).

Of course any partition repair tools I can get my hands on simple stare blankly at this situation wondering what exactly I have done and having no suggested solutions for all their ‘auto repair’ wizardry. At this point its a ‘here hold my beer’ and I roll up my sleeves to get a little funky.

Step 1 we need to get into a PE environment, which is essentially a bootable USB stick that we can get some command line action happening to start mucking about. I grab a hirens boot setup and burn it using rufus.

Step 2: Info tip: GPT partitions can ONLY be booted from uefi enabled bios, if your bios isn’t set for uefi, change it, if it doesn’t have uefi, then you DID do that backup first right? So enable your UEFI in your bios and boot up into your win pe environment. Little tidbit, if you have a non-uefi usb, thats fine, using your ‘boot menu’ hotkey you can often select to attempt to boot a usb device off uefi method or traditional bios method, either is fine for our purposes.

Step 3: Now you’re in a PE, new protip: UEFI requires an EFI partition for its boot junk, thats the partition that gets automagically created when you pick your empty hard drive as your destination for a fresh install (the roughly 100MB one that always gets made). Now here’s where the magic fixit tools fail. MBR ALSO requires a 100MB partition for its stuff, however its NOT an EFI partition and it won’t let you boot up your new GPT UEFI enabled bios hard drive. You’re going to have to drop to command line and get jiggy with some diskpart action.

Step 4: This is really the main trick, you have to go into diskpart, you have to list disk, select disk and select partition on your OS drive’s little original 100MB partition (ie: select disk 0 select partition 1 then delete partition

Step 5: you’ve wiped out your old boot partition, time to make your new efi partition, now if you’re doing this on an existing drive, at least for me, creating the 100MB partition using efi actually stuck it on the end of the drive leaving an empty chunk at the start (useless) so if it happens and you have to ‘select partition’ ‘delete partition’ again you’re going to have to use ‘delete partition override’ because efi partitions are protected because only an idiot deletes them (get your pointy white caps on). Here’s the command I used to make my new efi partiton: ‘create partition efi size=99 offset=1’. I tried sneaking it under in size by a tiny bit, efi obviously makes it efi and the offset tells it to stick it at the front of the drive. After this you’re going to need to do ‘format quick fs=fat32’ to get the drive ready. Next, here’s a stumper for me for a bit, you’re going to need access to this drive, windows drive manager will not allow you to mess with or assign an efi drive with a drive letter which is going to cause issues. Your solution is still doing to be in diskpart, you’re going to type ‘assign’ after you do your format (it will assign a drive letter to the partition you’re actively working on).

Step 6: Here we’re in the home stretch, we have an EFI partition it just has nothing in it so its still not going to work. You’re going to need to rebuild the bootrec system using the following command(s): (pick 1)
bcdboot c:\Windows /s l: /f EFI
bcdboot c:\Windows /s l: /f BIOS
bcdboot c:\windows /s l: /f ALL
To break these down, ‘c:\windows’ is your OS drive and windows folder, if you have a different drive letter etc, well I would advise you change drive letters around to get back to c:\windows because if you add d:\windows to the bootrec you might run into problems so use windows drive manager to make sure your drive letters are going to make sense.
‘/s l:’ this is telling bcdboot where to put the boot record its rebuilding, in my case my efi partition mapped to l:
‘/f efi’ While I don’t know what the ‘f’ stands for, basically this is telling it what kind of boot record to build, EFI is what we most need, Bios is old style but won’t boot a 2TB+ hard drive and all puts them both on.

So at this point (in theory) you have deleted the old useless boot partition, created a new fancy efi partition and your l: (or whatever your 99MB partition wound up being called) should have some files and folders in it (standard boot partition stuff). In theory (and indeed for me) at this point you should be able to restart and boot successfully back into your fully converted windows 7 (converted to UEFI boot, and upgraded to GPT for large drive support on your main OS drive).

Leave a Reply

Your email address will not be published. Required fields are marked *