4

I have a Windows 10 install on an NVMe drive. I've installed Ubuntu 20.04 and all installed smoothly, until the first boot. I was greeted with a grub prompt.

grub>

After searching the forums and finding a wealth of information, I've been able to issue the following command and reach GRUB bootloader (and both Windows and Ubuntu load correctly from there):

grub> configfile (hd1,gpt5)/boot/grub/grub.cfg

However, when I reboot, I'm back to the grub command line. I've also found the following commands from the forums:

grub> set root=(hd1,gptN)
grub> set prefix=(hd1,gptN)/boot/grub/
grub> insmod normal
grub> normal

These commands also bring me to my grub menu and I can safely boot into either OS (Windows or Ubuntu). The problem is that I have to do this each time. Thus, I'm trying to make a permanent change to my grub settings.

Once in Ubuntu, I can update grub from the command line, and I can also reinstall grub. Both with the following.

$: sudo update-grub
$: sudo grub-install /dev/nvme0n1pX

However, I'm at a loss of how to ensure the correct partition number for X in the grub-install command. Is it as simple as N from the root/prefix commands within the above grub terminal? Or is there more definitive way to check which partition number to choose?

Any help is much appreciated.

user641699
  • 41
  • 2

1 Answers1

0

On UEFI systems you need to specify the device, not a partition. grub-install should detect the correct device automatically, so

sudo grub-install

and

sudo grub-install /dev/nvme0n1

should both work.

Freddy
  • 25,172
  • 1
  • 21
  • 60
  • I can confirm that neither of these commands resolve my problem. I've tried them both. With both I get a return of: `Installing for x86_64-efi platform.` `Installation finished. No error reported.` But I'm still greeted with a grub prompt upon rebooting. – user641699 Feb 03 '21 at 22:35
  • I still think (although, possibly wrong) that I need to explicitly tell grub into which partition to install. I'm quite confident that I know the partition number, but I'd love to find a way to positively identify it... without guessing. – user641699 Feb 03 '21 at 22:38
  • After a successful installation `root` and `prefix` are defined in `grub.cfg` in your ESP (usually mounted as `/boot/efi/EFI/ubuntu/grub.cfg` in Ubuntu) defining the path to your GRUB configuration (`/boot/grub/grub.cfg`). Check if UUID and partition are set to the correct values. You can override the locations to the EFI and boot directory (`--efi-directory` and `--boot-directory`) when invoking `grub-install`, but you don't specify any partition numbers. – Freddy Feb 04 '21 at 11:52
  • Thanks for the comment, @Freddy. If I'm reading the grub.cfg file correctly (in `/boot/efi/EFI/grub/grub.cfg` actually), it appears to be pointing to the correct GRUB configuration file (UUID and paths are correct, that is). I've discovered that `/boot/grub/` and `/boot/efi` are on separate partitions. Is this normal/expected? I checked your comment about overriding the EFI location by issuing `sudo grub-install /dev/nvme0n1 --efi-directory=/boot/efi/`. However, after rebooting... same grub command line. :( – user641699 Feb 05 '21 at 15:15
  • Interesting that your path is `/boot/efi/EFI/grub` and not `/boot/efi/EFI/ubuntu` like on my VM running 20.04... So the value of your UEFI boot entry points to `\EFI\grub\shimx64.efi` (list with `efibootmgr -v`)? Different partitions for `/boot/grub` (your root partition or boot partition) and `/boot/efi` (ESP) are correct. – Freddy Feb 05 '21 at 15:48
  • I wonder why your config file is not loaded if the values seem correct. Try this: In the grub commandline, enter `set`. Compare the values of `root` and `prefix` with the ones you enter manually. Also check the values of `config_directory` and `config_file`. Test if `cat $prefix/grub.cfg` prints your `grub.cfg`. Using `--efi-directory=/boot/efi` should not make a difference since `/boot/efi` is the default value, but you can try it. – Freddy Feb 05 '21 at 15:48
  • for your first comment, yes, `efibootmgr -v` does indeed point to `\EFI\grub\shimx64.efi`. I will check your second comments today when I'm back in the office. Thanks so much for all your assistance. – user641699 Feb 08 '21 at 15:41
  • Okay, I think we're making progress. First, `root` and `prefix` point to the EFI partition (which _I think_ is correct?). However, `cat $prefix/grub.cfg` returns with `error: file '/EFI/ubuntu/grub.cfg' not found.`. Finally an error message I can work with! It seems your suspicions about the `/boot/efi/EFI/` might be correct. I'm not much of a grub expert here. Any suggestions on my next step? – user641699 Feb 08 '21 at 16:04
  • Sorry for stretching out so many comments here. I double-checked all paths and noticed that `prefix` is set to `(hd0,gpt2)/EFI/ubuntu`. Since I my grub.cfg is not in `ubuntu`, but rather in `/efi/grub/`, I changed (i.e., `set`) the path correctly. However, after issuing all the commands from my original post `set ...`, `insmod normal`, `normal` followed by `update-grub` and `grub-install`, I was back to the grub prompt after a reboot. I noticed, then, that prefix is back to `(hd0,gpt2)/EFI/ubuntu`! Did I miss something? – user641699 Feb 08 '21 at 16:14
  • No. `prefix` should point to the location where your `/boot/grub` directory is, same as in your question. But `config_file` should point to the (small) `grub.cfg` on your EFI partition, this is `(hd0,gpt1)/EFI/ubuntu/grub.cfg` in my installation and should be something with `/EFI/grub/grub.cfg` in yours. I don't know why your installation is using the `/EFI/grub` path in the first place, it should be `/EFI/ubuntu` and this value is probably hardcoded in your `grubx64.efi`. You can try to fix the wrong `root` and `prefix` values in `/EFI/grub/grub.cfg`, but I'm not sure if this is enough. – Freddy Feb 08 '21 at 17:03