2

I recently installed Kali on my Win 10 machine. Win 10 boots in EFI. I don't know how, but I somehow managed to install grub in legacy mode. Now I always have to switch between legacy and EFI in the BIOS depending if I want to boot into Win 10 or into Kali. Is there a way to reinstall GRUB to the EFI partition and get it all to work so that GRUB will start up Win 10 and Kali?

3

You have to boot Linux with EFI mode to get access to EFI variables and the ability to use efibootmgr so you can switch to grub. This guide may be of some use.

The procedure I would use would be as follows:

  1. Install efibootmgr when booted into Linux.
  2. Boot into an EFI-enabled Linux livecd in EFI mode. Any would do.
  3. Ensure you are in EFI mode by checking for the existence of /sys/firmware/efi/efivars. If I'm not in EFI mode it's not present.
  4. Choose a mount point for the main distribution. I'll use /mnt/target as an example.
  5. I would run mount /dev/<root partition> /mnt/target, then mount -t proc proc /mnt/target/proc, mount -t sysfs sysfs /mnt/target/sys, mount -o bind /dev /mnt/target/dev, and mount -t tmpfs tmpfs /mnt/target/run. I would also make sure to mount other partitions from my install if needed, including /boot, and also mount the EFI partition (usually the first one) to /mnt/target/boot/efi after creating that directory.
  6. I now have my environment set up. chroot /mnt/target.
  7. Run grub2-install --efi-directory=/boot/efi inside the chroot.
  8. Run something like efibootmgr -c -d /dev/<disk> -p Y -l \EFI\grub\bootx64.efi" -L "GRUB" if grub2-install doesn't do that for you. You'll want to ensure the path to the bootx64.efi file is GRUB2's EFI file in /boot/efi.
  9. Exit the chroot, unmount everything in reverse order you mounted, then reboot.
  10. It should now boot into GRUB2 by default.
  • Untrue. You can also get at the UEFI variables from Windows 10 or from the UEFI Shell. – fpmurphy Jul 26 '16 at 4:54
  • 1
    @fpmurphy1 item 3 above was not about accessing the efivars but rather about checking that the host is booted in EFI mode – Michael Shigorin Jul 26 '16 at 6:11
  • @MichaelShigorin Item 8 above is about accessing UEFI variables. – fpmurphy Jul 26 '16 at 14:39
  • sigh go access those with efibootmgr using win10, UEFI shell, any other atrocity, and let's not spam the discussion anymore before you're done with that. – Michael Shigorin Jul 27 '16 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.