The "This GPT partition label contains no BIOS boot partition" message suggests that you may have booted your live media in legacy BIOS style, and as a result, you'll wind up trying to install a BIOS version of GRUB onto a GPT-partitioned disk.
/dev/sda2
seems to be your EFI System Partition (ESP), which should get mounted to /mnt/boot/efi
. Because ESP exists on your disk, it indicates your system was previously booting in the native UEFI way.
/dev/sda3
is a swap partition.
The remaining three partitions, sda1
, sda4
and sda5
are all ext4
. One of these is your root filesystem. Another might be a separate /boot
filesystem. What is in the remaining one?
First, you'll need to boot your recovery live media using the same boot style (either BIOS or UEFI) as was used by the system you're trying to repair; by default, the GRUB installer will auto-detect the type of bootloader to install according to the way the system is currently booted. And installing a UEFI version of GRUB requires access to UEFI NVRAM variables, which will only be available if the system is booted in native UEFI mode.
You can verify the current boot mode by running sudo efibootmgr -v
: if it outputs a list of boot settings, the system is booted in UEFI native mode. If it displays an error message "EFI variables are not supported on this system", you have most likely booted the system in legacy BIOS compatibility mode.
If your installation had /boot
as a separate filesystem, you'll need three steps:
- Mount the root filesystem to
/mnt
in the live medium. After that, /mnt/boot
should now exist (among other things).
- Mount the
/boot
filesystem to /mnt/boot
in the live medium. After that, /mnt/boot/efi
and /mnt/boot/grub
directories should now exist.
- Mount the ESP to
/mnt/boot/efi
in the live medium. After that, a directory path like /mnt/boot/efi/EFI/ubuntu
should now exist, assuming that traces of previous installation of Ubuntu's UEFI GRUB are still there. Yes, it is normal to have .../efi/EFI/...
in the directory structure. And since the ESP is a FAT32 filesystem which is designed to be case-insensitive, the case of the names of directories and files under /mnt/boot/efi
may vary.
Once this is completed, you can proceed with the remaining steps:
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub