GRUB2 failed to install

I want to install Ubuntu Gnome alongside Windows. I made two partitions, one ext4 and one swap partition. For the bootloader I chose the /dev/nvme0n1p1 partition, which is my Windows-EFI-Partition.

At the end of the Installation I get the error:

Unable to install GRUB in /dev/nvme0n1p1
Executing `grub-install /dev/nvme0n1p1 failed.
This is a fatal error.

EDIT

partition table is GPT:

Partition Table

lsblk output:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb           8:16   1   104M  1 disk 
└─sdb1        8:17   1 103.8M  1 part /media/ubuntu-gnome/USB-C DOCK
loop0         7:0    0   1.3G  1 loop /rofs
sda           8:0    1  14.5G  0 disk 
└─sda1        8:1    1  14.5G  0 part /cdrom
nvme0n1     259:0    0 238.5G  0 disk 
├─nvme0n1p5 259:5    0  12.5G  0 part 
├─nvme0n1p3 259:3    0   185G  0 part 
├─nvme0n1p1 259:1    0   500M  0 part 
├─nvme0n1p6 259:6    0  35.4G  0 part 
├─nvme0n1p4 259:4    0   450M  0 part 
├─nvme0n1p2 259:2    0   128M  0 part 
└─nvme0n1p7 259:7    0   4.6G  0 part

sudo mdadm --detail-platform output:

mdadm: imsm capabilities not found for controller: /sys/devices/pci0000:00/0000:00:17.0 (type SATA)


Solution 1:

Just to document FAT32 ESP - efi system partition issues and possible fixes.

First try either chkdsk from Windows or dosfsck from Linux on the ESP - efi system partition which is FAT32 formatted. Where X is drive and Y is partition, often ESP is first partition on sda or sda1. But some new drives are NVMe devices where drive is nvme0n1 and full drive & partition (p1) is /dev/nvme0n1p1.

sudo dosfsck -t -a -w /dev/sdXY

Some cases require full back up of the ESP which is always a good idea before doing anything anyway, deletion of the FAT32 partition with gparted and then use gparted just to recreate it, format as FAT32 and it must have boot flag to make it the ESP. Restore boot files. But you may have to reinstall grub or use efibootmgr to add entries as UEFI uses GUID which new partition will have new GUID.

More info on partitioning:

How to prepare a disk on an EFI based PC for Ubuntu?

See also

man efibootmgr