problem dual-booting Windows with EFI and 2 hard disks

6,089

Solution 1

Both your disks use the GUID Partition Table (GPT), which means that Windows is booting in EFI/UEFI mode. This is your starting point for any repair, since this detail is not easily changed.

The fact that Boot Repair once said you needed to create a BIOS Boot Partition (the "bios-grub flag" you mentioned) means that that boot of the system was in BIOS/CSM/legacy mode. Installing GRUB (or Ubuntu) in that mode would do nothing useful. There's evidence that your /dev/sdb has such an installation of GRUB. It's conceivable that other remnants of this GRUB installation are lurking and causing problems. OTOH, the Boot Repair output you posted is from a run that was clearly in EFI/UEFI mode, since it's got efibootmgr output (lines 708-738, 1115-1145, and 1179-1209), which can be produced only in an EFI-mode boot. Thus, your attempts to boot Ubuntu and related tools have been inconsistent in the boot mode, which introduces a variable that greatly impacts how everything works.

As a first step to recovery, I recommend you enter your firmware setup utility and look for options related to support for "BIOS," "CSM," or "legacy" booting. If you find such an option, disable it, since any BIOS/CSM/legacy-mode boot will be a waste of time. Note that there may be options related to "legacy USB" support or something else. These options are not a problem. You just want to be sure the computer boots in EFI/UEFI mode, not in BIOS/CSM/legacy mode. Unfortunately, there's no standardization of option names or behaviors, so it's hard to say precisely what you should adjust.

With that task done, my recommendation is to download the USB flash drive or CD-R version of my rEFInd boot manager. Prepare a medium and try to boot it. Its menu should show options for both Windows and Linux. Try them both. If you can boot both OSes, then the simplest solution is to install the rEFInd Debian package or PPA. When you reboot after doing this, rEFInd should appear and you'll be good to go. (You might want to clean up unwanted boot options or change rEFInd defaults, but you'll at least be booting.)

If rEFInd doesn't boot both Windows and Linux, add to your question details of what happens when you try.


EDIT:

rEFInd is my program. It's a fork of rEFIt, which has been abandoned. Much of the information on rEFIt's pages applies specifically to Macs and/or is outdated, so I wouldn't trust the rEFIt documentation in your case. The rEFInd documentation more up-to-date and more general, as it's written for both EFI-based Macs and UEFI-based PCs.

GRUB 2 supports both MBR and GPT, when booted with either BIOS or EFI. GRUB is different for each boot mode (BIOS vs. EFI), though -- BIOS-mode GRUB is not identical to EFI-mode GRUB, although the two are very similar. Windows ties the partition table type (MBR vs. GPT) to the boot mode (BIOS vs. EFI). If Windows insists on installing to MBR, then that means that you booted the installer in BIOS mode; if it insists on installing to GPT, then that means that you booted the installer in EFI mode. As a general rule, it's best to stick to this linkage, even in Ubuntu, because it can head off problems down the road. (There are some situations in which you must use GPT even in BIOS mode, though. Most notably, this is the case when using an over-2TiB disk on an old computer that doesn't use EFI.)

The symptom of an empty partition table in GParted or the Ubuntu installer when you've created partitions in Windows is caused by "damage" to the partition table by the Windows partitioning tools. I put "damage" in quotes because some of these problems are not technically damage. In your case, the "damage" is most likely the presence of leftover GPT data on a disk that's been converted from GPT to MBR. I've written a Web page on this subject. The easiest fix is to run FixParts (the fixparts command, in the Ubuntu gdisk package) on the disk.

Note that if Windows is installed on your MBR disk, then that means that your Windows installation, at least, is now in BIOS mode, not in EFI mode, as it was when you began. You can keep booting in that way, but if you want GRUB to manage the boot process, GRUB will also have to be the BIOS version; EFI-mode GRUB can't redirect to a BIOS-mode OS. (BIOS-mode GRUB also can't redirect to an EFI-mode OS.)

Solution 2

I finally resolved this - without resorting to a third bootloader, and without running boot-repair, which was causing problems rather than fixing them. Maybe my settings were wrong, but I didn't end up needing it.

I used 3 partitions for Ubuntu:

(1) 1GB for /boot/efi (2) 8GB swap (I have 8GB of memory) (3) root, mounted at /

A Ubuntu menu item magically appeared in the Windows bootloader, and a Windows menu item magically appeared in Grub (well, after I fixed my Windows installation and ran "sudo update-grub").

Choosing Ubuntu from the Windows bootloader chains to Grub2, from which I can launch Ubuntu. Selecting Windows from Grub2 also chained to a second menu at first - the Windows boot selection menu - but the second menu contained only the one item (Windows 10 Technical Preview). Since it was unnecessary, I bypassed it with this Windows command, entered as an administrator:

bcdedit /set {bootmgr} displaybootmenu no

Since the Grub2 bootloader was more efficient, I changed the boot order on my computer so Ubuntu booted before Windows Boot Loader. Now the computer boots directly in the Grub2 menu, from where I can select Ubuntu or Windows with a single click.

I created a lot of problems on disk 0 (Windows) by repeated installs - sometimes using BIOS/MBR and sometimes using UEFI/GPT. The MBR got screwed up, and so did the Boot Configuration Data. First I booted to a command prompt on a Windows 10 setup disk (DVD or USB flash drive) and ran diskpart. I ran the "clean" command, which deleted all the partitions, set the disk to GPT partitioning, and reinstalled Windows. That solved my Windows boot problems.

For some reason, deleting all the partitions did not clear the corrupted BCD, so I did that manually. I used the BCDEDIT command line utility that comes with Windows 10 (and earlier versions).

Everything is now working perfectly. Many thanks to Rod for advice and help!

Share:
6,089

Related videos on Youtube

permutations
Author by

permutations

Updated on September 18, 2022

Comments

  • permutations
    permutations over 1 year

    I've searched everywhere for answers to the problems I'm having, and can't find a solution. I hope someone here can help.

    I have a Thinkpad T420 with two hard disks. The first hard disk is internal and contains Windows 10 Technical Preview. The second hard disk is in the DVD bay, and contains Ubuntu. I have reinstalled both operating systems multiple times trying to get this to work. One time I managed to boot Ubuntu, but then Windows was invisible. At this point I can boot Windows, but not Ubuntu.

    I'm using EFI, not BIOS. The second disk, with Ubuntu, is partitioned as follows:

    (1) Space for BIOS (bios-grub flag) because boot-repair insisted. But when I reinstalled with this partition, boot-repair deleted everything in it.

    (2) EFI partition (about 1GB), boot flag.

    (3) Swap partition, about 10GB because I have 8GB of RAM. I didn't want to include this because it's an SSD drive, but dire warnings from the Ubuntu install program caused me to include it.

    (4) Root, mounted at /.

    The first time I did this, I could boot Ubuntu, but Windows was no where to be found. I tried adding Windows to the Grub menu with custom_40 (then run update-grub), but it was (and still is) completely ignored. This is another problem - maybe I should post it separately.

    I reinstalled Windows 10, and now Ubuntu is on the Windows boot menu (did boot-repair put it there?). When I choose Ubuntu, the Grub menu comes up. But when I choose Ubuntu (first item) from this menu, it fails to boot. I get the message, "Booting in insecure mode", and then it hangs.

    This ThinkPad originally came with Windows 7, and it does not have Secure Mode to turn off - no secure mode.

    I've tried every boot-repair option, and it is not set up to handle this configuration. I need to edit the Windows and Grub bootloaders manually somehow, but I don't know enough about them to know what's wrong or how to fix it.

    Here is the output from boot-repair. I wish I knew what any of it meant. I've spent hours and hours on this. Can anyone help me?

    Forget that - I can't paste it here because it's too long. Also, I don't know how to put this in a code block - I'm not going to manually type spaces in front of each line! Here's the link:

    http://paste.ubuntu.com/10842921

    • Brian Sizemore
      Brian Sizemore about 9 years
      Since you are using two separate drives for your OSes then the you should first determine the boot order of the drives in your bios. If the windows drive was selected, then it should boot directly into windows, if the ubuntu drive was selected, it should boot into grub, with no option to boot into Windows. Inside of Ubuntu, your host drive "should" be /dev/sda and any additional drives installed on the system would be /dev/sdb ... /dev/sdc ... etc. It is possible that by using boot-repair you've messed something up.
    • Brian Sizemore
      Brian Sizemore about 9 years
      Please try changing boot order from the bios and booting directly into either drive to see what happens, maybe this can give us a better idea of the issue.
    • Rod Smith
      Rod Smith about 9 years
      Under EFI, you do not normally boot "drives" or "disks," so changing the boot order "by drive" or "by disk" is not likely to be effective. Although there is a default/fallback boot loader filename, most EFI booting is done by filename, with entries pointing to each file in the NVRAM.
    • permutations
      permutations about 9 years
      I've tried changing the boot order - one of the many things I tried. It didn't solve the problem. I know that boot-repair is unable to solve the problem. It doesn't work at all before boot-repair (Ubuntu is completely inaccessible). Running boot-repair at least gives me access to Grub, but it's not booting correctly. I know I need to fix this myself - not rely on boot-repair - but I don't know enough about Grub and the Windows boot-loader to do it. I'm posting here in hopes someone can tell me how these things work. I've been trying to do this blind.
    • permutations
      permutations about 9 years
      I've seen posts where people post the paste from boot-loader, and very knowledgable people are able to see what is wrong. I'm hoping someone with the ability to read that sees this post. I am lost. I'm a programmer and capable of learning, I'm just lost and can't figure out what to do. I spent something like 12 hours yesterday trying different things.
  • Mitch
    Mitch about 9 years
    Comments are not for extended discussion; this conversation has been moved to chat.