Ubuntu – Grub not loading config file or booting into linux automatically

bootdual-bootelementary-osgrub2Ubuntu

I was trying to dual boot elementary os with windows on my laptop (Asus Zenbook UX305). To do that I shrank the windows partition using the windows disk manager, and then used the Elementary installer's "install alongside windows" option to set up the linux partitions automatically. When I rebooted after installing I was put into the grub console. I was able to boot linux manually with the commands

grub> set root=(hd0,gpt4)
grub> linux /boot/vmlinuz-3.19.0-26-generic root=/dev/sda4
grub> initrd /boot/initrd.img-3.19.0-26-generic
grub> boot  

and I found that running the command

grub> configfile (hd0,gpt4)/boot/grub/grub.cfg

would load the normal grub menu as is supposed to happen – so there don't seem to be any problems with the config file itself. I also found that the root and prefix are on (hd0,gpt1), so running

grub> set root=(hd0,gpt4)
grub> set prefix=(hd0,gpt4)/boot/grub
grub> insmod normal
grub> normal

also loaded the normal grub menu. So possibly the problem is that grub is looking on the wrong partition?

In my BIOS, I have a choice between using grub and the windows bootloader to boot. Selecting the windows bootloader boots me directly into windows without any problems.

However, I can't find any way to get any fixes to stick after a reboot. I've tried rerunning grub-install /dev/sda, recreating the config file with grub-mkconfig, and using the Ubuntu boot repair gui tool – none of these have worked. Is there any way to fix this short of reinstalling either or both OSs? I'd rather not have to reinstall windows if possible.

Best Answer

It seems that the GRUB menu is failing to load because it is reading an incorrect efi file in /boot/efi/EFI/grub/.

Once you have booted into elementaryOS, run the following commands to replace the grubx64.efi file within that folder.

cd /boot/efi/EFI/grub
sudo cp grubx64.efi grubx64.efi.backup (just in case)
sudo rm grubx64.efi
sudo cp /boot/grub/x86_64-efi/grub.efi /boot/efi/EFI/grub/grubx64.efi

This solution comes from users discussing a reported bug in elementaryOS. See details at: https://bugs.launchpad.net/elementaryos/+bug/1492801

I faced the exact same issue as you (I have installed elementaryOS Freya 0.3.1 alongside Windows 10) and followed the steps you described before finding this solution.

It is worth noting that before applying the fix, I had disabled fast startup in Windows 10 which may or may not had an effect. See http://www.tenforums.com/tutorials/4189-fast-startup-turn-off-windows-10-a.html

In addition, I had to disable secure boot in order for this to work. With secure boot enabled, my UX305 failed to load grub completely. Press the Esc key on the first screen at startup, then enter setup and turn secure boot off from there. Alternatively, there may be a way to get secure boot to work but I am happy with this solution for now - my UX305 now loads the GRUB menu complete with a Windows option!

Related Question