Clean Install of 18.04 Boots to Grub Prompt

I'm stuck at a grub prompt since installing Ubuntu 18.04. I have tried all the things I can find online but I'm stumped.

It was a clean install of Ubuntu 18.04 started from a USB stick. I had 17.10 installed but selected to overwrite my old installation during the new install. I also have a Windows 10 partition as I dual boot.

The install happened fine, but now when I boot my machine I end up at the grub> prompt.

If I type exit Ubuntu boots with no problems.

If I manually select the drive with Windows on from my BIOS it loads with no problems.

I tried using the grub-rescue disk tool but it says it can't run because it's not in EFI mode.

An output of the diagnostics from this shows:

=================== Suggested repair
The default repair of the Boot-Repair utility would purge (in order to fix packages) and reinstall the grub-efi-amd64-signed of nvme0n1p7, using the following options:        nvme0n1p1/boot/efi,
Additional repair would be performed: unhide-bootmenu-10s   fix-windows-boot use-standard-efi-file

I've tried installing grub using this:

sudo grub-install --efi-directory=/dev/nvme0n1p1/

But I get an error:

Installing for i386-pc platform.
grub-install: error: install device is not specified.

It's a nvmie drive. I'm a bit stumped. Any ideas of what else I can try?


Solution 1:

I was able to solve mine (though I was using EFI and not legacy) by booting from the install thumb drive, selecting rescue mode, and re-installing grub on /dev/sda.

Solution 2:

Reinstall Ubuntu in CSM / Legacy mode

There was confusion about whether your installation was UEFI or CSM (Legacy BIOS mode). Recent comments show it's the latter. Using this reference:

Converting Ubuntu into Legacy mode

Note: Use this procedure only to convert an UEFI-mode Linux installation to boot in BIOS/CSM/legacy mode. Such a conversion may be necessary if some hardware doesn't work correctly under UEFI mode. (Video cards are a common source of problems.) Converting to boot in BIOS/CSM/legacy mode while Windows boots in UEFI mode can make the boot process more awkward -- you'll need to use the computer's built-in boot manager to switch between OSes, and some computer's have such poor boot managers that this may be impossible.

  1. If Ubuntu is installed on a GPT disk (you can check it via the 'sudo parted -l' command), use Gparted to create a BIOS-Boot partition (1MB, unformatted filesystem, bios_grub flag) at the start of its disk.

  2. Start Boot-Repair, click on "Advanced options", go to the "GRUB location" tab.

  3. Untick the "Separate /boot/efi partition" option

  4. Click the "Apply" button.

  5. Set up your BIOS so that it boots the HDD in Legacy mode (see the ""Set up the BIOS in UEFI or Legacy mode" paragraph above).


Original answer below

You are trying to install grub to your root partition but it needs to go into the EFI partition which is about 500 MB usually. Full instructions are available here

Basically the correct syntax is:

sudo grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB

Solution 3:

To install grub you need to specify the correct parameters for the grub-install command.

This is what i used about an hour ago to reinstall grub after booting to the prompt too:

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader=ubuntu --boot-directory=/boot/efi/EFI/ubuntu --recheck

Assuming you have mounted the boot partition to /boot, and the EFI partition to /boot/efi, the above command should work given that there is enough space to fit grub on the EFI partition.

If you are installing to a USB drive and don't want to install grub to your PC's EFI partition, make sure that there is an EFI partition on the USB drive and that that partition is mounted to /boot/efi instead of your PC's.