How to Fix GRUB Installation Failure on /dev/nvme0n1 During Ubuntu 22.04 Setup
When deploying Ubuntu 22.04 on systems equipped with NVMe sollid state drives, the Unable to install GRUB in /dev/nvme0n1 error often appears in the final stages of the setup process, blocking successful installation.
Diagnostic Steps
Confirm Storage Device Paths
First verify that /dev/nvme0n1 maps to your target installation drive by listing all connected block devices with the following command (run from the live installation environment terminal):
lsblk -e7
The output will list all physical storage devices and their associated partitions, allowing you to confirm the correct NVMe drive identifier.
Verify Boot Mode
Ensure your system is booted in UEFI mode rather than Legacy BIOS mode, as NVMe drives require UEFI for standard bootloader operations. Confirm your boot mode by runing:
efivar -l
A list of EFI variables confirms UEFI mode is active. If the command returns an error, reboot into your system firmware (BIOS/UEFI) settings and enable UEFI boot mode.
Check for EFI System Partition
UEFI boot requires a dedicated FAT32-formatted EFI System Partition (ESP) to store bootloader files. If no ESP exists on your target NVMe drive, GRUB installation will fail.
Disable Secure Boot
Temporarily disable Secure Boot in your firmware settings during installation. Secure Boot may block unsigned GRUB binaries from being written to the EFI partition, causing insatllation failures. You can re-enable Secure Boot post-installation if you configure signed boot shim packages.
Update GRUB Packages in Live Environment
If you are using an older Ubuntu 22.04 installation ISO, update the GRUB packages in the live environment before launching the installer too resolve known compatibility bugs:
sudo apt update && sudo apt install --only-upgrade grub-common grub-efi-amd64-signed
Confirm Bootloader Target
If you have multiple storage drives connected to your system, ensure you have selected the NVMe drive you are installing Ubuntu to as the target for bootloader installation, rather than a secondary HDD or USB drive.
Root Cause for Custom Partitioning Setups
The most common trigger for this error when using custom partitioning is failing to create and assign an EFI System Partition during the setup process. If you only configure a root (/) partition and no ESP, GRUB has no valid location to install its boot files, leading to the error.
Fix for Missing EFI Partition
During the custom partitioning step of Ubuntu setup, create a valid EFI partition with the following steps:
- Select the unallocated free space on your target NVMe drive
- Click the
+button to create a new partition - Set the partition size to between 300MB and 1024MB (larger capacities are functional but unnecessary for standard use)
- Select
EFI System Partitionas the partition type from the dropdown menu - Click
OKto save the partition configuration
Once the EFI partition is created, proceed with the remaining installation steps as normal. The GRUB bootloader will install to the new EFI partition, allowing the system to boot successfully after setup completes.