UEFI, GNU/Linux and HP notebooks – problems and how to get it working

There is a lot of confusion and wrong information in the internet about the Unified Extensible Firmware Interface (UEFI) and how to set it up correctly – especially under GNU/Linux. What makes things worse and also confused me a lot is that all vendors tend to implement this “standard” differently. So although UEFI is defined as a new industry standard replacing the BIOS, it can hardly be called “standard” at this time. Yet another problem of understanding UEFI is, that people seem to mix up words that have a special meaning.

My old notebook still uses the old BIOS-MBR setup, not capable of any UEFI fancy-ness. But it is dying, so I recently bought a new one. It is an “HP EliteBook 840 G1”. I used that opportunity to familiarize myself with UEFI and GNU/Linux.

This article explains two things (only taking GPT setups into account):

  • How is UEFI implemented in practice and set up with GNU/Linux?
  • How to set up UEFI and GNU/Linux on HP notebooks?

How is UEFI implemented in practice and set up with GNU/Linux?

First, you should read some general information about UEFI, if you are new to it. (You should read this, if you do not fully understand the following paragraphs.)

The vocabulary for UEFI terms used on the internet is very confusing and often wrong. People often use one term, e.g. “BIOS” or “boot manager”, to refer to different things. When they use the word “BIOS”, they sometimes actually mean BIOS, a few lines later they using the same word to refer to the “UEFI pre-boot graphical environment” – bad practice and simply wrong. The word “boot manager” is even more problematic, as with UEFI there actually is more than one boot manager (in contrast to BIOS-MBR systems). I will try to explain (simplisticly) how an UEFI-GPT setup is generally implemented with GNU/Linux while defining UEFI specific terms for this article. Hopefully, this will give the reader a clearer view of UEFI and GNU/Linux.

When setting up an UEFI system with GNU/Linux we need to know about two things:

The ESP is a regular partition in the main (GPT) partition table of your HDD/SSD with a FAT32 filesystem. It should be 512 MiB in size, although smaller or bigger sizes are possible. The partition type code should be “ef00” (using “gdisk“, with “parted” you have to set the bootable flag instead). On this ESP, the UEFI applications are saved. These UEFI applications usually are the Operating System (OS) boot loaders (e.g. GRUB, ELILO or Mircosoft Windows Boot Loader), but can be applications for memory testing or interactive Shells as well. I intentionally use the word “saved”: There is no much of an installation process – the UEFI applications can just be copied manaully (e.g. using “cp”) to the right paths (just keep in mind possibly hard coded paths within the UEFI applications). The applications are saved by honoring the following path scheme (e.g. on a x86-64 architecture):

Where “APPNAME” is a descriptive name, you can freely choose. Note that noramally upper or lower case letters do not matter, since FAT32 filesystems are case-insensitive (unless UFT-8 encoding is explicitly used). Also note the use of backslashs, as UEFI internally uses backslashs. Under GNU/Linux, of course, use normal slashs. The backslashs only are important when defining paths within the UEFI pre-boot graphical environment or the UEFI shell. Additionally, a few standard paths are defined (but do not have to exist on your ESP):

On an UEFI system you have to distinguish between two different kinds of boot loaders: the OS boot loader already mentioned above (UEFI application) and the UEFI boot loader, which launches the specified UEFI application. The UEFI boot loader is controlled via the UEFI NVRAM settings.

To configure the UEFI boot loader you have to change the variables in the UEFI NVRAM. This can be done in the running OS. In GNU/Linux this can be achieved using the “efibootmgr” program. Just typing:

should show the current UEFI boot manager settings. With this tool you can add and remove boot entries and adjust the boot oder. Every UEFI application copied to the ESP should be added to the UEFI NVRAM.

Note that most GNU/Linux OS boot laoders will do both during their installation, copy their UEFI application to the right place on your ESP and add an entry to your UEFI NVRAM – as long as an ESP already exists.

Now, what if you can simply configure the boot order in the BIOS-like UEFI pre-boot graphical environment – just as you could change it in the BIOS before, with your BIOS-MBR system? Well, lucky you! When saying “changing s.th. in the BIOS” (on a BIOS-MBR system), we usually meant entering the graphical environment by pressing a certain key after switching on the computer and change some values there. The UEFI standard, however, does not define such a graphical environment. But for convenience, most computer vendors add such a BIOS-like UEFI pre-boot graphical environment to aid the transition from traditional BIOS systems to UEFI. Such a system then auto-detects applications on your ESP, adds them to the boot order and lets you configure it just as you would on your old BIOS-based system.

Now, this is the problem: Although UEFI itself defines a standard, the actual implementation of UEFI by the different computer vendors is far from standardized. They do as they like and thus every computer acts differently. This point gave me a hard time figuring out how to configure my new notebook.

Short summary

To get your UEFI-based system to boot GNU/Linux you have to:

  • set up an ESP
  • copy the UEFI applications to it
  • change the UEFI NVRAM variables

Note that the last two points are normally done automatically when installing certain OS boot loaders (e.g. GRUB).

Also note that althought this is very easy and straight forward to set up, it often creates problems, because computer vendors implement certain functions differently and deviate from the UEFI standard (see next section).

How to set up UEFI and GNU/Linux on HP Notebooks?

As mentioned above, I bought a new HP notebook (HP EliteBook 840 G1), which gave me a lot of trouble when trying to set it up with UEFI and GNU/Linux. The notebook just did not want to boot my favourite GNU/Linux distribution, Arch Linux, although everything was installed and configured correctly. It took me quite a while to understand HP’s rather studip implementation of UEFI. While investigating that issue, I found that quite a lot people had similar problems with their HP notebooks (although different models). So this seems to affect all kinds of HP notebooks. This section covers troubleshooting and workarounds of UEFI boot problems with HP notebooks (esp. HP EliteBook 840 G1).

First, make sure you have the latest firmware installed. Things have gotten a lot better with the last fimrware updates.

I installed Arch Linux with GRUB on my HP EliteBook. I set up the ESP beforehand and GRUB installed it’s UEFI application to it and added an UEFI NVRAM entry just fine. Still the notebook refused to boot. So the regular way did not work. The problem was that HP hard coded the path for the OS boot manager in their UEFI boot manager to

to boot Microsoft Windows, regardless of how you changed the UEFI NVRAM variables. So when setting the device boot order in the UEFI pre-boot graphical environment of HP to boot from the first HDD/SSD by selecting “OS Boot Manager” it expects to boot Microsoft Windows (only!) from above mentioned path. The only workaround was to change the UEFI application path of the OS boot loader to that hard coded path.

On your ESP (e.g. $MOUNTPOINT=/boot/efi), do (e.g. GRUB on Arch Linux):

After that, GRUB loaded as expected. This was far from perfect, as it obviously would create conflicts in a dual boot setup with Microsoft Windows. Also, everytime you installed GRUB, you had to remmeber to copy it over to the hard coded path. (Admittedly, you do not install GRUB that often, though.)

A later HP firmware update made things much better. The above path was still hard coded, but at least they added the UEFI standard path (also hard coded):

Now, at least you could have both, a GNU/Linux OS boot loader and Microsoft Windows OS boot loader in their own places. Although I did not try which loads first.

But the real improvement is, that the new HP firmware allows defining a “Customized Boot” path in the UEFI pre-boot graphical environment:

Select the “Customized Boot” option in the UEFI pre-boot graphical environment under “Boot Optoins” and set the path to:

and adjust the device boot order (also in the UEFI pre-boot graphical environment) to boot this entry first.

This seems to be the best (acceptable) solution so far. Why HP hard codes these paths in the first place and names them “OS Boot Manager”, is beyond me. Also, I do not understand why most computer vendors in general deviate from the UEFI standard – it gives users a hard time figuring out what is wrong. It defeats the very purpose of a standard!

Other souces:

 

12 thoughts on “UEFI, GNU/Linux and HP notebooks – problems and how to get it working

  1. Thank you very much for the info, very useful although I am still working on the best way forward. I have been using a Lenovo x301 with a triple boot (Windows7, Sabayon, OpenSuse) managed by grub from Sabayon. Never had any problem, the three systems worked perfectly for 2 years without a glitch.

    Now I have an EliteBook 840 G1, like yours, but I am having hard-times. I think I have understood your explanation and the critical points, however I need some support. I have upgraded the bios to new version (I am running L71 ver 1.08) but still I have difficulties implementing the multiboot. Here my questions:

    – in the BIOS (or how should I call it?) before installing any OS, should I set UEFI Native, UEFI Hybrid or the Legacy options?

    – With the old Bios laptops, when it comes to multiboot with Microsoft and Linux, it has always been better to start with Windows: now with this new laptop and BIOS, is there any preference or can I start installing Windows 8 as first OS?

    – Either if I start with Windows or with a Linux distro, should I create the 512 Mb ESP partition (Fat32) in the first place?

    Thank you very much again

    Fabio

    • Hello Fabio,

      first of all, thanks for your comment. However, I never set up a multi-boot configuration with Microsoft Windows using UEFI on this notebook. So I can answer your questions only in theory.

      – in the BIOS (or how should I call it?) before installing any OS, should I set UEFI Native, UEFI Hybrid or the Legacy options?

      If you want a pure UEFI system, you should set the mode to “EUFI native” in the UEFI pre-boot graphical environment. That way, you can be sure that the installation media (in your case probably a bootable USB-Stick with Microsoft Windows and later your preferred GNU/Linux distribution) is booted in UEFI mode and installs to your notebook in that mode.
      In GNU/Linux, you can easily tell if you booted in UEFI mode and if everything is working correctly by typing:

      # efivar -l

      The output should not give you any errors and list the available UEFI variables.

      Under Microsoft Windows, you can see if you booted in UEFI mode by checking the partition table type. It should be “GPT”. As far as I know, Microsoft Windows only installs in UEFI mode, when using a GPT partition table. An UEFI-MBR configuration is not possible.

      – With the old Bios laptops, when it comes to multiboot with Microsoft and Linux, it has always been better to start with Windows: now with this new laptop and BIOS, is there any preference or can I start installing Windows 8 as first OS?

      Same here, I would recommend installing Microsoft Windows first. Microsoft Windows has quite an aggressive way of installing and potentially wipes out your UEFI boot entries etc. instead of just adding it’s own boot entry. It is not fatal, but it requires extra steps to be able to boot into GNU/Linux afterwards. (In practice, on this particular notebook it will not make much difference, since HP disregards your UEFI boot variables anyway.)

      – Either if I start with Windows or with a Linux distro, should I create the 512 Mb ESP partition (Fat32) in the first place?

      Yes, no matter what OS you install first, you need to partition and format your HDD/SSD first (that includes setting up an ESP). I strongly recommend to do the partitioning under GNU/Linux, as it is much more flexible.

      The way I would tackle your desired setup is:
      * Set the boot mode to “UEFI native”.
      * Partition your HDD/SSD under GNU/Linux (use a live USB-Stick). Set the partition table to “GPT”, create an ESP and your desired partition scheme for GNU/Linux. Leave enough space for Microsoft Windows.
      * First install Microsoft Windows unsing a bootable USB-Stick. It should detect your previously created “GPT” partition table, as well as your ESP. Install Microsoft Windows to the unallocated space you left free during partitioning, leaving the other partitions untouched. Again, if Microsoft Windows uses the “GPT” partition table, you know it installs in UEFI mode.
      * Install GNU/Linux after you finished the Microsoft Windows installation. I would not care to much about setting up a Microsoft Windows chainloading entry in your GNU/Linux boot manager as this can now be handled by the UEFI boot manager alone (see below). Just install GNU/Linux as if it was the only OS on the notebook.
      * Now, no matter how you setup your notebook, it will always try and only boot Microsoft Windows by default. What you need to do is to set the path of your GNU/Linux boot loader with the “Custom Path” option in the notebook’s UEFI pre-boot graphical environment (as described in the article).

      Now, you can change the OS boot order to your liking in the UEFI pre-boot graphical environment, with “OS Boot Manager” beeing your Microsoft Windows and “Custom Path” your GNU/Linux distribution. To switch between the two at startup, use the UEFI boot manager by pressing the “ESC”-key after turning on your notebook and in the following menu “F9”.

      Please do not take above steps for granted. It is just the way I would tackle this problem in theory, as I do not have Microsoft Windows installed. It is totally untested. You should probably also consult one of the many guides out there, that explaine how to set up a multi-boot environment with Microsoft Windows and GNU/Linux.

      • Dear 6arms1leg,

        thanks again for your support. I am not particular expert of Linux distros but I like to learn, therefore I made a few tests.

        Before reading your answer, I set the UEFI to Native and I tried installing Sabayon as first OS, than Windows, and last OpenSuse (I wanted to understand the implications of not having Windows as first system). Last I also used the Custom Boot option.

        After every installation/configuration I tested the system.

        With Sabayon I created the /boot/uefi partition in FAT, and than I installed the system in two ext4 partitions (/ and /home) plus the swap.

        Sabayon Rebooted and tested: the UEFI preboot graphic started, with two options: sabayon and the UEFI file. With sabayon the system started perfectly and booted extra fast. If I select the EFI file, nothing happens.

        Installed WIndows 8.1. It didn’t ask anything about the UEFI during the installation. I installed Windows in a new partition, and it created its additional partitions. Rebooted and tested: the preboot screen showed OS Boot Manager, boot from EFI file and Sabayon. From the UEFI preboot graphic menu, both the OS Boot Manager (for Windows) and Sabayon boot and work perfectly.

        I could also have Sabayon to manage the multiboot: the grub2 was detecting Windows and I could configure Grub2 to display an additional Menu after selecting Sabayon from the uefi preboot screen.

        Installed OpenSuse: I gave /boot/efi as boot, shared the swap with Sabayon and installed in a new single partition.

        Suse was correctly added to the UEFI preboot graphic menu and it started correctly. The only difference now is that if I select Sabayon from the UEFI preboot menu, it takes ages to load. It takes so long that you may think that it failed. Once you log in it performs correctly, but it takes really too long to load.

        I played around a little bit, having the Grub2 from Suse to manage everything. It works, but while Windows and Suse boot very quickly, now sabayon, no matter if called by the preboot menu or by the Grub2 of Suse, takes ages to load.

        I tried to customize the boot. I tested putting the path of Sabayon, checking if it was faster in this way: with the path of sabayon, it is like I haven’t customized anything, it does not start and than it displays the preboot UEFI menu. If I put the path of Suse, Suse starts correctly and I can have the three systems managed by Suse. However, Sabayon keeps loading very slow.

        I managed to have the triple boot, all EFI, but Sabayon takes too long to be booted, no matter how I call it.

        I checked the /boot/efi partition and I found out that is a FAT16 bit partition. It has been Sabayon that created it (it was the first OS to be installed), and there were no options in the installer if create a 16 or 32 FAT partition. There was only the option to be FAT.

        Now I do not know if this has something to do with the fact that Sabayon loads very slowly (although when it was only Sabayon and Windows, it was loading fast), however the fact that if I put the Sabayon path in the Customize Boot option, The Sabayon menu does not start, triggers a bell.

        I want to retry everything from scratch, installing Windows as first, and having this ESP partition to be a FAT 32.

        Let’s see what happens. Thanks again for your support, your articles switched on a light at the end of the tunnel.

        I will let you know if I will manage to speed up the Sabayon booting.

        Fabio

        • Hello Fabio,

          thanks again for sharing your experiences. There are a few things I want to comment on:

          Installed OpenSuse: I gave /boot/efi as boot, shared the swap with Sabayon and installed in a new single partition.

          Sharing a swap partition/file is dangerous, if you use hibernation. If you have a multi-boot GNU/Linux setup and make use of hibernation, sharing a swap partition/file will lead to data loss!

          […], and there were no options in the installer if create a 16 or 32 FAT partition.

          That should make no difference. The ESP (normally) is only 512 MiB in size, so size limitations of the file system are irrelevant. I do not believe, that the file system causes Sabayon to load slowly. Either the UEFI boot manager can read the file system or not. It should have no problem reading FAT16 or FAT32.

          I want to retry everything from scratch, installing Windows as first, and having this ESP partition to be a FAT 32.

          You do not have to install everything from scratch just to change the boot order. Since the HP EliteBook 840 G1 ignores the UEFI boot variables anyway, you can simply rearange your ESP. For example, if you want to reformat your ESP with FAT32 instead of FAT16 (although I doubt it will make any difference), boot your system and write the following in a shell (replace “$ESP” with the mountpoint of your ESP and “sdXx” with your actual device partition):

          $ sudo tar --one-file-system --same-owner -cvzpf ESP.tar.gz $ESP/ # backup all files on your ESP
          $ sudo umount $ESP
          $ sudo mkfs.vfat -F 32 -n ESP /dev/sdXx # reformat the ESP
          $ sudo mount /dev/sdXx $ESP
          $ sudo tar --numeric-owner -xvzpf ESP.tar.gz -C $ESP/ # restore the backup

          I guess, you can omit the “–same-owner”, “–numeric-owner” and “-p” flags – it makes no difference on a FAT file system.

          If you want to re-install GRUB, have a look at the man page:

          $ man grub-install

          To re-install an OS boot loader, you do not need to re-install your OS – at least not under GNU/Linux.

          • Thank you 6arms1leg, very useful indeed.

            I rearranged the EFI sequence and reformatted the \boot\efi partition following your suggestion.

            As you predicted no big changes in terms of booting speed for Sabayon. The only thing I have noticed is that if I have OpenSuse and its grub2 to manage the [custom] multiboot, Sabayon loads a bit faster than if I have Sabayon itself (and its grub2) to manage the multiboot. Weird but true. There are about 15 sec difference (over a total time of ~40 sec) between the two grub/s when it comes to load Sabayon. It appears the grub from OpenSuse loads Sabayon faster than the Sabayon one.

            Still I can’t understand how is possible that when I had only Sabayon and Windows 8, Sabayon was loading in ~5-7 sec.

            However I do not care much now 🙂 I mainly work with OpenSuse, and I practice my Linux with Sabayon. It is OK like that.

            Suse and Windows load in 5 secs, it is amazing.

            With only the customized boot enabled in UEFI, I managed to have 3 systems on the laptop and I eliminated any additional interface: after the UEFI pre-boot, control goes directly to the grub I specified in the path.

            Back to business 🙂

            Thanks a lot 6arms1leg

            Fabio

  2. Nice work, This is an awesome resource! As a blind Linux user, I haven’t found anything thus far to point me in the right direction to help me out when it comes to my HP laptop and wanting arch Linux on it to replace windows completely

  3. Hi, thanks a lot for the valuable information!
    The described solution with the “Customized Boot” option is applicable for HP ProBook 450 G0 with the latest firmware upgrade since January 2015.
    I set-up a dual-boot system with MS Windows 8.1 and SUSE Linux Enterprise Desktop 12. The Windows was installed first, the Linux GRUB successfully added an option (menu row) to start Windows and when I set the Customized Boot to \EFI\sled12\grubx64.efi everything was OK.

Leave a Reply

Your email address will not be published. Required fields are marked *