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?
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:
efibootmgrwhen booted into Linux.
- Boot into an EFI-enabled Linux livecd in EFI mode. Any would do.
- 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.
- Choose a mount point for the main distribution. I'll use
/mnt/targetas an example.
- 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/efiafter creating that directory.
- I now have my environment set up.
grub2-install --efi-directory=/boot/efiinside the chroot.
- 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
- Exit the chroot, unmount everything in reverse order you mounted, then reboot.
- It should now boot into GRUB2 by default.