How to Convert a GPT disk layout to a MS-DOS/MBR layout without data loss (and Gigabyte Hybrid EFI)

If you're coming here from Google searching for how to convert a GPT disk layout to MS-DOS/MBR and don't want to read through my (probably boring) story, click here ;)

Adventures with Hybrid EFI

My gaming PC has been long overdue due for a reformat. I naively allocated only 30GB to the Windows partition (and the other 120GB to 3 flavours of Linux) thinking I wouldn't use Windows for much other than Starcraft 2, but a few months back I had the urge to play Battlefield 2 again. Ever since installing and fully patching it disk space has been running pretty tight. I had to disable sleep, hibernation as well as system restore and still only had 4GB of free space, so my filesystem became fragmented easily. With the release of Windows 8 Customer Preview (download it free here), I figured it was a good time to reformat my disk and reinstall all my OSs from scratch.

I figured while I'm at it, I would make all of the big changes at once and enabled EFI booting on my Gigabyte GA-Z68A-D3H board. Little did I know that when the BIOS says "EFI," it really means Gigabyte's "Hybrid EFI" implementation and not UEFI (although in retrospect, the fact that I made the change in the BIOS should have been enough of a hint, right?). With Hybrid EFI enabled, Windows 7 and Windows 8CP installed perfectly and even created a nice GPT disk layout so reinstalled my games and activated Windows 7. Then I rebooted to play around in Windows 8CP for a bit (I do not like it, btw).

I then tried installing Fedora 16. To my surprise EFI booting failed every time, despite the all of the Fedora 16 installation media being EFI-capable. When attempting to boot from my Fedora 16 Live (x86_64) USB key I just would get a black screen with "........." printed one dot a time and then it would proceed to fall back to the next boot device (Windows boot manager on the hard disk). Upon re-examining my BIOS settings, I was disappointed to find that the setting was actually called "CD/DVD EFI Boot Option" indicating that perhaps USB EFI booting was not supported. Fair enough, I burnt the same F16 image I was using on the USB key to a CD and tried again. The same "........." text appeared.

It was then as I went back to boot Windows 7 that I discovered my attempts to set it as the default OS from Windows 8CP removed my capability of booting Windows 7 somehow. At this point it was 2AM and I was fed up with this stupid Hybrid EFI. I looked for a way to revert to a good old MS-DOS/MBR partition layout. After some Googling I stumbled across Rod Smith's website. He has extensive documentation on EFI booting, including with Gigabyte's implementation of Hybrid EFI. He says that it shares a large amount of code with EFI DUET (tianocore) and although it does work natively with Windows 7, it is not a full UEFI implementation. That would explain the problems I was having with Fedora, then.

The actual GPT to MBR conversion

Through the Rod Smith's guidance and a few dirty tricks, I was successfully able to convert my GPT partition - without data loss or deleting any partitions - and then boot Windows 7 in legacy/MBR mode. In order to do this you'll need your Windows installation media at hand as well as a copy of the Fedora 16 Live media. If you don't have a copy of Fedora 16 Live handy, you can download the Live media ISO (64-bit) from a local mirror here. See the Fedora 16 Installation Guide for details on burning this image to a CD or on creating a bootable USB key.

Keep in mind that at this point I only had 3 partitions and a bunch of unpartitioned space on the disk, so conversion was a rather straightforward process (all GPT partitions mapped directly to primary partitions). Although it is theoretically possible to convert GPT partitions with >4 partitions by defining which ones are to be logical partitions after conversion, I have not tested this.

  1. Boot your Fedora 16 Live media and wait for your session to start. If you're having troubles booting, press Tab at the boot loader screen and try booting with the nomodeset parameter added.
  2. Depending on your graphics card, you'll either be presented with the new Gnome 3 Shell or with the traditional interface. Start a terminal session by putting your mouse in the top right corner of the screen and typing "terminal" in the search (Gnome Shell) or by selecting Applications > System Tools > Terminal (traditional interface)
  3. Install gdisk:
    su -
    yum -y install gdisk
    This may take a few moments.
  4. Make a backup of your current GPT scheme:
    gdisk -b sda-preconvert.gpt /dev/sda
  5. Now we will attempt to convert your GPT disk layout to MS-DOS/MBR. Start gdisk:
    gdisk /dev/sda

    You should be prompted with:
    Command (? for help):
  6. Press r to start recovery/transformation.
  7. Press g to convert GPT to MBR.
  8. Press p to preview the converted MBR partition table.
  9. Make any modification necessary to the partition layout. See Rod Smith's Converting to or from GPT page for more details on this.
  10. When you're happy with the MS-DOS/MBR layout, press w to write changes to the disk.
  11. Shutdown Fedora 16 and boot from the Windows 7 installation media
  12. Enter your language & keyboard layout and then select the option to repair your computer in the bottom left corner.
  13. From the available options, select Startup Repair. Windows will ask for a reboot.
  14. Follow the previous three steps again to boot the Windows 7 installation and run startup repair
  15. Once again, boot the Windows 7 installation media but this time opt to open a command prompt instead of choosing startup repair. Type:
    bootrec /scanos
    bootrec /rebuildbcd
    bootrec /fixmbr
    bootrec /fixboot
  16. Close the command prompt and run Startup Repair one last time.

That's it! You should now have a bootable installation of Windows 7 on a MBR partition layout.

References

Rating: 

Comments

worked like a charm!
Steps I used:
I used ubuntu 10.4 live cd and apt-get instead of yum. I noticed there was a typo with 'sgdisk' for the first gdisk command, should be 'gdisk'. For Ubuntu, you must use sudo before all "gdisk" commands. There is a newer version of gdisk out, apparently, so the questions asked is a little different. When it asked for a hex key after I typed 'g', I just hit enter to let it use the default. From there it was simply saying yes to the following questions. The only thing that scared me was that after I ran gdisk I opened gparted to see that my partition was marked as unallocated. O_O having confidence, I just ignored it and booted into win7 install disk and hit startup repair (before this I couldn't even access startup repair... it said I had the wrong version of windows!). It took a LONG time to do repairs, but once it finished I rebooted into the w7 install disk again and hit startup repair, where I was prompted to continue repairing startup. I clicked cancel, and did the cmd prompt commands instead. Worked perfectly!
THANK YOU SOOOOOOOOOO MUCH!!! I was about ready to wipe my hdd and do a clean install!

Glad to hear it worked! Thank you for pointing out the typo, I have updated the main post.

Thanks for these instructions. I'm working through them now. My first trip was step 3 as I didn't have a live Internet connection and yum install needs that connection. I would suggest that this be mentioned.

gdisk is included in Fedora (starting with 16?), so no download would be needed if you use a newer version of Fedora.

This is great stuff, worked for me prepping for a Cache SSD that only supports MBR.

i note that i did not have to run the extra commands and Windows 7 booted fine, should i be worried or will it be cool?

Thanks again, great guide!

Hello,

I have Parted Magic live USB. It has gdisk but it does not have yum. Can I just run the gdisk command without runing the yum command? If not, then I have to download the ~600 MB Fedora ISO file ...

Thanks!

I haven't tested this, but if partition magic has the required utilities already then there should be no need to grab them with a package manager like yum.

Thank you!

Be sure to select your windows partion as bootable and as primary in step 9. steps 14-16 were not necessary for me. Thanks again man.

Thanks, worked great on Windows 8 as well (only one Repair session was needed).

Got this to work on Win8 too. :)
Conversion went fine, i used Linux Mint because fedora couln't find my mobile broadband device for downloading gdisk..
Had serious problems with the bootloader repair though but finally got my os to boot properly.
Thanks a lot for these great instructions!

Didn't work for me, though I accidentally did only one startup repair before doing the bootrec commands. Did the correct series of two repairs, bootrecs, and one repair afterwards, but it didn't work, though at one point I got a menu asking whether to boot windows in safe mode, etc, or normally. Was very excited and chose normally, but it just put me in the windows cd setup menu :/. Also, the backup command you give is useless, because it saves the backup in a directory on livecd OS, which is wiped out when the computer is restarted... It's not a disaster because I'm doing this on a cloned disk because I expected something like this to happen.

To clarify, by "didn't work", I mean I ended up in an endless sequence of startup repairs, with windows itself never booting.

Problem solved. I googled a bit for the "Element not found" error that I was getting for the bootrec commands, and found remedies that really repaired the startup. I now have my win7 on an MBR disk :).

Glad to hear it! Feel free to post the command here if you still have it handy for others with the same problem.

Cheers,
Stewart

I had the same problem too. In my case, this was caused by the relevant Windows partition not being set to "Active". I used gparted on a Linux live CD to fix this, then re-ran the commands on the Windows live CD and all was good.

Also, don't forget to change your BIOS settings to do a non UEFI boot.

Having trouble with element not found while running some bootrec commands. Probably to many partitions (3) on that SSD/HDD. 1. "GPT/EFI", 2. “System partition” 3. "real Windows partition". DISKPART and bootrec /scanos revealed that Windows repair thinks the Windows partition is “D:\” and does not know what to do with the first partition (1. "GPT/EFI", ).
Try the manual I found, it solved my problem. I additionally deleted the GPT/EFI Partition and unassigned C:\ from 2. “system partition” and assigned it to 3. Windows partition.
A simple BCDBOOT c:\windows /s C: and my system is booting again!
Although I deleted 1. "GPT/EFI" I cannot assign it’s space to any other partition! Even with gparted live cd I could not move it around 2. “system partition” which seems to be very very different.
So I lost 100 MB I couldn’t access before either…

Manual I found:
You can remove this partition AFTER install.

1. Open CMD
2. Type DISKPART (enter).
3. Type LIST DISK (enter).
4. Choose the disk that contains your WinRE partition. If it is disk zero, you type SELECT DISK 0.
5. Type LIST PARTITION.
6. Select the 100MB (or 200MB, depending) partition. If it were partition 1, you would type SELECT PARTITION 1 (enter).
7. Type DETAIL PARTITION. Examine details to make sure this is the 100/200MB WinRE partition.
8. Type INACTIVE to make this no longer the active, bootable partition.
9. Now select your Windows disk – the one you want to boot from. If it is partition 2, you’ll type SELECT PARTITION 2.
10. Again examine details with DETAIL PARTITION.
11. Once you’re sure, mark it active with the command ACTIVE.
12. Type EXIT to get out of Diskpart. You’re back at the commandline.
13. You need to be sure there are system files on the new bootloader drive. if that drive is C:, you will put them there with this command: BCDBOOT c:\windows /s C: (you can use BCDBOOT /? to learn the other options available.)
14. Now reboot the machine.
15. When it comes back, use Disk Manager to delete the old 100/200MB partition. You’re done, though I recommend a reboot to test.

I did it folks!
But instead of doing a repair, I decided only to do at the cmd:
bootrec /scanos
bootrec /rebuildbcd
bootrec /fixmbr
bootrec /fixboot

that´s it! : )
thanks so much!

My hat goes off to you good sir, you just saved me a ton of work. I had built out a session host template and went to image it with Citrix PVS, only to discover that PVS doesn't support EFI >:( All on he off chance that I may one day need a C:\ drive that might exceed 2TB. Sigh.

Thanks for the write up, you're a life saver.

Having trouble with element not found while running some bootrec commands. Probably to many partitions (3) on that SSD/HDD. 1. "GPT/EFI", 2. “System partition” 3. "real Windows partition". DISKPART and bootrec /scanos revealed that Windows repair thinks the Windows partition is “D:\” and does not know what to do with the first partition (1. "GPT/EFI", ).
Try the manual I found, it solved my problem. I additionally deleted the GPT/EFI Partition and unassigned C:\ from 2. “system partition” and assigned it to 3. Windows partition.
A simple BCDBOOT c:\windows /s C: and my system is booting again!
Although I deleted 1. "GPT/EFI" I cannot assign it’s space to any other partition! Even with gparted live cd I could not move it around 2. “system partition” which seems to be very very different.
So I lost 100 MB I couldn’t access before either…
Linux for beginners
Manual I found:
You can remove this partition AFTER install.

1. Open CMD
2. Type DISKPART (enter).
3. Type LIST DISK (enter).
4. Choose the disk that contains your WinRE partition. If it is disk zero, you type SELECT DISK 0.
5. Type LIST PARTITION.
6. Select the 100MB (or 200MB, depending) partition. If it were partition 1, you would type SELECT PARTITION 1 (enter).
7. Type DETAIL PARTITION. Examine details to make sure this is the 100/200MB WinRE partition.
8. Type INACTIVE to make this no longer the active, bootable partition.
9. Now select your Windows disk – the one you want to boot from. If it is partition 2, you’ll type SELECT PARTITION 2.
10. Again examine details with DETAIL PARTITION.
11. Once you’re sure, mark it active with the command ACTIVE.
12. Type EXIT to get out of Diskpart. You’re back at the commandline.
13. You need to be sure there are system files on the new bootloader drive. if that drive is C:, you will put them there with this command: BCDBOOT c:\windows /s C: (you can use BCDBOOT /? to learn the other options available.)
14. Now reboot the machine.
15. When it comes back, use Disk Manager to delete the old 100/200MB partition. You’re done, though I recommend a reboot to test.

Nice blog! The content is impress me. Thanks for sharing.