2

I recently formatted my Ubuntu hard disk to install Kali on it. I formatted the entire hard disk through the Kali installation process. Now, my pc boots to "GNU GRUB Version 2.02" with "grub>" command line. Exiting this I managed to get to my boot manager, where I found that Ubuntu's grub was still in my Hard disk.

As u can see it still sees 2 grubs

From here, I'm able to finally get to kali' grub and boot the OS. Choosing Ubuntu brings me back to the black "GNU GRUB Version 2.02" screen. I can use the computer like this, but it's a really annoying process. Anyone has suggestions on what could I do to skip the whole process and repair my bootloader? Booting directly into kali at startup would be fine, since it's the only OS on my hd.

4

You don't need live boot utilities or boot-repair for this.

Boot into kali, then run sudo efibootmgr (or just efibootmgr as root).

It should display a list that should look something like this:

BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0000,0001  <there may be other 4-digit numbers on this line>
Boot0000* Ubuntu
Boot0001* Kali
<... possibly other BootNNNN lines with other stuff...>

The 4-digit numbers may be different, but the general layout should be the same.

Now, BootOrder tells the system firmware the order in which the various boot targets listed on the BootNNNN lines should be attempted, and on your system, the number referring to Kali is after the one referring to Ubuntu.

Since you want to get rid of the last vestiges of Ubuntu, the next step is simple: look at the BootNNNN lines, find the 4-digit number on the line that says Ubuntu. We'll call that number XXXX.

Now, use this command to delete Ubuntu's UEFI boot entry:

sudo efibootmgr -b XXXX -B

Replace XXXX with the actual four-digit number.

That solves your immediate problem: Ubuntu's GRUB will no longer run at boot time. But it still exists on the disk.

Your ESP partition should be mounted into /boot/efi, and if you have only one disk, that's where Ubuntu's GRUB actually lives. Look into directory /boot/efi/EFI/: you should find in there one directory for each OS installed on this disk, probably named as just ubuntu and kali (capitalization may be different).

To thoroughly remove the last vestiges of Ubuntu's bootloader, just remove the whole /boot/efi/EFI/ubuntu directory:

sudo rm -r /boot/efi/EFI/ubuntu

Be careful with this command: if you accidentally remove the kali directory instead, you'll need to reinstall the bootloader with grub-install /dev/sda or similar command.

  • Awesome, this worked and it has been so simple! Does kali come with other boot manager other the efiboot one? I have another kali pc i would fix some boot issues in – Kodeeo May 24 at 14:43
  • efibootmgr is a tool that manipulates UEFI firmware boot variables; it is pretty much standard in all Linux installations that use native UEFI boot, and completely useless on non-UEFI systems. I don't actually know Kali all that well, but since it's based on Debian/Ubuntu, I'd expect it to have a number of various boot managers available, although it uses just GRUB by default (and on UEFI systems, efibootmgr to configure the firmware NVRAM variables for it on installation). – telcoM May 24 at 16:50
  • Actually, it didn't have it. but apt install efibootmanager solved the issue – Kodeeo May 24 at 18:06
  • Interesting. Then the UEFI GRUB may now have its own routine for manipulating the boot variables, and it no longer depends on efibootmgr for installation, as I think it once used to do; nevertheless, having efibootmgr at hand and understanding its use can only be a good thing on UEFI systems. – telcoM May 25 at 23:32
0

Use a live boot utility like YannuBuntu's Boot-Repair-Disk or add boot-repair to your OS to find the old GRUB2 and remove it.

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.