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:
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
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
Mounting with Chroot
sudo chroot /mnt
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 --recheck /dev/sdX
exit && sudo umount /mnt/sys && sudo umount /mnt/proc && sudo umount /mnt/dev/pts && sudo umount /mnt/dev && sudo umount /mnt
Rebooting the System
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.