Restoring GRUB EFI

GRUB
GRUB is a multiboot boot loader. The name stands originally for GRand Unified Bootloader.

A boot loader (like GRUB) is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software (Linux in this case). The kernel, in turn, initializes the rest of the operating system (GNU).

Restoring GRUB requires to use a Live Session, any DVD/USB/SD media storage with a recent version of Parrot or Debian can be used to succeed. Some detailed commands:

:large_blue_circle: Mounting the Partition with the System of Interest

GParted can be used to know the partition name for replacing X with the partition letter and Y with its number.

In the following example, the disk is sda, and the root partition is sda3

sudo mount /dev/sda3 /mnt

If the /boot folder has a dedicated partition, then it has to be mounted as well.

In the following example the boot partition is sda2, and it is not required if you don’t have /boot in an external partition. Separate /boot partitions are common in encrypted systems:

sudo mount /dev/sda2 /mnt/boot

In a UEFI computer, the EFI/ESP partition has to be mounted properly in order to fix the grub installation.

The EFI partition can be easily found with gparted because it is a fat12, fat16 or fat32 partition with the ESP flag enabled.

In the following example the EFI/ESP partition is sda1

sudo mount /dev/sda1 /mnt/boot/efi

:large_blue_diamond: Binding Directories for GRUB’s OS detection

sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys &&
sudo mount --bind /run /mnt/run

:large_blue_circle: Mounting with Chroot

sudo chroot /mnt

:large_blue_circle: Installing, Checking and Updating

Only the letter has to be indicated (to replace X), usually it is “a”.

apt update && apt dist-upgrade
apt install grub-efi
grub-install /dev/sdX
grub-install --recheck /dev/sdX
update-grub

:large_blue_diamond: Unbinding Directories

exit &&
sudo umount /mnt/sys &&
sudo umount /mnt/proc &&
sudo umount /mnt/dev/pts &&
sudo umount /mnt/dev &&
sudo umount /mnt

:large_orange_diamond: Rebooting the System

sudo reboot

Finally, this procedure is not intended to replace easier solutions like using Rescatux, Super Grub Disk, Boot-Repair or even Grub Customizer but to show how to take advantage from a Live Session to restore GRUB EFI in a broken Parrot 4.2 systems or future versions where grub was not installed properly.

3 Likes

i updated the topic to better address the grub-efi installation error of Parrot 4.2

It doesn’t works for me!
-EFI folder doesn’t exist