Dual boot Win 8 / Ubuntu loads only Win

Sony, HP, and many laptop vendors are hard-coded to only boot Windows.

There are several work-a-rounds that suggest you move the grub grubx64.efi or shimx64.efi file on top of the Windows /EFI/windows/bootmgfw.efi. However this isn't recommended because Windows Update will restore bootmgfw.efi and you'll be back to only Booting windows.

Instead, I suggest renaming the fallback /EFI/Boot/bootx64.efi and boot hard drive entry or use rEFInd.

Make sure you backup the entire EFI partition before making changes.

You have several options available:

I. Move and rename the grub files grubx64.efi or shim64.efi (for secure boot) to this folder/file /EFI/BOOT/BOOTX64.EFI

  1. Rename /efi/boot/bootx64.efi, copy shim or grub into /efi/boot and name it bootx64.efi Then boot hard drive entry. New versions of Boot-Repair automatically do this with 'Use the standard EFI file' in advanced options. It also backs up current bootx64.efi which is probably just a copy of Windows .efi boot file.

    From live installer mount the efi partition on hard drive: Mount efi partition. check which partition is FAT32 with boot flag. Often sda1 or sda2 but varies.

    sudo mount /dev/sda1 /mnt
    

    only if not already existing,

    sudo mkdir /mnt/EFI/Boot
    sudo cp /mnt/EFI/ubuntu/* /mnt/EFI/Boot
    

    If new folder created, the bootx64.efi will not exist, skip this command

    sudo mv /mnt/EFI/Boot/bootx64.efi /mnt/EFI/Boot/bootx64.efi.backup
    

    Make grub be hard drive boot entry in UEFI. If not existing, may have to update UEFI also with efibootmgr.

    sudo mv /mnt/EFI/Boot/grubx64.efi /mnt/EFI/Boot/bootx64.efi 
    

    If need be, add a new UEFI hard drive boot entry: See also

    man efibootmgr
    

    If ESP is sda or default drive & partition entries:

    sudo efibootmgr -c -L "UEFI Hard drive" -l "\EFI\Boot\bootx64.efi"
    

    If ESP is not sda1, sdX is drive, Y is efi partition, also NVMe drives :

    sudo efibootmgr -c -g  -w -L "UEFI hard drive" -l '\EFI\Boot\bootx64.efi' -d /dev/sdX -p Y
    sudo efibootmgr -c -L "UEFI hard drive" -l "\EFI\Boot\bootx64.efi" -d /dev/nvme0n1 -p 2 
    
  2. (This is the same as what Boot-Repair used to do in II. Not now recommended: Rename /efi/Microsoft/Boot/bootmgfw.efi and copy grub or shim into /efi/Microsoft/Boot and name it bootmgfw.efi Then boot Windows entry to boot to grub menu. You have to manually add a grub menu entry to boot renamed Windows efi file. Grub2's os-prober entry boots bootmgfw.efi entry which is now just grub, so it will not work.

    Users who manually moved efi files around see post #6.

    http://ubuntuforums.org/showthread.php?t=2101840
    http://ubuntuforums.org/showthread.php?t=2219452
    http://ubuntuforums.org/showthread.php?t=2221498&p=13012109#post13012109

II. If you ran Boot-Repair's fix for "buggy UEFI" with an older copy it's best to undo it. And then make the change above to use bootx64.efi To undo and to rename files to their original names, you just need to tick the "Restore EFI backups" option of Boot-Repair.

Any rename either manually or with Boot-Repair will need to be redone after a Windows update as it will restore Windows files.

III. Edit Windows BCD, one alternative to Boot-Repair's rename to make shim have Windows name. Some systems work better to register grub/shim from inside Windows - for those that keep resetting Windows as default.

Grub not showing on startup for Windows 8.1 Ubuntu 13.10 Dual boot

bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

https://coderwall.com/p/vfyqkg

IV. If Description has to be Windows, then change UEFI description. This really only works for those with just Ubuntu, and no Windows install at all.

sudo efibootmgr -c -L "Windows Boot Manager" -l "\EFI\ubuntu\shimx64.efi"

Restore or a new Windows UEFI entry - assumes default sda1 add -p 2 if sda2 (see man efibootmgr -d drive & -p partition options):

sudo efibootmgr -c -L "Windows Boot Manager" -l "\EFI\Microsoft\Boot\bootmgfw.efi"
sudo efibootmgr -c -L "Windows Boot Manager" -l "\EFI\Microsoft\Boot\bootmgfw.efi" -d /dev/nvme0n1 -p 1 

V. Some install rEFInd which seems to be another workaround and has nice boot icons.

http://www.rodsbooks.com/refind/index.html

http://www.rodsbooks.com/refind/secureboot.html

PPA available to make it easy to install in Ubuntu

http://www.rodsbooks.com/refind/getting.html

VI. Restore Ubuntu UEFI entry sdX is drive, Y is efi partition , if sda2 for example

sudo efibootmgr -c -L ubuntu -l "\EFI\ubuntu\shimx64.efi"  -d /dev/sda -p 1
sudo efibootmgr -c -L "Ubuntu" -l "\EFI\ubuntu\shimx64.efi" -d /dev/nvme0nX -p Y

VII. Change boot order with efibootmgr:

Change boot order using efibootmgr

VIII. Uninstall UEFI entry:

Uninstall Grub and use Windows bootloader Change boot order using efibootmgr


The answer above didn't work for my friend's HP Pavilion, but I found a decent workaround. It seems that HP's firmware always overwrites the BootOrder on every boot and sets Windows first, but it still respects BootNext. So I wrote a startup script to set BootNext on every boot.

  1. Run

    efibootmgr
    

    to find the numeric code of BootCurrent. In my friend's case this was 0003.

  2. /etc/systemd/system/boot-linux-next.service:

    [Unit]
    Description=Boot Linux next
    
    [Service]
    Type=oneshot
    # Replace '3' in the next line with the appropriate code.
    ExecStart=efibootmgr --bootnext 3
    
    [Install]
    WantedBy=multi-user.target
    
  3. Run

    systemctl enable --now boot-linux-next.service
    

This does mean that if you ever boot something else you will have to manually select Linux on boot next time.