When GRUB drops you into a shell instead of booting Ubuntu, the bootloader cannot find its configuration or kernel files. This usually happens because the EFI System Partition is missing, corrupted, or not mounted correctly in the GRUB environment. You can resolve this by manually locating the correct disk and partition, mounting them, and then either chaining to Windows or booting Linux directly from the command line.
Understanding the GRUB Shell Environment
Thegrub> prompt indicates that the standard GRUB menu system failed to initialize. Unlike a full operating system, the GRUB shell has limited commands and no access to your installed hard drive unless it is explicitly identified and mounted. The error often stems from a mismatch between where GRUB was installed and where the /boot/grub directory actually resides. In dual-boot setups with Windows 10, this frequently occurs if the UEFI partition was accidentally deleted or if the BIOS/UEFI boot order changed after a hardware update.
Before attempting any fixes, identify which disk contains your Ubuntu installation. Use the ls command followed by a space to list available devices. The output will look something like (hd0,gpt1), (hd0,gpt2), etc. Note that these identifiers are relative to the GRUB environment, not necessarily matching /dev/sda in Linux. You must determine which device holds your root filesystem and which holds the EFI System Partition (ESP).
Locating Your Partitions
To find your partitions, use thels -l command on potential devices. Look for file systems labeled as ext4 for your Ubuntu root partition and FAT32 for the EFI partition. For example:
ls (hd0,gpt1)/
ls (hd0,gpt2)/
If one partition lists directories like boot, etc, and home, that is likely your Ubuntu root. If another shows files like EFI, BOOT, and microsoft, that is your ESP. Write down the correct device identifiers for both. If you cannot identify the partitions easily, you may need to boot from a Live USB to verify the partition layout using fdisk -l or lsblk, then return to the GRUB shell with that knowledge.
Booting Ubuntu Manually from the Shell
Once you have identified the correct partitions, you can attempt to boot Ubuntu directly. Assume(hd0,gpt2) is your root partition and (hd0,gpt1) is your EFI partition. First, set the root device to your Ubuntu partition:
set root=(hd0,gpt2)
Next, load the Linux kernel. You need to specify the path to the vmlinuz file inside the boot directory. The exact filename depends on your installed kernel version. You can discover it by listing the contents of the boot directory:
ls /boot/vmlinuz-*
Suppose the output shows vmlinuz-5.15.0-generic. Load the kernel with the following command, ensuring you include the ro flag for read-only mode and root=/dev/sdXN pointing to your actual root partition device name (e.g., /dev/sda2):
linux /boot/vmlinuz-5.15.0-generic root=/dev/sda2 ro
After loading the kernel, you must load the initial RAM filesystem (initrd). List the initrd files similarly:
ls /boot/initrd.img-*
Load the corresponding initrd image:
initrd /boot/initrd.img-5.15.0-generic
Finally, start the boot process with the boot command. If successful, Ubuntu will load. However, this is a temporary fix. To make it permanent, you must repair the GRUB installation from within a working Linux environment.
Repairing GRUB Permanently
Booting from the shell does not fix the underlying issue. Once you are logged into Ubuntu, open a terminal and reinstall GRUB to ensure it can find the EFI partition and configuration files next time. The method depends on whether your system uses UEFI or Legacy BIOS. Most modern Windows 10 installations use UEFI. For UEFI systems, mount the EFI partition first. Identify the EFI partition device (e.g.,/dev/sda1) and mount it to /boot/efi:
sudo mount /dev/sda1 /boot/efi
Then, reinstall GRUB using the correct target architecture. Do not use /dev/sda directly without specifying the EFI target, as this can overwrite critical Windows bootloader files. Use the following command:
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu
This command writes the GRUB EFI binary to the correct location on the FAT32 partition. Afterward, update the GRUB configuration file to reflect the current kernel versions:
sudo update-grub
Reboot your computer. If the repair was successful, the GRUB menu should appear normally, allowing you to select Ubuntu or Windows 10. If the system still fails to boot, check your BIOS/UEFI settings to ensure the Ubuntu bootloader entry is prioritized or enabled. Refer to Accidentally Deleted UEFI Partition: Can't Boot Linux Mint if the EFI partition itself is missing and needs reconstruction from a backup or live media.
Chaining to Windows 10
If your primary goal is simply to access Windows 10 when GRUB fails, you can chainload the Windows bootloader from the GRUB shell. Assuming(hd0,gpt1) is your EFI partition containing the Windows bootloader:
set root=(hd0,gpt1)
Navigate to the Microsoft bootloader path:
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
Press Enter to execute. This transfers control to the Windows bootloader, allowing you to boot into Windows 10. This is useful if you cannot immediately repair Linux but need access to your Windows data. However, note that Cant boot dual partition - GRUB issue discusses scenarios where partition UUIDs change, which might require updating the grub.cfg file once you regain access to the OS.
Common Pitfalls and Verification
Ensure that theroot variable points to the correct partition before loading kernels. A common mistake is confusing the EFI partition with the root partition. Always verify with ls commands. Additionally, check that the kernel and initrd filenames match exactly, including hyphens and version numbers. Typos here will result in "file not found" errors. If you frequently encounter this issue, consider backing up your /boot/grub/grub.cfg file regularly. For insights into how modules are loaded during this process, see Understanding the Loading of Modules by initramfs in Linux.
Frequently Asked Questions
Why did my GRUB menu disappear completely?
This usually happens when the /boot/grub/grub.cfg file is deleted or the EFI partition is formatted. Without this configuration file, GRUB falls back to the minimal shell interface. Reinstalling GRUB from a Live USB or chroot environment restores the necessary files.
Can I use the GRUB shell to edit my boot options?
No, the GRUB shell is a runtime environment, not a text editor. You can type commands to boot temporarily, but any changes made here are lost on reboot. Permanent edits must be made to /etc/default/grub and /boot/grub/grub.cfg within the Linux OS.
What if I don't know the kernel version?
You can list available kernels by typing ls /boot/vmlinuz-* in the GRUB shell. This will display all compatible kernel images stored in the boot directory of the mounted partition, allowing you to select the correct filename for the linux command.
Is it safe to run grub-install on a dual-boot system?
Yes, provided you specify the correct EFI directory and target. Using --target=x86_64-efi ensures only the Ubuntu bootloader is written to the EFI partition, leaving the Windows bootloader intact. Avoid running it without arguments, as it may detect the wrong disk.
How do I prevent this from happening again?
Regularly update GRUB after kernel upgrades using sudo update-grub. Also, avoid formatting the EFI partition unless you intend to reinstall Linux. Keeping a backup of your grub.cfg file allows for quick restoration if corruption occurs.