I've faced a similar problem with another HP notebook.
The problem is that even if you change the EFI boot order permanently (with command: "efibootmgr -0", for example), your change will be overwritten each time you boot Windows.
To workaround the problem, I had to install rEFInd manually.
Then, I've located the default EFI boot loader (.efi), backed it up and replaced it by the one from rEFInd (renamed) [don't forget to copy other folders and files pertaining to rEFInd in the same folder]. I don't remember which one was the default EFI boot loader and I can't check on the computer since it is owned by one of my customers.
WARNING : If you have to apply that tricky workaround, please ensure that you can boot on the normal installation of rEFInd via the boot menu before, so that you can easily revert the changes in case of problem or if you change your mind in the future!!!!!
rEFInd manual installation procedure is available here: http://www.rodsbooks.com/refind/installing.html#linux
For a clear example for changing EFI boot order permanently with efibootmgr (will probably not work on your computer, as stated above, however I highly recommend to try that first), please take a look at this post from Rod Smith (the creator of rEFInd).
It seems that the renaming trick is now fully documented on the official Web site of rEFInd : http://www.rodsbooks.com/refind/installing.html#naming, http://www.rodsbooks.com/refind/installing.html#manual_renaming
rEFInd is really user-friendly (once installed) and allows to workaround such poor EFI implementations.
Step by step, failsafe approach
Trying to change UEFI boot order with efibootmgr
Under Ubuntu, open a terminal and install "efibootmgr", if it is not already installed, by using the following command:
sudo apt-get install efibootmgr
Retrieve EFI boot order and entries with the command:
sudo efibootmgr -v
BootCurrent: 0002 (indicates the UEFI boot entry used for booting).
BootOrder: 0002,0003,0001,0000 (indicates the UEFI boot order defined).
Boot000x* (represents one boot entry. It is followed by its name, HD and EFI file. All the boot entries are listed below "BootOrder").
Define the new boot order with the command:
sudo efibootmgr -o 0001,0002,0000,0003
In the command above, I suppose that Ubuntu entry is 0001, Windows is 0002, Recovery is 0000, Diagnostics is 0003. Of course, you may have more or less entries and/or wish to setup a different order. I suggest that you copy the "BootOrder" value from the command "sudo efibootmgr -v" and adapt it as you want. Then check the result of the command.
Check again the "BootOrder" with the command used at step 2.
Restart your computer properly and check that the system boots the expected (first) entry of the new boot order (here, Ubuntu). If it works, restart and try to boot Windows (via UEFI menu), then restart the computer again and check that Ubuntu is still booted by default. If it works as expected, you're done! The EFI implementation is correct and you don't need to do anything more. If not, jump to the next solution.
Installing and configuring rEFInd
- Disable Secure Boot feature in your BIOS, if it is not already done, in order to avoid extra complications;
- Under Ubuntu, Download the binary ZIP file of rEFInd from this page: http://www.rodsbooks.com/refind/getting.html;
- Unzip the ZIP archive;
- Open a terminal and move to the folder where the archive files have been extracted (the command should look like:
- Follow the steps (1 to 6) described here: http://www.rodsbooks.com/refind/installing.html#linux. Your architecture is very probably x86-64, so use
rm refind_ia32.efi at step 3;
- Edit the configuration file (refind.conf). Simply use
sudo nano ./refind.conf or
sudo -i gedit ./refind.conf. I'm assuming that the current directory is still rEFInd's directory on the ESP. You will be very interested in "timeout" (value like: 1) and "default_selection" (value like: Ubuntu) parameters to configure automatic boot to Ubuntu.
- Restart the computer, use the UEFI boot menu for launching rEFInd and checking that its configuration fulfil your needs. If not, start Ubuntu and edit refind.conf in its directory on the ESP and repeat this step until the settings fit all your requirements. Please check that you can boot Ubuntu and Windows as well from rEFInd (longer timeout value may help).
- Identify which EFI file is used by default by your system and locate its folder on the ESP (It might be something like "EFI/Microsoft/Boot/bootmgfw.efi" or else). Don't forget the command
sudo efibootmgr -v which can be very helpful to get this information.
- Copy the content of the refind folder on the ESP in the folder of the default EFI file identified at step 7 ("EFI/Microsoft/Boot/" in the example). You can even use command
sudo -i nautilus if you are not very familiar with the command line. Assuming that the ESP is mounted at /boot/efi, you can use the following command :
sudo cp -r /boot/efi/EFI/refind/* /boot/efi/EFI/Microsoft/Boot/. Don't forget to adapt the destination path as required.
- Rename default EFI file ("bootmgfw.efi" in the example) in "bootmgfw.bak" (
sudo mv bootmgfw.efi bootmgfw.bak, if you are in the right folder. You can use
cd /boot/efi/EFI/Microsoft/Boot/ to switch to that folder [I'm still assuming that ESP is mounted at "/boot/efi" and that the relative path to the default EFI file is "EFI/Microsoft/Boot/"]);
- Rename rEFInd EFI file ("refind_x64.efi") as the default EFI file (here, "bootmgfw.efi"). Use
sudo mv refind_x64.efi bootmgfw.efi, if you are in the right folder.
- Restart your computer and if everything is OK, you're done! If something goes wrong, you can still use UEFI boot menu to launch rEFInd, boot Ubuntu and revert the changes made in steps 8 to 10.