2

I have a Macbook running OSx and Xubuntu16.04, but there seems to be something I don't understand about the boot process.

I simply wanted to choose at boot which OS I started, OSx or Xubuntu - but what happens is that the choice is presented to me twice - firstly in a GUI with refind and secondly as a text based selection with GRUB.

How do I choose to use just one? And prefereably refind?

Thanks

John
  • 45
  • On rEFInd are you selecting the kernel options or the Linux bootloader option? – Andrea Lazzarotto Apr 25 '17 at 10:11
  • Good question Andrea! I am not sure I'm afraid. How do I ascertain this? When I boot, i am presented with a GUI of three large icons, I select the first one which takes me to the GRUB selection. – John Apr 25 '17 at 10:12
  • In the default config you should have at least two Linux icons. One for the bootloader (i.e. GRUB) and another one for the kernel. Can you confirm this? Maybe you could share a picture of the menu in your question. :) – Andrea Lazzarotto Apr 25 '17 at 10:14
  • Ah do you mean when I start up - there are indeed three image icons shown; 1-the one I select for booting into Xubuntu (well, GRUB), then 2-OSx, then there is a third icon that is the same in appearance as the first, that I haven't selected. – John Apr 25 '17 at 10:16
  • If you could [edit] the question and add a picture it would be great. :) But I guess the first one is GRUB and the fourth one is the kernel. Can you try that last one? I can write an answer on how to hide some of those icons to prevent duplication, but first you should confirm that the last icon boots the kernel correctly. – Andrea Lazzarotto Apr 25 '17 at 11:37

1 Answers1

1

The Solution

You can eliminate the GRUB menu in either of two ways:

  • Reconfiguring GRUB -- You can tell GRUB to hide its menu (in which case GRUB will still be used, but its menu will simply disappear). See this question and its answers for more on this approach.
  • Using an EFI stub loader -- You may already have an EFI stub loader on your menu; this detail is unclear from your description. If so, you can simply select it to launch in this way, bypassing GRUB and its menu. If you don't see such an option, you can probably get them by adding an EFI filesystem driver. The easiest way to do this is probably to re-install rEFInd. When run in OS X, the installation script looks for Linux partitions and, if one is found, automatically installs the ext4fs driver. When run in Linux, the installation script adds the driver for the filesystem that holds the kernel, if that driver is available. (rEFInd ships with drivers for ext2/3fs, ext4fs, ReiserFS, and Btrfs; but not for XFS or JFS.) If you can get the system to boot with the EFI stub loader, chances are that will leave you with two ways to boot Ubuntu from rEFInd -- the EFI stub loader and GRUB. I recommend leaving both in place because the redundancy may prove useful if a problem emerges with one approach in the future; however, if you want to hide one, you can do so with the dont_scan_dirs or dont_scan_files options in refind.conf; or if you're booting via a BIOS-mode GRUB, you can uncomment the scanfor option and ensure that hdbios is not among the options. See this page of the rEFInd documentation -- read the "Hiding and Displaying EFI Boot Loaders" section, or search for dont_scan within the page.

Background Information: The Explanation (tl;dr)

rEFInd is a boot manager, which means it presents a menu of boot options to you and lets you select one option. This contrasts with a boot loader, which loads an OS kernel into memory and starts it running. Whenever rEFInd starts, it scans the computer for EFI boot loaders, which fall into two or three categories, depending on how you're counting:

  • BIOS-mode boot loaders -- These are handled differently for UEFI-based PCs and Macs, but in either case, if you select one of these, the machine uses a Compatibility Support Module (CSM) to launch an old-style BIOS boot loader, such as the BIOS version of GRUB. It's possible that this is what you're seeing -- a BIOS-mode GRUB that was installed to your computer because you installed Ubuntu in BIOS mode.
  • EFI-mode boot loaders -- These all launch in the same way, but rEFInd includes code that makes for a general case and a special case within this category:
    • Conventional .efi files -- Most EFI boot loaders come in files with names that end in .efi, such as grubx64.efi, which is the EFI-mode version of GRUB. For most of these files, rEFInd just launches them with no options. (There are some exceptions to this rule, but you needn't be concerned about them.) It's possible this is what you're seeing when you launch Ubuntu from rEFInd.
    • Linux kernels -- Since version 3.3.0, the Linux kernel has provided a feature called the EFI stub loader, which turns the Linux kernel into its own EFI boot loader -- it can be run like an EFI program. Thus, rEFInd looks for common Linux kernel filenames (vmlinuz-* in the case of Ubuntu) and, if a cursory check makes them look like they're executable EFI programs, adds them to its menu. rEFInd can also locate matching initial RAM disk (initrd) files and can pass options the kernel needs to boot, either by extracting the data from files like Linux's /etc/fstab or by using a dedicated configuration file, refind_linux.conf, that rEFInd's installation script generates to go alongside the kernels. Criticially, rEFInd can find Linux kernels only on filesystems it can read. Most EFIs can read only FAT filesystems, but Linux kernels normally go on ext2/3/4fs, Btrfs, or some other Linux-native filesystem. Thus, you'll see Linux kernel boot options in rEFInd's menu only if you copy the kernels to a FAT filesystem or if you add EFI filesystem drivers to the rEFInd installation.

When you use rEFInd with either a BIOS-mode boot loader or a conventional EFI-mode boot loader like GRUB, rEFInd passes control to that boot loader, which may interact with the user. GRUB, in particular, is both a boot loader and a boot manager, so you're likely to see a GRUB menu after rEFInd launches it. Most other OSes have much simpler boot loaders than GRUB; these boot loaders launch their OSes without bothering to present options menus, except possibly if something goes wrong.

The EFI stub loader is a much simpler boot loader than GRUB; it does not present its own boot manager menu. Thus, when you use rEFInd to launch a Linux kernel via its EFI stub loader, you'll see no follow-on menu.

If your rEFInd menu has just one Ubuntu option, and if it launches GRUB, then you're booting using either a BIOS-mode GRUB or an EFI-mode GRUB. (You can tell which is the case by examining the description, which either specifies a legacy-mode boot or identifies the filename of the EFI-mode boot loader.)

Rod Smith
  • 44,284
  • 7
  • 63
  • 105
  • Wowe, fantastic information here Rod, thanks very much. A lot of reading and understandig for me to press on with. Much appreciated. – John Apr 25 '17 at 15:09
  • Superb answer, as usual. On my Macbook I decided I actually wanted to remove the boot loader from the partition and I pruned the boot code from the boot record. This way your amazing software would not list GRUB as an entry, but only the kernels. This was done because I still wanted to detect legacy bootloaders on external USB drives, so I didn't want to disable boot sector scanning completely. – Andrea Lazzarotto Apr 26 '17 at 22:07
  • 1
    @Andrea, note that rEFInd enables you to detect or ignore BIOS-mode boot loaders separately for internal, external, and optical devices. To do so, uncomment and edit the scanfor line: hdbios enables BIOS-mode disk boot loader detection, biosexternal applies to external disks, and cd refers to optical drives. (The internal, external, and optical options do much the same for EFI-mode boots.) That said, wiping out an unwanted BIOS-mode boot loader with dd will also do the job. That's a riskier approach, though. – Rod Smith Apr 28 '17 at 17:32
  • Ah, I didn't know that. Thank you! That is very good to know. I was also skeptical about wiping the entire PBR. IIRC I just blanked the machine code jump instruction bytes, or something like that, so it didn't look like an executable. – Andrea Lazzarotto Apr 28 '17 at 22:04
  • BTW @John IMHO the best "experience" to get what you want is hiding GRUB from rEFInd as Rod explained and then using the single kernel entries to boot. This is what I personally do and it's quite clean when booting the Mac, with a minimal theme you can only get two big icons and little more. :) Of course it depends on your taste as well. – Andrea Lazzarotto Apr 28 '17 at 22:05