Dual boot Windows7 & Mint on EFI System

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
srs5694
Level 6
Level 6
Posts: 1386
Joined: Mon Feb 27, 2012 1:42 pm

Re: Dual boot Windows7 & Mint on EFI System

Post by srs5694 »

mintybits wrote:
srs5694 wrote:It's kept me busy -- both incorporating Secure Boot code into rEFInd and answering a lot of posts on Web forums. And yes, Linux is built as a follow-on product for a massive commercial juggernaut (meaning the PC industry as a whole, not just Microsoft). As such, Linux is at a disadvantage in some ways, and the transition from BIOS to EFI is highlighting that fact.
I would encourage you to put your efforts into understanding the details of booting linux and how to write the code necessary to do it. This way you might be able to develop an EFI booter for Ubuntu/Mint that can be incorporated into the official installer. By gaining a more detailed understanding you would also recognize the means to avoid the grub-bios partition.
If you want to learn more a new thread would be appropriate.
ROTFL! I already understand EFI booting well enough to do this, and in fact I am doing this -- after all, I maintain rEFInd! Whether the Mint developers want to adopt rEFInd or stick with GRUB is entirely up to them.

The BIOS Boot Partition (what you're calling the "grub-bios partition") is entirely unrelated to EFI-mode booting; as the name implies, it's required for BIOS-mode booting. Personally, I see no point in investing time into improving BIOS-mode booting, since that's a dead-end technology. Furthermore, you're the one who's being critical of the BIOS Boot Partition. I have no problem with it, so I'm not motivated to find a way to eliminate it. Since you're the one who finds the BIOS Boot Partition to be so offensive, you should be the one to find a way to boot without it! (Alternatives do already exist, but they've got their own problems -- look into GRUB Legacy, LILO, and SYSLINUX for details.)
PS: Your statement that Refind is written in C horrifies me. I suggest you learn about modern languages. C is really old-fashioned and a hacker's delight. New code should not be based on C, IMO, but on properly structured languages.
Your programming language snobbery is noted. You might want to be aware of a few facts:
  • EFI is written in C.
  • C is, by a very wide margin, the best-supported language for programming EFI applications, including boot managers and boot loaders. No other language is really a practical alternative.
  • Every other Linux boot loader and boot manager for EFI that I'm aware of uses C. These include rEFIt, gummiboot, ELILO, Fedora's patched GRUB Legacy, GRUB 2, efilinux, shim, the PreBootloader, and the kernel's stub loader. Chances are most of them use C because of the previous point, although I haven't communicated with their authors about this topic.
  • rEFInd is a fork of rEFIt, which was written in C. Thus, I didn't really choose C; Christoph Pfisterer, rEFIt's author, chose it.
  • C is currently at or near the top in most lists of programming language popularity. (See here, for instance.) Thus, your bias against C is your personal bias. Get over it.
You appear to be unaware of at least some of these facts. I recommend you learn more before being critical in the future.
srs5694
Level 6
Level 6
Posts: 1386
Joined: Mon Feb 27, 2012 1:42 pm

Re: Dual boot Windows7 & Mint on EFI System

Post by srs5694 »

mintybits wrote:Yes, EFI ought to simplify Grub. There should be, I presume, a unique EFI boot file for each linux installation made. Simplifying Grub has got to be a good idea.
Computer software projects tend to follow a trajectory of increasing complexity. Although counter-examples do exist, they're pretty rare by comparison. I wouldn't hold my breath waiting for a trimmed-down version of GRUB.

Fortunately, there are simpler alternatives. IMHO, the best of these is the Linux kernel's own EFI stub loader, which has been more reliable for me than any other EFI boot loader. My second choice is ELILO, which is siimilar to the old BIOS LILO in configuration and use. Neither of these can boot non-Linux OSes, so they require a separate boot manager in a dual-boot system. Many EFI implementations include a simple boot manager, but it's often desirable to add something like rEFInd or gummiboot to provide that functionality.
littlenoodles

Re: Dual boot Windows7 & Mint on EFI System

Post by littlenoodles »

@srs5694 - I've tried rEFInd from a flash drive, and I'm finally convinced that there's a way to get my dual boot set up. It looks really nice - thanks for all the work.

My problem is that all your installation instructions seem to have at least some part that requires getting linux booted in EFI mode prior to being able to set up linux to boot in EFI mode (unless I'm misunderstanding something, that's a Catch-22). The trick seems to be to boot a live CD in EFI mode, but I don't think my BIOS will let me do it. Perhaps a properly formatted EFI-bootable CD would show up in the EFI boot menu (like my rEFInd flash drive does), but all the live CD's I've tried don't. I only get the legacy boot option for those CD's, and they don't show any of the telltale signs of EFI awareness once booted. There's no BIOS setting that allows me to force the issue.

So far, I've got Mint installed (and bootable from a supergrub2 CD) on my GPT disk, so my question is - is it possible to get enough of a bootloader onto the EFI partition for rEFInd to boot a linux system - without having to do any of the steps on an EFI-booted linux system? It seems like the only step that would really need to be done under linux is adding linux itself to the EFI BIOS's boot menu. But if I'm going to use rEFInd, does the EFI bios even need to know about that?

Bottom line - is there a cookbook set of files you can point me to that I can stick in a cookbook directory on the EFI partition that'll get the job done? (or maybe just a section in one of your documents that I can focus on and ignore all the other options - your doc's are really thorough, but they present so many optional ways to do it, that I'm scared to try any one...) it looks like the section on "Installing rEFInd under windows would be a good start - but that still tells you to install a bootloader from your linux distro...

Another (silly?) question. Once I get any distro bootable (i.e. some form of grub or elilo loader in the EFI partition), can I use that efi bootloader to boot any other distro I happen to install on the machine? (even if I blow away the original distro that bootstrapped me into efi bootability)? Your comments about Ubuntu loading part of grub in its root partition makes me suspect I can't count on that.

Thanks,
Rob
srs5694
Level 6
Level 6
Posts: 1386
Joined: Mon Feb 27, 2012 1:42 pm

Re: Dual boot Windows7 & Mint on EFI System

Post by srs5694 »

littlenoodles wrote:My problem is that all your installation instructions seem to have at least some part that requires getting linux booted in EFI mode prior to being able to set up linux to boot in EFI mode (unless I'm misunderstanding something, that's a Catch-22).
Yes, it is a catch-22. There is an "out," though: The fallback boot loader, which on x86-64 systems is EFI/BOOT/bootx64.efi. If no other boot loader is available, the firmware tries that one. The trick is in that phrase "if no other boot loader is available," though. If you've got a system that boots Windows, the Windows boot loader will be available, so just dropping a Linux boot loader on the ESP under the name EFI/BOOT/bootx64.efi won't do the trick. You'll need to install the Linux boot loader from Linux or use a removable disk to launch Linux in EFI mode (using the EFI/BOOT/bootx64.efi file on the removable disk).
The trick seems to be to boot a live CD in EFI mode, but I don't think my BIOS will let me do it. Perhaps a properly formatted EFI-bootable CD would show up in the EFI boot menu (like my rEFInd flash drive does), but all the live CD's I've tried don't.
If you can boot rEFInd from a USB flash drive, then that can be your way in. The details depend on what you've got installed on the hard disk already, though. Assuming you've got Linux installed but non-bootable, try this:
  1. Determine the partition number where Mint is installed -- for instance, /dev/sda2 or /dev/sdb7.
  2. Boot the rEFInd disk.
  3. Locate a Linux kernel option in the rEFInd menu. It will have a name of "vmlinuz-{something}".
  4. With the Linux kernel option highlighted, press F2 or Insert twice. This will open a text-mode line editor on the kernel options.
  5. Add "ro root=/dev/{sdax}" to the options, where "/dev/{sdax}" is the partition where Mint is installed.
This should launch Mint in EFI mode, whereupon you can use the rEFInd install.sh script to install it to the hard disk and register it with the NVRAM in such a way that it should launch from hard disk when you reboot. You should then be able to launch Linux from rEFInd without pressing F2 or Insert and adding those kernel options. (Part of what install.sh does is to add a configuration file that holds those options.)
I only get the legacy boot option for those CD's, and they don't show any of the telltale signs of EFI awareness once booted. There's no BIOS setting that allows me to force the issue.
Most CDs, especially older ones, are mastered without EFI boot options. It's possible that's the cause of your problem. Most recent Linux distributions, though, should be EFI-bootable. If you're seeing this lack of EFI-bootability from such discs, then it's likely a firmware bug that's to blame.
So far, I've got Mint installed (and bootable from a supergrub2 CD) on my GPT disk, so my question is - is it possible to get enough of a bootloader onto the EFI partition for rEFInd to boot a linux system - without having to do any of the steps on an EFI-booted linux system?
See above.
It seems like the only step that would really need to be done under linux is adding linux itself to the EFI BIOS's boot menu. But if I'm going to use rEFInd, does the EFI bios even need to know about that?
rEFInd itself needs to be registered with the ESP in order to launch, but once rEFInd has launched, the NVRAM entries become irrelevant, so rEFInd could launch an OS whose boot loader is not registered.
your doc's are really thorough, but they present so many optional ways to do it, that I'm scared to try any one...)
Sorry about the plethora of options. You can blame the huge variability between EFI implementations; what works on one doesn't work on another. You may just need to try something and hope it works. If it doesn't, try something else....
it looks like the section on "Installing rEFInd under windows would be a good start - but that still tells you to install a bootloader from your linux distro...
One thing to keep in mind is that with 3.3.0 and later kernels (included in Mint 14 and later), the kernel itself is a boot loader. That fact, in combination with a rEFInd filesystem driver to read whatever partition holds your Linux kernels, means that you can launch a kernel directly from rEFInd. Normally you'd use a configuration file called refind_linux.conf to hold kernel options, but as a stopgap measure, you can enter the options manually (using the option editor, as described earlier). This can be a good way to get started.
Another (silly?) question. Once I get any distro bootable (i.e. some form of grub or elilo loader in the EFI partition), can I use that efi bootloader to boot any other distro I happen to install on the machine? (even if I blow away the original distro that bootstrapped me into efi bootability)?
That depends on the boot loader. For ELILO, yes, at least if ELILO has access to the kernel files for the other distribution. For GRUB Legacy, yes. For GRUB 2, it depends on whether it can read its configuration file; if it can do that, then yes, but if not, no. If you're using rEFInd as a boot manager, then it can use the EFI stub loader built into 3.3.0 and later kernels, so the combination of rEFInd and the distribution's kernel can do the job without anything else.
osprey

Re: Dual boot Windows7 & Mint on EFI System

Post by osprey »

Wow. I find this whole thread fascinating because I too am faced with the need to install LM (LM 14 KDE) on an ASUS machine (the EB1503 nettop). I have used Linux for many years but am new to LM and am unfamiliar with UEFI. But it looks like I'll have to learn since Windows 7 is apparently pre-installed on my machine in UEFI mode (see screenshot from Windows Disk Manager below).

I was not able to run LM 14 KDE on my ASUS from a Live DVD (kept rebooting before displaying anything on screen), but I have no problems running from a Live USB. Now my goal is to actually install on the unused space on the Windows D: (DATA) partition, while keeping Windows 7 intact (and bootable). I have done many Linux installations over the years, so I'm not a total novice. But this thread makes me think that this installation might be a trial and error process.

Perhaps if I read and really understood everything in this thread, I would know what to do next. Some of this is over my head, though.

Would anyone care to advise me how to proceed? What would be the simplest way to get Windows 7 and LM 14 coexisting happily on my machine?

One more thing - I was under the impression that there could be no more than 4 primary partitions, so that installing on a machine configured like mine required deletion of the Windows recovery partition. But it appears that the OP in this thread created several new linux partitions without deleting any of the original primary partitions. What am I missing here?

Thanks in advance,

osprey
srs5694
Level 6
Level 6
Posts: 1386
Joined: Mon Feb 27, 2012 1:42 pm

Re: Dual boot Windows7 & Mint on EFI System

Post by srs5694 »

osprey wrote:But it looks like I'll have to learn since Windows 7 is apparently pre-installed on my machine in UEFI mode (see screenshot from Windows Disk Manager below).
The presence of a partition identified as an EFI System Partition (ESP) is highly suggestive of an EFI-mode installation. To be 100% sure, check the disk's partition table type:
  1. Right-click in the area that reads "Disk 0" in the screen shot you posted.
  2. Select Properties in the context menu.
  3. Select the Volumes tab.
  4. Read the line labelled "Partition Style." If it's "GUID Partition Table," then you've got a GPT disk and an EFI installation. I don't recall the name that Windows uses for MBR disks, but if it's not GPT, it's presumably an MBR disk and a BIOS-mode installation.
I have done many Linux installations over the years, so I'm not a total novice. But this thread makes me think that this installation might be a trial and error process.
...
Would anyone care to advise me how to proceed? What would be the simplest way to get Windows 7 and LM 14 coexisting happily on my machine?
I'm afraid your first suspicion is correct -- it will be a trial-and-error process. If all goes well, you'll be able to install with little or no more difficulty than on a BIOS-based computer. If not, you'll have to figure it out in a highly system-specific way. To begin, though, be sure that the installer is booted in EFI mode. You can do this by dropping to a shell and looking for a directory called /sys/firmware/efi. If it's present, you've booted in EFI mode; if not, you've probably booted in BIOS mode. Installing Linux in BIOS mode and then switching to EFI mode is possible, but it's generally easier to install directly in EFI mode. If you have problems, start a new thread; that's almost always preferable to trying to resolve multiple peoples' problems in one thread.
One more thing - I was under the impression that there could be no more than 4 primary partitions, so that installing on a machine configured like mine required deletion of the Windows recovery partition. But it appears that the OP in this thread created several new linux partitions without deleting any of the original primary partitions. What am I missing here?
You're missing the fact that EFI computers almost always use GPT disks, and GPT is not so limited. Under GPT, there's no such thing as "primary," "extended," or "logical" partitions -- there are just "partitions," with no modifier word attached. You can have up to 128 of them in a default configuration. That said, I strongly recommend using Linux tools to do your re-partitioning. The Windows partitioning tools are pretty flaky and can do weird things, so you should avoid them. The one exception is in shrinking NTFS volumes -- but even that advice isn't as important on systems that boot via EFI as it is on BIOS-booting computers.
Locked

Return to “Installation & Boot”