16

My computer is a Sony Vaio Notebook. I used Ubuntu and Win 8 with dualboot but windows somehow managed to remove the menu to choose the OS at startup. I think the BIOS is UEFI. Secure boot was disabled already and Boot Repair somehow fails.

How can I fix this?

2

3 Answers 3

26

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

IX. You can use system UEFI/BIOS settings key (often F2, check your manual) to change the boot order or other UEFI settings that then will be in the UEFI boot menu (often F12):

https://askubuntu.com/a/757426/53503

3
  • Yes! Renaming worked for me! I mounted the efi partition and copied the files ../EFI/ubuntu/grubx64.efi to ../EFI/Boot/ and to /EFI/Microsoft/Boot and changed the name of the file as follows. In the ../EFI/Boot directory I overwrote the bootx64.efi with the file and in the ../EFI/Microsoft/Boot i overwrote the bootmgfw.efi with the file . That was all I think. Thank you very much!
    – user296880
    Jun 23, 2014 at 20:28
  • 1
    For those stuck on Windows: I managed to do the rename approach describe in option a1 without leaving Windows. I opened a command window as administrator, then ran mountvol S: /S to mount the EFI partition as S:. I had odd issues with going up and down folders, but moving a copy of grubx64.efi a folder at a time into /EFI/Boot, then renaming it to bootx64.efi worked. Sep 17, 2015 at 10:59
  • I am surprised the English major who renumbered my post did not do that. I had older comments referring to A: & B: as major sections. :)
    – oldfred
    Dec 29, 2019 at 16:16
3

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.

1
  • For my HP, what really worked for me was the most simple solution possible. It just took me two weeks to find in this answer: askubuntu.com/a/757426/53503
    – brandizzi
    Dec 15, 2022 at 10:01
1

I have an Acer that has the same problem. My solution is to "reboot" windows, rather than shutdown (which is really just a hybernate.)

By rebooting (Which may trigger updates,) the system shuts down and you can select boot from the bios. You do have to catch it before it reboots.

I rarely use windows so booting this way doesn't bother me at all. Unless, of course, windows updates.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .