After the two previous posts about installing openSuSE 12.3 and Fedora 18 on my sub-notebooks with UEFI BIOS and Windows 8, my intention was to continue with the same theme a third time and write about Ubuntu.
However, I have decided not to do that quite yet, first because I'm getting pretty bored with it, and second because Ubuntu 13.04 is supposed to be released at the end of this month, so I think I will wait until we are closer to the release date before writing that.
Instead, I am going to pick up a thread that I mentioned in each of the previous UEFI Boot posts and I have promised to get back to "real soon now".
This one is going to be somewhat more technical, and will have a lot less pretty pictures included, so you might want to get a strong cup of coffee before starting, if you are determined to stay awake until the end. For the impatient readers, I will start with a summary:
The UEFI boot systems I have always boot the file bootmgfw.efi from the EFI Boot partition, come hell or high water.
All of my attempts to change the configuration to get it to boot something else have eventually failed.
The UEFI-compatible Linux systems I have installed include the grub2-efi boot loader. Getting the computer to boot this by default is the trick.
The simplest way to permanently achieve this is to copy the Linux bootloader files to the default bootloader directory, and then rename the Linux bootloader to bootmgfw.efi
That's it, in a nutshell. All the gory details follow, bit I will say this as clearly as possible first. Mucking about with the boot process on your computer can be dangerous. If it all goes pear-shaped you may have to reload from scratch.
The details and procedures which I present here are as complete and accurate as I could make them, and work on my HP and Acer systems, but there may be significant differences in UEFI implementation, so don't be surprised if things look different or work differently on your computer.
Oh, and by the way, based on the information I have read about UEFI boot, Linux, and Samsung computers, even I would not try this on one of those, period.
So here come the details of my experiments.
If you have a UEFI Boot system, and you followed the details of either or both of my preceding posts, when you rebooted your system after installing Linux you probably got a surprise - no sign of Linux. Just the same old ordinary Windows 8 boot.
No Grub boot menu, no operating system selection, no Linux boot. Just Windows.
There are two related "problems" at work here - first, the whole theory of booting has changed with UEFI boot, and second the current state of UEFI Boot Managers is very poor (in my opinion, and based on my experience with HP and Acer UEFI systems).
I will explain each of those problems in more detail separately.
The boot process has been radically changed with UEFI boot. As I understand it, the process is now broken into two pieces, one is the "Boot Manager", which finds, presents and controls what can be booted, and the other is the "Boot Loader", which actually does the booting (load and run) of whatever is selected by the Boot Manager.
By the way, if I have this completely wrong, please feel free to correct me in the comments - I'm sure there will be plenty of "corrections" anyway, many of which will themselves be completely wrong, nothing new in that.
So when the computer is initially powered on, the Boot Manager looks around and decides what candidates for booting are available, and which one has first priority. Unless it is interrupted (by you pressing the boot selection key) it will then try to pass control to whatever boot loader it decides comes first.
The Boot Manager which came on my HP and Acer systems is pretty grim, to be kind.
It is difficult to configure, it is prone to tossing whatever configuration changes you might make and going back to its original default configuration, its on-screen presentation looks like something that came out of the original War Games movie from 1983, and well, it is just generally not very pleasant. The best that can be said for it is that it gets the job done, more or less.
If you take the time to find and read the documentation for the UEFI boot system in general, and the Boot Manager in particular, it sounds like it could be a lot better than that. It could have a Graphical User Interface, it could present wonderful classy menus of boot candidates, it could have a very spiffy configuration center, and so on.
However, the ones I have experience with are really good at exactly one thing - starting the Windows Boot Loader. Well, two things... they are also really good at throwing away everything I try to do to configure them, and returning to the first thing they are really good at.
I wrote not long ago about the rEFInd boot loader, which does a lot of the things which I just mentioned, but it has to be installed as a separate package after installing Linux, and it is not easy to get working with Secure Boot enabled. My intention here is to show how I get dual-boot/multi-boot working with a minimum effort, using only what gets installed with a standard Linux distribution. So I will not go into any more detail here about rEFInd.
The Windows Boot Loader is also supposed to be capable of booting multiple operating systems. I have tried to get it to do this with Linux installed in addition to Windows, and I have failed miserably. I have read everything I can find on the Internet about configuring it, and I have tried to use my knowledge from configuring the boot loaders in Windows XP, Vista and Windows 7.
I have tried using BCDedit and easyBCD, and I have never managed to get it to do anything other than boot Windows 8. I have gotten it to present a graphical "selection" menu with pretty buttons to click for Windows 8 and whatever else I am trying to add, but none of the buttons other than Windows 8 ever actually works.
Perhaps I am just too dense to understand it, and if anyone would like to enlighten me, with a complete and functioning example, please feel free to do so. Oh, make that a complete and functioning example which includes booting Linux, because being able to "multi-boot" several different versions of Windows is not interesting to me, and doesn't seem to be particularly difficult...
So, in my case there are only two ways to boot Linux - either interrupt the Boot Manager, by pressing whatever the Boot Selection key is on your computer (ESC, F9, F12 or some such), or install some other Boot Loader and convince the Boot Manager to start that by default instead of the Windows Boot Loader. If you take the first course, and interrupt the Boot Manager, you get something like this:
This screen shot was taken from one of the system where I have openSuSE and Fedora both installed in addition to Windows 8. I can move up and down with the arrow keys, and then press return when I am on the one I want to boot. I wrote something very similar to this in a shell script in about 1982, and I am shocked and disappointed to find it here... If only I had thought to patent it at the time, I could be making a fortune today! Or not...
Well, whatever, it is what it is, and I find it to be unpleasant and inflexibie, so I need to figure out how to replace it with something I like better. To help me do that, I will use the Linux efibootmgr utility to list and edit the boot manager configuration. Here is the list from one of my systems:
The first few lines are what I am interested in, it is a list which corresponds to what the Boot Manager presented in the boot selection list. I am not going to spend a lot of time on things that I have learned the hard way don't work here, I will just say that there are a lot of options for the efibootmgr program which allow you to add and delete items and change the boot order (use the -? option to list them all), but most everything I did, which appeared to work when I listed them again, ended up being thrown away either during the next reboot, or the next time Windows was booted.
So the only really important bit of information here is the path of the Windows Boot Loader, which is the object that the UEFI Boot Manager insists on booting by default - "\EFI\Microsoft\Boot\bootmgfw.efi". I'm hoping that if I replace that file with the boot loader of my choice, I will be able to trick the Boot Manager into doing what I want.
The paths used by the Boot Manager are relative to the EFI Boot Partition, which is /dev/sda2 on both of my systems, and which is mounted on /boot/efi under Linux - the actual partition may change, but the mount point will always be the same. Linux installations which are UEFI Boot compatible will create their own directory to contain their boot loader binary and configuration files, so on my system I have /boot/efi/EFI/opensuse and /boot/efi/EFI/fedora. Their contents are:
The important things there for my purpose are the grub EFI binaries, which you can boot directly if you don't have Secure Boot enabled, and the shim EFI binaries, which are what you have to boot if you do have Secure Boot enabled. Assuming that I want to boot the openSuSE version of grub by default, what I do next is copy the contents of this directory to /boot/efi/EFI/Microsoft/Boot/. Please note that I said copy, not move, because you don't want to destroy your existing boot configuration, so if things go wrong you can always recover by using the boot select key. Also, you don't absolutely have to copy everything, but it doesn't hurt to do so; if you have gotten this far and are still awake, you should be able to figure out which bits you don't need without too much difficulty, at least by trial-and-error if nothing else.
Once I have the openSuSE boot files in the default boot directory, all I have to do is rename things so that the boot manager runs grub rather than the Windows Boot Loader. I try to be careful and leave myself a way to recover from misunderstandings and mistakes, so I first rename the file for the Windows Boot Loader from bootmgfw.efi to something like bootmgfw.ms.
Then I rename shim.efi to bootmgfw.efi and I am done. The shim file will boot whether Secure Boot is enabled or not, but if you know that you are going to have Secure Boot disabled, and you want to save one step and simplify the boot process a bit, you can rename grubx64.efi to bootmgfw.efi instead.
But be aware, if you do this, and then later enable Secure Boot, the next time you try to boot the Boot Manager will notice that something is wrong.
What it does seems to depend on the specific system on which it happens; it can range from just using a fall-back boot image which will start Windows 8, or dropping into the boot selection menu, or restoring a copy of the original boot files, or it can even go so far as to run what seems to be a very large and very complex Windows recovery procedure in order to get back to the factory boot configuration.
When you reboot after making these changes, you should get the openSuSE grub boot loader, which will give you a simple graphic menu where you can choose to boot either openSuSE or Windows 8. Hooray!
There are just a few loose ends that I would like to clean up.
For the vast majority of people, who are trying to set up a simple dual-boot configuration with Windows and Linux, this procedure will work equally well using either openSuSE or Fedora. In my case I want to set up a multi-boot configuration with several different Linux distributions, so I always use openSuSE as the base because I have found that its grub is more flexible, and at least with Secure Boot disabled it is able to boot other EFI images (such as Fedora and Ubuntu) and even non-EFI "traditional" boot distributions such as Linux Mint.
Please remember, mucking about with the boot configuration is dangerous. Make sure that you have complete backup and/or recovery media and procedures on hand before you try this.
As I have mentioned a couple of times, there seem to be differences between vendors in the details of the implementation, checking and automatic "repair/recovery" procedures, so don't expect that I have covered all the possibilities here, and don't be surprised if at some point you try to boot and rather than starting grub your computer starts showing that blasted rotating circle of dots, indicating that Windows is doing something whether you want it to or not.
If that happens, what I would do is not try to stop it, just let it finish, and you should be able to go back and "pick up the pieces" or just start over again.