[CentOS] Re-enable grub boot in UEFI (Windows took over it)

Mon Feb 5 15:27:19 UTC 2018
Kay Diederichs <kay.diederichs at uni-konstanz.de>

On 02/01/2018 12:15 PM, wwp wrote:
> Hello there,
> 
> 
> Dell XPS-15-9560 laptop (SSD drive, UEFI, secure boot off).. Windows 10
> pre-installed, CentOS7 installed in a separate partition and running
> for months w/o issue. Don't know what happened but at reboot yesterday
> (not even booted in Windows, just rebooted), grub has disappeared,
> booted in Windows by default, which apparently has taken over the UEFI
> boot.


The DELL XPS-13-9360 in its BIOS has an option (named "auto boot
recovery" or similar - sorry the machine is somewhere else) that is by
default enabled. I guess you have it enabled as well.

This option is triggered by two unsuccessful boot trials, and leads to
the loss of the grub menu, and restoration of the (non-grub) "Windows
boot manager" (or whatever it's called).

After being bit by it once, I disabled it.

HTH,

Kay

P.S. I recovered my Ubuntu grub menu by booting from the Ubuntu live
USB, and then
sudo su
mount /dev/nvme0n1p7 /mnt
cd /mnt
mount /dev/nvme0n1p1 boot/efi
mount --bind /proc proc
mount --bind /sys sys
mount --bind /dev dev
chroot /mnt
grub-install /dev/nvme0n1
update-grub

On CentOS, the last two lines would be

grub2-install  /dev/nvme0n1
grub2-mkconfig -o etc/grub2.cfg


> 
> By booting from a USB drive w/ CentOS7 LiveGnome, I could use its grub
> command prompt to inspect the UEFI of the local SSD drive, see that the
> centos/ sub-directory and files are still there.
> 
> /boot/efi/EFI/centos/:
> BOOT.CSV
> BOOTX64.CSV
> fonts
> grub.cfg
> grub.cfg.1501243846.rpmsave
> grub.cfg.1505469290.rpmsave
> grubenv
> grubx64.efi
> mmx64.efi
> shim.efi
> shimx64-centos.efi
> shimx64.efi
> 
> maybe /boot/efi/EFI/Boot/ contents has been altered?
> 
> /boot/efi/EFI/Boot/:
> bootx64.efi
> fbx64.efi
> 
> I had a backup of the full efi partition (`dd`) but it's outdated and
> I feel it's a bad idea to restore the partition from it.
> 
> Still from this "external" grub prompt, I could boot into my CentOS7
> using:
>  configfile (hd0,gpt1)/EFI/centos/grub.cfg
> 
> At least I know how to get back to it :-).
> 
> But now, how could I give the UEFI control back to grub? Is there a
> grub2 or grubby command I can run to make grub the default? I've read a
> lot and still cannot figure out exactly what to do or don't dare
> running commands that could make things worse.
> 
> And I have the feeling the at next Windows boot, I may need to do it
> again..
> 
> 
> Regards,
> 
> 
> 
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos
>