What do you do when your Linux machine boots in a Grub prompt?
This happened to me a few weeks ago, and searching resulted in old advice that didn't work for me.
I am on Xubuntu 24.04 LTS, with UEFI.
Among things that you could try are:
- Hit Enter
- Type 'boot' then hit Enter
Other advice was to mount the EFI partition and so on.
What ended up working in my case is what I describe in the rest of the article.
The root cause was that the file /etc/default/grub was missing, for some unknown reason.
It is likely that a update renamed it to grub.ucf-dist and didn't complete the update tasks so it ended up missing.
Know Your Partitions
Before you start, it helps to know what your partitions look like.
On my laptop, they are like this:
Device Mount Point
/dev/nvme0n1p1 /boot/efi
/dev/nvme0n1p2 /Or they may be like this, depending on whether you use extended partitions:
Device Mount Point
/dev/nvme0n1p1 /boot/efi
/dev/nvme0n1p5 /List The Partitions From Grub Prompt
One you boot and you see the grub prompt, enter the ls command.
The output will look something like this:
ls
(proc) (memdisk) (hd0) (hd0,gpt1), (hd0,gpt5)We are interested only in the hd0 device and its partitions, since it is the only storage device on the laptop, and the only bootable device.
Search For The Root File System
You need to search for the partition containing the root file systen, which has Linux on it.
Use TAB for autocomplete at the end of the line
ls (hd0,gpt5)/If there is a boot directory, then list what is in it (use TAB again):
ls (hd0,gpt5)/boot/You should see files starting with vmlinuz-* and initrd.img-*
Once you have confirmed that this partition is the one that contains Linux images and initrd images, set it as your root
Set Root Partition
set root=(hd0,5)Set The Linux and Initrd Images
Then tell Grub where the kernel is, and the root partition, in Linux's notation
If you have a hard disk, or SSD, then this will be /dev/sdaX
But in this case it is an NVME.
linux /boot/vmlinuz-6.8.0-110-generic root=/dev/nvme0n1p5Then tell grub where the initrd file is:
initrd /boot/initrd.img-6.8.0-110-genericBoot Grub
Finally execute the boot command:
bootIf all works, you should be back in your Linux system.
And now you can proceed with restoring the /etc/default/grub file, and run update-grub.
Most Comments
Most commented on articles ...