1

I somehow erased all the boot options in my bios (maybe caused by some operation using super-grub disk). I have tried to fix my grub using boot-repair live-usb. After performing recommended repair and reboot, there is still no boot option in the bios, and I'm brought to the bios setup screen itself everytime I boot.

Complete information about my setup is here.

The whole story started when I found my windows cannot boot (BCD broken error). Then I thought it was a grub issue so I used boot-repair in my linux and performed the recommended repair. Then I found I cannot get into my linux either, only left with a grub> prompt. So I tried super-grub disk and super-grub2 disk live. Then I found I've basically erased all my boot-options in the bios/uefi. Now I've installed another linux (kubuntu) in hope that the new installation could fix the grub, but it didn't. So I finally tried boot-repair live usb and performed the recommended repair, but still no luck. Any idea how to fix this?

2 Answers 2

1

If your only problem is that the UEFI NVRAM boot options (boot variables) are gone, you'll have several options:

If you can boot from external media in UEFI mode:

  • mount the root filesystem of your OS, mount /proc, /sys and /dev to it, then chroot into that filesystem, mount the ESP partition and run grub-install (assuming /dev/sdX is the root filesystem of your OS installation)
mount /dev/sdX /mnt
mount -t proc none /mnt/proc
mount --rbind /dev /mnt/dev
mount --rbind /sys /mnt/sys
chroot /mnt /bin/bash
mount /boot/efi
grub-install /dev/sdX

grub-install will automatically generate the UEFI boot variable for GRUB, but it requires having the efivarfs virtual filesystem mounted at /sys/firmware/efi/efivars and the system booted in UEFI mode.

  • or mount your ESP partition without chrooting and use efibootmgr to manually recreate your boot options: (assuming /dev/sdX1 is your ESP partition)
mount /dev/sdX1 /boot/efi

ls /boot/efi/EFI # there should be a directory for each OS/distribution

efibootmgr -c -d /dev/sdX1 -L "Any label you want" -l \\EFI\\<distro name>\\shimx64.efi  
# or ...\\grubx64.efi if Secure Boot disabled
  • If Secure Boot is enabled, and your OS installation has the Secure Boot shim installed, there might be a special grub-install option. Chroot as in the first option, then run:
grub-install --uefi-secure-boot /dev/sdX

If your external media can only boot in legacy BIOS mode:

  • Chroot like in the first option above, but use this grub-install line:
grub-install --target=x86_64-efi --force-extra-removable /dev/sdX

In legacy mode, you may get an error message about being unable to access UEFI boot variables, but you can ignore that for now.

This install a second copy of GRUB as [ESP mount path]/EFI/boot/bootx64.efi, which is the location where the firmware expects to find a UEFI fallback/removable media bootloader. After this, the firmware should detect the ESP partition as "bootable in UEFI mode", and you should be able to use the BIOS boot menus to select it for booting. Since there is now only UEFI-bootable disks present (after removing the external boot media), even the most legacy-preferring UEFI firmware should now boot in UEFI mode.

After the system boots up in UEFI mode, you can run grub-install /dev/sdX again to recreate the standard UEFI boot variable for your Linux OS.

0

finally fixed it with gdisk. not sure which is the crucial step, but after backing up and restoring the uefi header and partition table, upon reboot my linux will try to fix the disk and then fail to mount the efi system partition. At this stage, running gdisk from the rescue command line automatically discovers an erroneous "active" flag associated with the efi system partition. Just letting it fix the flag solves the problem.

It's not a problem with the bios or uefi. I also tried wiping out the efi system partition and reinstalling windows 10. However, that didn't help.

You must log in to answer this question.

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