As of January 2015, the bios for UEFI in HP laptops (probably any HP computer) is broken. Every time the bios runs, it overwrites the boot sequence to make sure that Windows boots. As a temporary workaround, you can interrupt the boot sequence and choose to boot ubuntu (in my laptop, the sequence is Esc, then F9).
However, that is probably not a good long term solution to the problem. I also did not like the USB boot solution proposed above. I don't want to have my system on a USB drive. Fortunately, you can make it work. Use the dual boot instructions here and the HP fix/workaround below.
GreatEmerald writes the solution here, but I will copy so to have more references to this important solution. The below recipe worked for me, although I used bootmgf2.efi
instead of bootmgfw.efi~
.
There is some sort of a "recovery feature" or so that on every boot sets the very first UEFI load option to point to one of the two locations, in this order:
\EFI\Microsoft\Boot\bootmgfw.efi
\EFI\Boot\bootx64.efi
This option is displayed as "OS boot Manager" (for the first path) and something akin to "UEFI partition" for the second path, completely ignoring the actual name given to it (when you look at the EFI variables through efibootmgr, you can see that what is displayed as "OS boot Manager" actually is set to the name "Windows Boot Manager"; why anyone would do such renaming is beyond me). If you try to change the boot order so that this slot isn't the first, the UEFI will overwrite the BootOrder variable on next boot and reset it to point to "OS boot Manager" anyway.
By default, both of the paths above contain the same Microsoft bootloader (if you check the md5sum of both, you'll see they match).
So, until HP releases an updated UEFI that allows turning this "feature" off or rearranging boot options through the F10 UEFI setup, this is what you can do to get dual boot with the least amount of hackiness:
In Windows, mount the UEFI partition (mountvol S: /S
mounts it as the S: drive) and copy the file \EFI\Microsoft\Boot\bootmgfw.efi
to use some other name (for example, I copied it to \EFI\Microsoft\Boot\bootmgfw.efi~
, but you can change the name to anything else).
In the Windows command prompt, update the Windows UEFI entry to point to the new name:
bcdedit /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi~
(adapt to your set name accordingly).
Optionally, change the name of the Windows boot loader so that you would be certain that it points to the new file location:
bcdedit /set {bootmgr} description "Fixed Windows path"
Install the other OS. In my case the bootloader was installed into \EFI\opensuse\grubx64.efi
.
Delete the two files, \EFI\Microsoft\Boot\bootmgfw.efi
and \EFI\Boot\bootx64.efi
.
Use efibootmgr to delete the "OS boot Manager" entry:
sudo efibootmgr -b 0000 -B
Set the new OS bootloader to be the default bootloader by using efibootmgr with the -o
option. In my case, I had an entry called "opensuse" in slot Boot0001 and the updated path Windows entry in slot Boot0002, so I had to do sudo efibootmgr -o 0001,0002
Update GRUB to point the Windows entry to your renamed file (you'll have to create a new file in /etc/grub.d
and rerun grub-mkconfig
).
And that's it, now the UEFI will boot GRUB by default (it won't regenerate the "OS boot Manager" entry since it won't be able to find either of the two hardcoded paths and will "fall back" to properly reading the BootOrder variable), and the F9 menu will still allow choosing to boot Windows directly.
So you don't have to struggle with the grub configuration, here is the windows entry that I put in my /etc/grub.d/40_custom file:
menuentry "HP / Microsoft Windows 8.1" {
echo "Loading HP / Microsoft Windows 8.1"
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 3C62-71F3
chainloader /EFI/Microsoft/Boot/bootmgf2.efi
}
YOUR UUID WILL NOT BE 3C62-71F3. Use this command to find it:
grub-probe --target=fs_uuid /boot/efi/EFI/Microsoft/Boot/bootmgf2.efi
YOUR gpt partition and hints may be different. Use this commannd:
grub-probe --target=hints_string /boot/efi/EFI/Microsoft/Boot/bootmgf2.efi
To get your grub configuration edits compiled:
grub-mkconfig -o /boot/grub/grub.cfg