Skip to content

Instantly share code, notes, and snippets.

@0xsonu
Last active June 8, 2023 18:05
Show Gist options
  • Save 0xsonu/d493ff573a3b5567ac921531c06f7837 to your computer and use it in GitHub Desktop.
Save 0xsonu/d493ff573a3b5567ac921531c06f7837 to your computer and use it in GitHub Desktop.
UEFI: How to repair Kali-linux grub dual boot with windows

UEFI: How to repair kali-linux grub dual boot with Windows 10

If you have dual booted kali with Windows 10 then most probably you are running PC with UEFI firmware. The booting process of UEFI is completely different from that of BIOS. Right after installation or after updating your UEFI, do you find that kali is missing from boot menu options? You can see the entry of Windows boot manager but there is no entry of kali in boot menu.

The reason can be failed grub installation or Windows major updates. If you update UEFI it deletes the entry of kali from NVRAM.

If you update UEFI from 1.x to 2.x then entry of Grub is removed from the boot-menu. Follow this post if you did this If you update UEFI from 1.x to 1.y then it remains there.

Boot into kali live USB and follow the instructions:

mount /dev/sda* /mnt
mkdir mnt/dev
mkdir mnt/proc
mkdir -p /mnt/sys/firmware/efi/efivars
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
mkdir -p /mnt/boot/efi
mount /dev/sda+ /mnt/boot/efi
mount -o remount,rw /dev/sda+ /mnt/boot/efi
mkdir /mnt/hostrun
mount --bind /run /mnt/hostrun
chroot /mnt
mkdir /run/lvm
mount --bind /hostrun/lvm /run/lvm
grub-install /dev/sda
update-grub
exit
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys/firmware/efi/efivars
umount /mnt/sys
umount /mnt/boot/efi
umount /mnt/hostrun
umount /mnt/run/lvm
umount /mnt
REBOOT
  • /dev/sda* is your linux filesystem. Like mine is /dev/sda6
  • /dev/sda+ is your EFI partition which is most likely /dev/sda1.
  • Use fdisk -l to list all partitions.
  • /dev/sda in grub-install /dev/sda is the name of your storage device, not the name of partition. Use fdisk -l to see the name of your stoage device.

If you are in grub rescue mode, then run these commands to reconfigure grub:

ls
set root=(hd0,gptx)
set prefix=(hd0,gptx)/boot/grub
insmod normal
normal

ls(LS) lists all the partitions of your hard drive like this (hd0) (hd0,gpt1) (hd0,gpt2). You can make some guesses which one is your kali filesystem to replace the variable x in gptx.

Once you boot into kali open terminal and type:

grub-install /dev/sda
update-initramfs -u
update-grub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment